Show mentioned badges & enable scrolling to mentions in conversations
This commit is contained in:
parent
caaeda8abe
commit
d012779e87
21 changed files with 694 additions and 184 deletions
|
@ -17,6 +17,8 @@ const {
|
|||
getMessageMetricsForConversation,
|
||||
getNewerMessagesByConversation,
|
||||
getOlderMessagesByConversation,
|
||||
getTotalUnreadMentionsOfMeForConversation,
|
||||
getOldestUnreadMentionOfMeForConversation,
|
||||
} = dataInterface;
|
||||
|
||||
function getUuid(): UUIDStringType {
|
||||
|
@ -824,4 +826,72 @@ describe('sql/timelineFetches', () => {
|
|||
assert.strictEqual(metricsInStory?.totalUnseen, 1, 'totalUnseen');
|
||||
});
|
||||
});
|
||||
|
||||
describe('mentionsCount & oldestUnreadMention', () => {
|
||||
it('returns unread mentions count and oldest unread mention', async () => {
|
||||
assert.lengthOf(await _getAllMessages(), 0);
|
||||
|
||||
const target = Date.now();
|
||||
const conversationId = getUuid();
|
||||
const ourUuid = getUuid();
|
||||
|
||||
const readMentionsMe: Partial<MessageAttributesType> = {
|
||||
id: 'readMentionsMe',
|
||||
readStatus: ReadStatus.Read,
|
||||
mentionsMe: true,
|
||||
};
|
||||
const unreadMentionsMe: Partial<MessageAttributesType> = {
|
||||
id: 'unreadMentionsMe',
|
||||
readStatus: ReadStatus.Unread,
|
||||
mentionsMe: true,
|
||||
};
|
||||
const unreadNoMention: Partial<MessageAttributesType> = {
|
||||
id: 'unreadNoMention',
|
||||
readStatus: ReadStatus.Unread,
|
||||
};
|
||||
const unreadMentionsMeAgain: Partial<MessageAttributesType> = {
|
||||
id: 'unreadMentionsMeAgain',
|
||||
readStatus: ReadStatus.Unread,
|
||||
mentionsMe: true,
|
||||
};
|
||||
|
||||
const messages = [
|
||||
readMentionsMe,
|
||||
unreadMentionsMe,
|
||||
unreadNoMention,
|
||||
unreadMentionsMeAgain,
|
||||
];
|
||||
|
||||
const formattedMessages = messages.map<MessageAttributesType>(
|
||||
(message, idx) => {
|
||||
return {
|
||||
id: getUuid(),
|
||||
body: 'body',
|
||||
type: 'incoming',
|
||||
sent_at: target - messages.length + idx,
|
||||
received_at: target - messages.length + idx,
|
||||
timestamp: target - messages.length + idx,
|
||||
conversationId,
|
||||
...message,
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
await saveMessages(formattedMessages, { forceSave: true, ourUuid });
|
||||
|
||||
assert.lengthOf(await _getAllMessages(), 4);
|
||||
|
||||
const unreadMentions = await getTotalUnreadMentionsOfMeForConversation(
|
||||
conversationId,
|
||||
{ includeStoryReplies: false }
|
||||
);
|
||||
const oldestUnreadMention =
|
||||
await getOldestUnreadMentionOfMeForConversation(conversationId, {
|
||||
includeStoryReplies: false,
|
||||
});
|
||||
|
||||
assert.strictEqual(unreadMentions, 2);
|
||||
assert.strictEqual(oldestUnreadMention?.id, 'unreadMentionsMe');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue