ui: Again fix issue with conversations not loading
Again: If we receive a message before first loading a conversation, it won't load it on open.
This commit is contained in:
parent
eb744bc9a4
commit
b95fc032b0
@ -19,12 +19,10 @@ void conversationMiddleware(Store<MoxxyState> store, action, NextDispatcher next
|
||||
"jid": args.jid
|
||||
});
|
||||
|
||||
if (!store.state.messages.containsKey(args.jid)) {
|
||||
FlutterBackgroundService().sendData({
|
||||
"type": "LoadMessagesForJidAction",
|
||||
"jid": args.jid
|
||||
});
|
||||
}
|
||||
FlutterBackgroundService().sendData({
|
||||
"type": "LoadMessagesForJidAction",
|
||||
"jid": args.jid
|
||||
});
|
||||
} else if (action is SetOpenConversationAction) {
|
||||
FlutterBackgroundService().sendData({
|
||||
"type": "SetCurrentlyOpenChatAction",
|
||||
|
@ -83,6 +83,16 @@ class DatabaseRepository {
|
||||
|
||||
/// Loads all messages for the conversation with jid [jid].
|
||||
Future<void> loadMessagesForJid(String jid) async {
|
||||
if (this.loadedConversations.indexOf(jid) != -1) {
|
||||
this.sendData({
|
||||
"type": "LoadMessagesForJidResult",
|
||||
"jid": jid,
|
||||
"messages": this._messageCache[jid]!.map((m) => m.toJson()).toList()
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
final messages = await this.isar.dBMessages.where().conversationJidEqualTo(jid).findAll();
|
||||
this.loadedConversations.add(jid);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user