From 5e3a64f83a43e6773657e7cbe286c13fbd6876de Mon Sep 17 00:00:00 2001 From: ereio Date: Tue, 15 Dec 2020 21:26:41 -0500 Subject: [PATCH 1/2] swap cold storage and store save --- ios/Flutter/.last_build_id | 2 +- lib/store/rooms/actions.dart | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/ios/Flutter/.last_build_id b/ios/Flutter/.last_build_id index 519724b4f..f62316d17 100644 --- a/ios/Flutter/.last_build_id +++ b/ios/Flutter/.last_build_id @@ -1 +1 @@ -2bf2ac012f4e7616c95ee0f58edbde23 \ No newline at end of file +9d5105d4c4a3b343276bbd9fb40da225 \ No newline at end of file diff --git a/lib/store/rooms/actions.dart b/lib/store/rooms/actions.dart index 27583e7f9..5f0d73376 100644 --- a/lib/store/rooms/actions.dart +++ b/lib/store/rooms/actions.dart @@ -149,14 +149,6 @@ ThunkAction 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), @@ -164,12 +156,23 @@ ThunkAction syncRooms(Map roomData) { 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(), messagesNew: List(), ); + // update room + store.dispatch(SetRoom(room: room)); + // fetch avatar if a uri was found if (room.avatarUri != null) { store.dispatch(fetchThumbnail( @@ -188,9 +191,6 @@ ThunkAction syncRooms(Map roomData) { from: room.prevHash, )); } - - // update room - store.dispatch(SetRoom(room: room)); }); }; } From 222ecccbb84be17a22a8c233f480a0230465b856 Mon Sep 17 00:00:00 2001 From: ereio Date: Tue, 15 Dec 2020 21:36:04 -0500 Subject: [PATCH 2/2] add await for clarity --- ios/Flutter/.last_build_id | 2 +- lib/store/rooms/actions.dart | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ios/Flutter/.last_build_id b/ios/Flutter/.last_build_id index f62316d17..519724b4f 100644 --- a/ios/Flutter/.last_build_id +++ b/ios/Flutter/.last_build_id @@ -1 +1 @@ -9d5105d4c4a3b343276bbd9fb40da225 \ No newline at end of file +2bf2ac012f4e7616c95ee0f58edbde23 \ No newline at end of file diff --git a/lib/store/rooms/actions.dart b/lib/store/rooms/actions.dart index 5f0d73376..e065589a9 100644 --- a/lib/store/rooms/actions.dart +++ b/lib/store/rooms/actions.dart @@ -160,7 +160,8 @@ ThunkAction syncRooms(Map roomData) { await store.dispatch( setUsers(room.usersNew), ); - store.dispatch( + + await store.dispatch( setMessageEvents(room: room, messages: room.messagesNew), );