Rewrite doesRoomOrThreadHaveUnreadMessages to use the receipt rewrite from js-sdk (#11903)
* Rewrite doesRoomOrThreadHaveUnreadMessages to use the receipt rewrite from js-sdk * Remove unit tests that rely on receipt timestamps Previously, if we found a receipt for an unknown event, we would use the receipt timestamp and declare all events before that time to be read. Now, we ignore such "dangling" receipts until we find the event they refer to. This new behaviour is more correct, but does lead to more messages being considered unread. This commit deletes tests that checked for the old behaviour. * Check for a missing thread in determineUnreadState * Fix incorrect way to find room timeline * More realistic test setup to support new receipt code * Update snapshot to expect a room to be unread when there are no receipts * Formatting fixes * Update snapshot to show menu and notif button * Disable some flaky tests * Disable some flaky tests * Fix test to make a threaded receipt for an event that is actually in the thread --------- Co-authored-by: Florian Duros <florianduros@element.io> Co-authored-by: Florian Duros <florian.duros@ormaz.fr>
This commit is contained in:
parent
e207798a8f
commit
8b7f49e74e
11 changed files with 230 additions and 234 deletions
|
@ -111,6 +111,13 @@ type MakeThreadProps = {
|
|||
ts?: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a thread but don't actually populate it with events - see
|
||||
* populateThread for what you probably want to do.
|
||||
*
|
||||
* Leaving this here in case it is needed by some people, but I (andyb) would
|
||||
* expect us to move to use populateThread exclusively.
|
||||
*/
|
||||
export const mkThread = ({
|
||||
room,
|
||||
client,
|
||||
|
@ -135,8 +142,29 @@ export const mkThread = ({
|
|||
|
||||
const thread = room.createThread(rootEvent.getId()!, rootEvent, events, true);
|
||||
|
||||
// So that we do not have to mock the thread loading
|
||||
thread.initialEventsFetched = true;
|
||||
|
||||
return { thread, rootEvent, events };
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a thread, and make sure the events added to the thread and the room's
|
||||
* timeline as if they came in via sync.
|
||||
*
|
||||
* Note that mkThread doesn't actually add the events properly to the room.
|
||||
*/
|
||||
export const populateThread = async ({
|
||||
room,
|
||||
client,
|
||||
authorId,
|
||||
participantUserIds,
|
||||
length = 2,
|
||||
ts = 1,
|
||||
}: MakeThreadProps): Promise<{ thread: Thread; rootEvent: MatrixEvent; events: MatrixEvent[] }> => {
|
||||
const ret = mkThread({ room, client, authorId, participantUserIds, length, ts });
|
||||
|
||||
// So that we do not have to mock the thread loading, tell the thread
|
||||
// that it is already loaded, and send the events again to the room
|
||||
// so they are added to the thread timeline.
|
||||
ret.thread.initialEventsFetched = true;
|
||||
await room.addLiveEvents(ret.events);
|
||||
return ret;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue