Skip to content

Commit

Permalink
swap cold storage and store save
Browse files Browse the repository at this point in the history
  • Loading branch information
ereio committed Dec 16, 2020
1 parent d4a0d97 commit 5e3a64f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ios/Flutter/.last_build_id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2bf2ac012f4e7616c95ee0f58edbde23
9d5105d4c4a3b343276bbd9fb40da225
22 changes: 11 additions & 11 deletions lib/store/rooms/actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,27 +149,30 @@ ThunkAction<AppState> syncRooms(Map roomData) {
'[syncRooms] ${room.name} ids msg count ${room.messageIds.length}',
);

// 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),
]);

// update store
await store.dispatch(
setUsers(room.usersNew),
);
store.dispatch(
setMessageEvents(room: room, messages: room.messagesNew),
);

// 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 +191,6 @@ ThunkAction<AppState> syncRooms(Map roomData) {
from: room.prevHash,
));
}

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

0 comments on commit 5e3a64f

Please sign in to comment.