feat: add function to prevent message audios being assigned as room lastEvent so they don't show as chat list subtitles (#1343)
This commit is contained in:
parent
be7bb5dd36
commit
f4e9823384
4 changed files with 30 additions and 35 deletions
|
|
@ -16,15 +16,6 @@ class GetChatListItemSubtitle {
|
|||
ModelKey.transcription,
|
||||
];
|
||||
|
||||
bool moveBackInTimeline(Event event) =>
|
||||
hideContentKeys.any(
|
||||
(key) => event.content.tryGet(key) != null,
|
||||
) ||
|
||||
event.type.startsWith("p.") ||
|
||||
event.type.startsWith("pangea.") ||
|
||||
event.type == EventTypes.SpaceChild ||
|
||||
event.type == EventTypes.SpaceParent;
|
||||
|
||||
String _constructTokens(
|
||||
List<PangeaToken> tokens,
|
||||
List<PangeaToken> hiddenTokens,
|
||||
|
|
@ -54,23 +45,6 @@ class GetChatListItemSubtitle {
|
|||
) async {
|
||||
if (event == null) return l10n.emptyChat;
|
||||
try {
|
||||
String? eventContextId = event.eventId;
|
||||
if (!event.eventId.isValidMatrixId || event.eventId.sigil != '\$') {
|
||||
eventContextId = null;
|
||||
}
|
||||
|
||||
final Timeline timeline = event.room.timeline != null &&
|
||||
event.room.timeline!.chunk.eventsMap.containsKey(eventContextId)
|
||||
? event.room.timeline!
|
||||
: await event.room.getTimeline(eventContextId: eventContextId);
|
||||
|
||||
if (moveBackInTimeline(event)) {
|
||||
event = timeline.events.firstWhereOrNull((e) => !moveBackInTimeline(e));
|
||||
if (event == null) {
|
||||
return l10n.emptyChat;
|
||||
}
|
||||
}
|
||||
|
||||
if (!pangeaController.languageController.languagesSet ||
|
||||
event.redacted ||
|
||||
event.type != EventTypes.Message ||
|
||||
|
|
@ -86,6 +60,16 @@ class GetChatListItemSubtitle {
|
|||
);
|
||||
}
|
||||
|
||||
String? eventContextId = event.eventId;
|
||||
if (!event.eventId.isValidMatrixId || event.eventId.sigil != '\$') {
|
||||
eventContextId = null;
|
||||
}
|
||||
|
||||
final Timeline timeline = event.room.timeline != null &&
|
||||
event.room.timeline!.chunk.eventsMap.containsKey(eventContextId)
|
||||
? event.room.timeline!
|
||||
: await event.room.getTimeline(eventContextId: eventContextId);
|
||||
|
||||
final PangeaMessageEvent pangeaMessageEvent = PangeaMessageEvent(
|
||||
event: event,
|
||||
timeline: timeline,
|
||||
|
|
@ -144,7 +128,7 @@ class GetChatListItemSubtitle {
|
|||
? i18n.you
|
||||
: event.room
|
||||
.getParticipants()
|
||||
.firstWhereOrNull((u) => u.id != event!.room.client.userID)
|
||||
.firstWhereOrNull((u) => u.id != event.room.client.userID)
|
||||
?.calcDisplayname(i18n: i18n) ??
|
||||
event.room.lastEvent!.senderId;
|
||||
|
||||
|
|
@ -158,10 +142,10 @@ class GetChatListItemSubtitle {
|
|||
e: e,
|
||||
s: s,
|
||||
data: {
|
||||
"event": event?.toJson(),
|
||||
"event": event.toJson(),
|
||||
},
|
||||
);
|
||||
return event?.body ?? l10n.emptyChat;
|
||||
return event.body;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ import 'dart:io';
|
|||
|
||||
import 'package:desktop_notifications/desktop_notifications.dart';
|
||||
import 'package:fluffychat/config/app_config.dart';
|
||||
import 'package:fluffychat/pangea/constants/model_keys.dart';
|
||||
import 'package:fluffychat/pangea/constants/pangea_event_types.dart';
|
||||
import 'package:fluffychat/utils/custom_http_client.dart';
|
||||
import 'package:fluffychat/utils/custom_image_resizer.dart';
|
||||
|
|
@ -145,6 +146,11 @@ abstract class ClientManager {
|
|||
),
|
||||
),
|
||||
),
|
||||
shouldReplaceRoomLastEvent: (_, event) {
|
||||
return event.content.tryGet(ModelKey.transcription) == null &&
|
||||
!event.type.startsWith("p.") &&
|
||||
!event.type.startsWith("pangea.");
|
||||
},
|
||||
// Pangea#
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,15 @@
|
|||
import 'dart:core';
|
||||
|
||||
import 'package:fluffychat/pages/chat_list/chat_list.dart';
|
||||
import 'package:fluffychat/pages/dialer/dialer.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'package:flutter_foreground_task/flutter_foreground_task.dart';
|
||||
import 'package:flutter_webrtc/flutter_webrtc.dart' as webrtc_impl;
|
||||
import 'package:matrix/matrix.dart';
|
||||
import 'package:webrtc_interface/webrtc_interface.dart' hide Navigator;
|
||||
|
||||
import 'package:fluffychat/pages/chat_list/chat_list.dart';
|
||||
import 'package:fluffychat/pages/dialer/dialer.dart';
|
||||
import 'package:fluffychat/utils/platform_infos.dart';
|
||||
import '../../utils/voip/callkeep_manager.dart';
|
||||
import '../../utils/voip/user_media_manager.dart';
|
||||
import '../widgets/matrix.dart';
|
||||
|
|
@ -195,4 +194,10 @@ class VoipPlugin with WidgetsBindingObserver implements WebRTCDelegate {
|
|||
@override
|
||||
// TODO: implement keyProvider
|
||||
EncryptionKeyProvider? get keyProvider => throw UnimplementedError();
|
||||
|
||||
@override
|
||||
Future<void> registerListeners(CallSession session) {
|
||||
// TODO: implement registerListeners
|
||||
throw UnimplementedError();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1523,10 +1523,10 @@ packages:
|
|||
description:
|
||||
path: "."
|
||||
ref: main
|
||||
resolved-ref: "53737bd566f5a430369589081ced4ee1cf4df51a"
|
||||
resolved-ref: f03945433cbcf7ffc33b521a9190630d8bb54513
|
||||
url: "https://github.com/pangeachat/matrix-dart-sdk.git"
|
||||
source: git
|
||||
version: "0.35.0"
|
||||
version: "0.36.0"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue