feat(inbox): automatically mark inbox items read when reading or viewing conversation
This commit is contained in:
parent
dcccc67d3e
commit
0de9c40337
6 changed files with 145 additions and 4 deletions
|
|
@ -1002,6 +1002,42 @@ public class EndToEndChatTests : IAsyncLifetime
|
|||
bobItems = stateBob.GetInboxItems();
|
||||
Assert.Contains(bobItems, x => x.Category == InboxCategories.FollowedChannel && x.ContentPreview.Contains("Regular update"));
|
||||
|
||||
// 4b. Bob looks at / joins #general -> all inbox items for #general are auto-marked read!
|
||||
await connBob.JoinChannelAsync(generalId);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
if (stateBob.UnreadInboxCount == 0) break;
|
||||
await Task.Delay(100);
|
||||
}
|
||||
Assert.Equal(0, stateBob.UnreadInboxCount);
|
||||
bobItems = stateBob.GetInboxItems();
|
||||
Assert.All(bobItems, item => Assert.True(item.IsRead));
|
||||
|
||||
// 4c. Alice sends DM to Bob while Bob is in #general -> Bob receives unread DM inbox item
|
||||
await connAlice.StartDmAsync(stateBob.CurrentUsername, stateBob.CurrentUserId);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
if (stateAlice.DirectMessages.Count > 0 && stateBob.DirectMessages.Count > 0) break;
|
||||
await Task.Delay(100);
|
||||
}
|
||||
string dmId = stateBob.DirectMessages[0].Id;
|
||||
await connAlice.SendChatMessageAsync(dmId, "Hey Bob, private message here!");
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
if (stateBob.UnreadInboxCount >= 1) break;
|
||||
await Task.Delay(100);
|
||||
}
|
||||
Assert.Equal(1, stateBob.UnreadInboxCount);
|
||||
|
||||
// When Bob opens/looks at the DM -> DM inbox item is marked read!
|
||||
await connBob.JoinChannelAsync(dmId);
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
if (stateBob.UnreadInboxCount == 0) break;
|
||||
await Task.Delay(100);
|
||||
}
|
||||
Assert.Equal(0, stateBob.UnreadInboxCount);
|
||||
|
||||
// 5. Bob marks all read and clears read items
|
||||
await connBob.SendInboxActionAsync("mark_all_read");
|
||||
for (int i = 0; i < 20; i++)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue