Skip to content

Commit

Permalink
Merge pull request #209 from syphon-org/bugfix-less-message-jank
Browse files Browse the repository at this point in the history
[bugfix] less message jank
  • Loading branch information
ereio authored Dec 16, 2020
2 parents d4a0d97 + 222eccc commit f3a6bde
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions lib/store/rooms/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,31 @@ ThunkAction<AppState> syncRooms(Map roomData) {
'[syncRooms] ${room.name} ids msg count ${room.messageIds.length}',
);

// update cold storage
await Future.wait([
saveUsers(room.usersNew, storage: Storage.main),
saveRooms({room.id: room}, storage: Storage.main),
saveMessages(room.messagesNew, storage: Storage.main),
]);

// update store
await store.dispatch(
setUsers(room.usersNew),
);

await store.dispatch(
setMessageEvents(room: room, messages: room.messagesNew),
);

// update cold storage
await Future.wait([
saveUsers(room.usersNew, storage: Storage.main),
saveRooms({room.id: room}, storage: Storage.main),
saveMessages(room.messagesNew, storage: Storage.main),
]);

// TODO: remove with parsers - clear users from parsed room objects
room = room.copyWith(
users: Map<String, User>(),
messagesNew: List<Message>(),
);

// update room
store.dispatch(SetRoom(room: room));

// fetch avatar if a uri was found
if (room.avatarUri != null) {
store.dispatch(fetchThumbnail(
Expand All @@ -188,9 +192,6 @@ ThunkAction<AppState> syncRooms(Map roomData) {
from: room.prevHash,
));
}

// update room
store.dispatch(SetRoom(room: room));
});
};
}
Expand Down

0 comments on commit f3a6bde

Please sign in to comment.