Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
31ccf5b
added highlight
alanpoon Apr 3, 2025
8009d1e
added search message logic
alanpoon Apr 11, 2025
0cff367
Merge branch 'main' into search_messages#122
alanpoon Apr 11, 2025
4506ddb
resolve conflict
alanpoon Apr 11, 2025
1620a30
add search_all_room
alanpoon Apr 11, 2025
81a842a
added room_name in search result
alanpoon Apr 12, 2025
52d7efa
added small_state display in search result
alanpoon Apr 12, 2025
6b3fc4b
EventableWrapperETI
alanpoon Apr 13, 2025
a772bc2
before populate_small_state
alanpoon Apr 14, 2025
9c4b11e
migrate to use generic
alanpoon Apr 14, 2025
6d2d63e
Added early abort search message
alanpoon Apr 14, 2025
ea6cb60
t
alanpoon Apr 15, 2025
ef2ddb5
t
alanpoon Apr 15, 2025
5321861
added body_inner
alanpoon Apr 15, 2025
c76173e
fix condensed message in search result
alanpoon Apr 15, 2025
62aac00
fix search summary
alanpoon Apr 15, 2025
e7e2557
test
alanpoon Apr 16, 2025
c6d24a4
revert push branches
alanpoon Apr 16, 2025
42349b0
added code review
alanpoon Apr 16, 2025
ebd129b
revert
alanpoon Apr 16, 2025
b4aac11
added next_batch
alanpoon Apr 16, 2025
4046815
working templates
alanpoon Apr 18, 2025
f7faebc
before changing .items
alanpoon Apr 21, 2025
86269e6
t
alanpoon Apr 22, 2025
8810d4d
t
alanpoon Apr 22, 2025
904099f
added Topspace for search result
alanpoon Apr 22, 2025
f576ee6
fix clippy
alanpoon Apr 23, 2025
6238ea5
removed other_display
alanpoon Apr 23, 2025
a037893
populate_search_result_item
alanpoon Apr 23, 2025
ab20bc3
added close_search
alanpoon Apr 23, 2025
666f57d
before using timeline
alanpoon Apr 24, 2025
6d25822
t
alanpoon Apr 25, 2025
e5ea6a6
using timeline for search messages
alanpoon May 6, 2025
eea320c
added_has_context_before
alanpoon May 7, 2025
44437a2
removed populate_search_messages
alanpoon May 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,11 @@ jobs:
- uses: actions/checkout@v4
- name: Check for typos
uses: crate-ci/typos@master
setup-deepseek-review:
runs-on: ubuntu-latest
name: Code Review
steps:
- name: DeepSeek Code Review
uses: hustcer/deepseek-review@v1
with:
chat-token: ${{ secrets.CHAT_TOKEN }}
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ bytesize = "1.3.0"
bitflags = "2.6.0"
indexmap = "2.6.0"
blurhash = { version = "0.2.3", default-features = false }
ruma = { git = "https://github.com/ruma/ruma", rev = "7755c7cbc580f8d8aea30d78cc1a6850b1a6fd39", default-features = false, features = ["api", "client-api-c"] }

[package.metadata.docs.rs]
all-features = true
Expand Down
8 changes: 6 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use makepad_widgets::*;
use matrix_sdk::ruma::OwnedRoomId;

use crate::{
home::{main_desktop_ui::RoomsPanelAction, new_message_context_menu::NewMessageContextMenuWidgetRefExt, room_screen::MessageAction, rooms_list::RoomsListAction}, login::login_screen::LoginAction, shared::{callout_tooltip::{CalloutTooltipOptions, CalloutTooltipWidgetRefExt, TooltipAction}, popup_list::PopupNotificationAction}, verification::VerificationAction, verification_modal::{VerificationModalAction, VerificationModalWidgetRefExt}
home::{main_desktop_ui::RoomsPanelAction, new_message_context_menu::NewMessageContextMenuWidgetRefExt, room_screen::MessageAction, rooms_list::RoomsListAction}, login::login_screen::LoginAction, shared::{callout_tooltip::{CalloutTooltipOptions, CalloutTooltipWidgetRefExt, TooltipAction}, popup_list::PopupNotificationAction, search_bar::SearchBarWidgetRefExt}, verification::VerificationAction, verification_modal::{VerificationModalAction, VerificationModalWidgetRefExt}
};

live_design! {
Expand Down Expand Up @@ -193,6 +193,7 @@ impl MatchEvent for App {
self.update_login_visibility(cx);

log!("App::handle_startup(): starting matrix sdk loop");
self.app_state.search_widget = Some(self.ui.search_bar(id!(home_screen_search_bar)).widget_uid());
crate::sliding_sync::start_matrix_tokio().unwrap();
}

Expand Down Expand Up @@ -304,7 +305,6 @@ impl MatchEvent for App {
if let VerificationModalAction::Close = action.as_widget_action().cast() {
self.ui.modal(id!(verification_modal)).close(cx);
}

// // message source modal handling.
// match action.as_widget_action().cast() {
// MessageAction::MessageSourceModalOpen { room_id: _, event_id: _, original_json: _ } => {
Expand Down Expand Up @@ -407,6 +407,10 @@ pub struct AppState {
pub logged_in: bool,
/// The current window geometry.
pub window_geom: Option<event::WindowGeom>,
/// Main Desktop Ui's search widget uid.
/// Room screens will get this widget uid to differentiate search action
/// from search bar widget.
pub search_widget: Option<WidgetUid>,
}

#[derive(Default, Debug)]
Expand Down
16 changes: 7 additions & 9 deletions src/event_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ pub fn text_preview_of_timeline_item(
text_preview_of_member_profile_change(profile_change, sender_username)
}
TimelineItemContent::OtherState(other_state) => {
text_preview_of_other_state(other_state)
text_preview_of_other_state(other_state.content(),other_state.state_key())
.unwrap_or_else(|| TextPreview::from((
String::from("<i>initiated another state change</i>"),
BeforeText::UsernameWithoutColon,
Expand Down Expand Up @@ -132,7 +132,7 @@ pub fn body_of_timeline_item(
).text
}
TimelineItemContent::OtherState(other_state) => {
text_preview_of_other_state(other_state)
text_preview_of_other_state(other_state.content(), other_state.state_key())
.unwrap_or_else(|| TextPreview::from((
String::from("initiated another state change."),
BeforeText::UsernameWithoutColon,
Expand Down Expand Up @@ -290,12 +290,12 @@ pub fn text_preview_of_redacted_message(
TextPreview::from((text, BeforeText::Nothing))
}


/// Returns a text preview of the given other state event as an Html-formatted string.
pub fn text_preview_of_other_state(
other_state: &timeline::OtherState,
other_state: &AnyOtherFullStateEventContent,
state_key: &str
) -> Option<TextPreview> {
let text = match other_state.content() {
let text = match other_state {
AnyOtherFullStateEventContent::RoomAliases(FullStateEventContent::Original { content, .. }) => {
let mut s = String::from("set this room's aliases to ");
let last_alias = content.aliases.len() - 1;
Expand Down Expand Up @@ -370,10 +370,10 @@ pub fn text_preview_of_other_state(
Some(format!("changed this room's topic to {:?}.", content.topic))
}
AnyOtherFullStateEventContent::SpaceParent(_) => {
Some(format!("set this room's parent space to {}.", other_state.state_key()))
Some(format!("set this room's parent space to {}.", state_key))
}
AnyOtherFullStateEventContent::SpaceChild(_) => {
Some(format!("added a new child to this space: {}.", other_state.state_key()))
Some(format!("added a new child to this space: {}.", state_key))
}
_other => {
// log!("*** Unhandled: {:?}.", _other);
Expand All @@ -382,8 +382,6 @@ pub fn text_preview_of_other_state(
};
text.map(|t| TextPreview::from((t, BeforeText::UsernameWithoutColon)))
}


/// Returns a text preview of the given member profile change as a plaintext string.
pub fn text_preview_of_member_profile_change(
change: &MemberProfileChange,
Expand Down
2 changes: 1 addition & 1 deletion src/home/home_screen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ live_design! {
<View> {
flow: Down
width: Fill, height: Fill
<SearchBar> {}
home_screen_search_bar = <SearchBar> {}
<MainDesktopUI> {}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/home/main_desktop_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl MainDesktopUI {

// create a new tab for the room
let (tab_bar, _pos) = dock.find_tab_bar_of_tab(live_id!(home_tab)).unwrap();
let kind = live_id!(room_screen);
let kind: LiveId = live_id!(room_screen);

let result = dock.create_and_select_tab(
cx,
Expand Down Expand Up @@ -234,10 +234,10 @@ impl MainDesktopUI {
self.most_recently_selected_room = None;
}
}

dock.close_tab(cx, tab_id);
self.tab_to_close = None;
self.open_rooms.remove(&tab_id);
dock.item(tab_id).as_room_screen().close_search(cx);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/home/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ pub mod main_mobile_ui;
pub mod room_preview;
pub mod room_screen;
pub mod room_read_receipt;
pub mod room_search_result;
pub mod rooms_list;
pub mod rooms_sidebar;
pub mod spaces_dock;
Expand All @@ -24,6 +25,7 @@ pub fn live_design(cx: &mut Cx) {
editing_pane::live_design(cx);
new_message_context_menu::live_design(cx);
room_screen::live_design(cx);
room_search_result::live_design(cx);
room_read_receipt::live_design(cx);
rooms_sidebar::live_design(cx);
main_mobile_ui::live_design(cx);
Expand Down
19 changes: 13 additions & 6 deletions src/home/new_message_context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
use bitflags::bitflags;
use makepad_widgets::*;
use matrix_sdk::ruma::OwnedEventId;
use matrix_sdk_ui::timeline::EventTimelineItem;
use matrix_sdk_ui::timeline::InReplyToDetails;
use ruma::events::room::message::MessageType;

use crate::sliding_sync::UserPowerLevels;

use super::room_screen::{MessageAction, MessageOrSticker};
use super::room_screen::{MessageViewFromEvent, MessageAction, MessageOrSticker};

const BUTTON_HEIGHT: f64 = 30.0; // KEEP IN SYNC WITH BUTTON_HEIGHT BELOW
const MENU_WIDTH: f64 = 215.0; // KEEP IN SYNC WITH MENU_WIDTH BELOW
Expand Down Expand Up @@ -283,10 +284,10 @@ bitflags! {
}
}
impl MessageAbilities {
pub fn from_user_power_and_event(
pub fn from_user_power_and_event<T: MessageViewFromEvent, M: ContextMenuFromEvent>(
user_power_levels: &UserPowerLevels,
event_tl_item: &EventTimelineItem,
_message: &MessageOrSticker,
event_tl_item: &T,
_message: &MessageOrSticker<M>,
has_html: bool,
) -> Self {
let mut abilities = Self::empty();
Expand All @@ -305,7 +306,6 @@ impl MessageAbilities {
abilities.set(Self::HasHtml, has_html);
abilities
}

}

/// Details about the message that define its context menu content.
Expand Down Expand Up @@ -657,3 +657,10 @@ impl NewMessageContextMenuRef {
inner.show(cx, details)
}
}
/// A trait for event that can be used to show context menus.
pub trait ContextMenuFromEvent {
fn msgtype(&self) -> &MessageType;
fn body(&self) -> &str;
fn in_reply_to(&self) -> Option<&InReplyToDetails>;
fn is_searched_result(&self) -> bool;
}
21 changes: 12 additions & 9 deletions src/home/room_read_receipt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ use crate::utils::human_readable_list;
use indexmap::IndexMap;
use makepad_widgets::*;
use matrix_sdk::ruma::{events::receipt::Receipt, EventId, OwnedUserId, RoomId};
use matrix_sdk_ui::timeline::EventTimelineItem;
use std::cmp;

use super::room_screen::MessageViewFromEvent;


/// The maximum number of items to display in the read receipts AvatarRow
/// and its accompanying tooltip.
Expand Down Expand Up @@ -220,18 +221,20 @@ impl AvatarRowRef {
/// room ID, and an EventTimelineItem, this will populate the avatar
/// row of the item with the read receipts of the event.
///
pub fn populate_read_receipts(
pub fn populate_read_receipts<T: MessageViewFromEvent>(
item: &WidgetRef,
cx: &mut Cx,
room_id: &RoomId,
event_tl_item: &EventTimelineItem,
event_tl_item: &T,
) {
item.avatar_row(id!(avatar_row)).set_avatar_row(
cx,
room_id,
event_tl_item.event_id(),
event_tl_item.read_receipts(),
);
if let Some(read_receipts) = event_tl_item.read_receipts() {
item.avatar_row(id!(avatar_row)).set_avatar_row(
cx,
room_id,
event_tl_item.event_id(),
read_receipts,
);
}
}

/// Populate the tooltip text for a read receipts avatar row.
Expand Down
Loading
Loading