-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Do not count sent messages as unread in sidebar
- Loading branch information
Showing
3 changed files
with
151 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,6 +108,86 @@ async fn test_maintains_message_count_from_prior_runs() -> Result<()> { | |
Ok(()) | ||
} | ||
|
||
#[mt_test] | ||
async fn test_does_not_count_sent_messages_in_muc_as_unread() -> Result<()> { | ||
let client = TestClient::new().await; | ||
|
||
client | ||
.expect_login(user_id!("[email protected]"), "secret") | ||
.await?; | ||
|
||
let room_id = muc_id!("[email protected]"); | ||
let our_occupant_id = client.build_occupant_id(&room_id); | ||
|
||
client | ||
.join_room_with_strategy( | ||
room_id, | ||
"anon-id", | ||
JoinRoomStrategy::default().with_catch_up_handler(move |client, room_id| { | ||
client.expect_muc_catchup_with_config( | ||
room_id, | ||
client.time_provider.now() | ||
- Duration::seconds(client.app_config.max_catchup_duration_secs), | ||
vec![ | ||
MessageBuilder::new_with_index(1) | ||
.set_from(occupant_id!("[email protected]/friend")) | ||
.build_archived_message("", None), | ||
MessageBuilder::new_with_index(2) | ||
.set_from(our_occupant_id.clone()) | ||
.build_archived_message("", None), | ||
MessageBuilder::new_with_index(3) | ||
.set_from(occupant_id!("[email protected]/friend")) | ||
.build_archived_message("", None), | ||
], | ||
); | ||
}), | ||
) | ||
.await?; | ||
|
||
let sidebar_items = client.sidebar.sidebar_items().await; | ||
assert_eq!(1, sidebar_items.len()); | ||
assert_eq!(*&sidebar_items[0].unread_count, 2); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[mt_test] | ||
async fn test_does_not_count_sent_messages_in_dm_as_unread() -> Result<()> { | ||
let client = TestClient::new().await; | ||
|
||
client | ||
.expect_login(user_id!("[email protected]"), "secret") | ||
.await?; | ||
|
||
client | ||
.start_dm_with_strategy( | ||
user_id!("[email protected]"), | ||
StartDMStrategy::default().with_catch_up_handler(|client, user_id| { | ||
client.expect_catchup_with_config( | ||
user_id, | ||
vec![ | ||
MessageBuilder::new_with_index(1) | ||
.set_from(user_id!("[email protected]")) | ||
.build_archived_message("", None), | ||
MessageBuilder::new_with_index(2) | ||
.set_from(user_id!("[email protected]")) | ||
.build_archived_message("", None), | ||
MessageBuilder::new_with_index(3) | ||
.set_from(user_id!("[email protected]")) | ||
.build_archived_message("", None), | ||
], | ||
) | ||
}), | ||
) | ||
.await?; | ||
|
||
let sidebar_items = client.sidebar.sidebar_items().await; | ||
assert_eq!(1, sidebar_items.len()); | ||
assert_eq!(*&sidebar_items[0].unread_count, 2); | ||
|
||
Ok(()) | ||
} | ||
|
||
#[mt_test] | ||
async fn test_loads_unread_messages() -> Result<()> { | ||
let store = store().await.expect("Failed to set up store."); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters