commit 16b9e6b87955d26875107604a464b40c1e91236a
parent 0f3ca2afa6f68a53fddf6c3e6dcc1481fb9f8c7b
Author: Marcel <mtrnord1@gmail.com>
Date: Sat, 30 May 2020 23:22:04 +0200
Better Initial Sync detection
Took 9 minutes
Diffstat:
4 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/app/components/room_list.rs b/src/app/components/room_list.rs
@@ -73,12 +73,16 @@ impl Component for RoomList {
self.state.loading = false;
true
}
- // Handle new rooms from sync
- Response::Sync(msg) => {
- // TODO properly do this...
+ // Better Initial Sync Detection
+ Response::SyncPing => {
if self.state.rooms.is_empty() {
self.matrix_agent.send(Request::GetJoinedRooms);
+ return true;
}
+ false
+ }
+ // Handle new rooms from sync
+ Response::Sync(msg) => {
if !(self
.state
.rooms
diff --git a/src/app/matrix.rs b/src/app/matrix.rs
@@ -75,6 +75,7 @@ pub enum Response {
LoggedIn(bool),
// TODO properly handle sync events
Sync(MessageWrapper),
+ SyncPing,
FinishedFirstSync,
JoinedRoomList(HashMap<RoomId, SmallRoom>),
Userdata(),
diff --git a/src/app/matrix/sync.rs b/src/app/matrix/sync.rs
@@ -44,6 +44,9 @@ impl Sync {
async fn on_sync_response(&self, response: SyncResponse) {
for (room_id, room) in response.rooms.join {
+ // Is there a smarter way?
+ let resp = Response::SyncPing;
+ self.callback.emit(resp);
for event in room.timeline.events {
if let Ok(event) = event.deserialize() {
self.on_room_message(&room_id, event).await
diff --git a/src/app/views/main_view.rs b/src/app/views/main_view.rs
@@ -55,7 +55,7 @@ impl Component for MainView {
match msg {
Msg::NewMessage(response) => match response {
Response::FinishedFirstSync => {
- self.matrix_agent.send(Request::GetJoinedRooms);
+ //self.matrix_agent.send(Request::GetJoinedRooms);
}
_ => {}
},