mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-19 21:29:52 -07:00
Support hiding server part of username in message scrollback (#71)
This commit is contained in:
parent
61aba80be1
commit
64891ec68f
8 changed files with 164 additions and 37 deletions
|
@ -40,6 +40,7 @@ use matrix_sdk::{
|
|||
reaction::ReactionEventContent,
|
||||
room::{
|
||||
encryption::RoomEncryptionEventContent,
|
||||
member::OriginalSyncRoomMemberEvent,
|
||||
message::{MessageType, RoomMessageEventContent},
|
||||
name::RoomNameEventContent,
|
||||
redaction::{OriginalSyncRoomRedactionEvent, SyncRoomRedactionEvent},
|
||||
|
@ -838,6 +839,38 @@ impl ClientWorker {
|
|||
},
|
||||
);
|
||||
|
||||
let _ = self.client.add_event_handler(
|
||||
|ev: OriginalSyncRoomMemberEvent,
|
||||
room: MatrixRoom,
|
||||
client: Client,
|
||||
store: Ctx<AsyncProgramStore>| {
|
||||
async move {
|
||||
let room_id = room.room_id();
|
||||
let user_id = ev.state_key;
|
||||
|
||||
let ambiguous_name =
|
||||
ev.content.displayname.as_deref().unwrap_or_else(|| user_id.localpart());
|
||||
let ambiguous = client
|
||||
.store()
|
||||
.get_users_with_display_name(room_id, ambiguous_name)
|
||||
.await
|
||||
.map(|users| users.len() > 1)
|
||||
.unwrap_or_default();
|
||||
|
||||
let mut locked = store.lock().await;
|
||||
let info = locked.application.get_room_info(room_id.to_owned());
|
||||
|
||||
if ambiguous {
|
||||
info.display_names.remove(&user_id);
|
||||
} else if let Some(display) = ev.content.displayname {
|
||||
info.display_names.insert(user_id, display);
|
||||
} else {
|
||||
info.display_names.remove(&user_id);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
let _ = self.client.add_event_handler(
|
||||
|ev: OriginalSyncKeyVerificationStartEvent,
|
||||
client: Client,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue