Skip to content

Commit e541b3e

Browse files
committed
search message improvement
1 parent 32b0463 commit e541b3e

File tree

7 files changed

+211
-129
lines changed

7 files changed

+211
-129
lines changed

src/home/home_screen.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,5 +344,5 @@ impl MatchEvent for NavigationWrapper {
344344
pub enum MessageSearchInputAction {
345345
#[default]
346346
Show,
347-
Hide
348-
}
347+
Hide,
348+
}

src/home/main_desktop_ui.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ use std::{collections::HashMap, sync::Arc};
55

66
use crate::{app::{AppState, AppStateAction, SelectedRoom}, shared::message_search_input_bar::{MessageSearchAction, MessageSearchInputBarRef}, utils::room_name_or_id};
77
use super::{invite_screen::InviteScreenWidgetRefExt, room_screen::RoomScreenWidgetRefExt, rooms_list::RoomsListAction};
8+
89
live_design! {
910
use link::theme::*;
1011
use link::shaders::*;
@@ -172,7 +173,7 @@ impl MainDesktopUI {
172173

173174
self.open_rooms.insert(room_id_as_live_id, room.clone());
174175
self.most_recently_selected_room = Some(room.clone());
175-
// Calls AppStateAction::RoomFocused action to display the search message input box when a room is open.
176+
// Call AppStateAction::RoomFocused action to display the search message input box when a room is open.
176177
cx.widget_action(
177178
self.widget_uid(),
178179
&HeapLiveIdPath::default(),
@@ -222,7 +223,7 @@ impl MainDesktopUI {
222223
self.open_rooms.remove(&tab_id);
223224
// Clear the search input when a room is closed
224225
cx.get_global::<MessageSearchInputBarRef>().set_text("");
225-
// clear the search results when a room is closed
226+
// Clear the search results when a room is closed
226227
cx.widget_action(self.widget_uid(), &Scope::empty().path, MessageSearchAction::Changed(String::new()));
227228
}
228229

src/home/room_screen.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,8 @@ pub struct RoomScreen {
859859
#[rust] is_loaded: bool,
860860
/// Whether or not all rooms have been loaded (received from the homeserver).
861861
#[rust] all_rooms_loaded: bool,
862+
/// Whether the timeline loaded notification has been sent for the current room.
863+
#[rust] timeline_loaded_notified: bool,
862864
}
863865
impl Drop for RoomScreen {
864866
fn drop(&mut self) {
@@ -1331,11 +1333,12 @@ impl Widget for RoomScreen {
13311333
};
13321334
let room_id = &tl_state.room_id;
13331335
let tl_items = &tl_state.items;
1334-
if !tl_items.is_empty() {
1336+
if !tl_items.is_empty() && !self.timeline_loaded_notified {
13351337
// Signal waiting threads that this room's timeline has loaded and is ready to jump to specific messages.
13361338
if let Ok(map) = ROOM_TIMELINE_LOADED_MAP.read() {
13371339
if let Some(notify) = map.get(room_id) {
13381340
notify.notify_one();
1341+
self.timeline_loaded_notified = true;
13391342
}
13401343
}
13411344
}
@@ -1792,7 +1795,7 @@ impl RoomScreen {
17921795
item_id: index
17931796
};
17941797
} else {
1795-
log!("essage not found - trigger backwards pagination to find it");
1798+
log!("Message not found - trigger backwards pagination to find it");
17961799
// Message not found - trigger backwards pagination to find it
17971800
loading_pane.set_state(
17981801
cx,
@@ -2625,6 +2628,8 @@ impl RoomScreen {
26252628
self.loading_pane(id!(loading_pane)).take_state();
26262629
self.room_name = room_name_or_id(room_name.into(), &room_id);
26272630
self.room_id = Some(room_id.clone());
2631+
// Reset timeline loaded notification flag for the new room
2632+
self.timeline_loaded_notified = false;
26282633

26292634
// We initially tell every MentionableTextInput widget that the current user
26302635
// *does not* has privileges to notify the entire room;
@@ -4406,7 +4411,7 @@ impl Widget for Message {
44064411
&scope.path,
44074412
RoomsListAction::Selected(target_selected_room)
44084413
);
4409-
submit_async_request(MatrixRequest::WaitForRoomTimelineDrawnToJump { room_id: jump_request.room_id.clone(), event_id: jump_request.event_id.clone() });
4414+
submit_async_request(MatrixRequest::WaitForRoomTimelineLoadedToJump { room_id: jump_request.room_id.clone(), event_id: jump_request.event_id.clone() });
44104415
}
44114416
}
44124417
self.view.handle_event(cx, event, scope);

0 commit comments

Comments
 (0)