Fix 'my threads' filtering to include participated threads (#7882)
* move js utils into directory Signed-off-by: Kerry Archibald <kerrya@element.io> * typescripterize js test-utils Signed-off-by: Kerry Archibald <kerrya@element.io> * move test utils to directory Signed-off-by: Kerry Archibald <kerrya@element.io> * move remaining mock functions to directory Signed-off-by: Kerry Archibald <kerrya@element.io> * update imports Signed-off-by: Kerry Archibald <kerrya@element.io> * missed copyright Signed-off-by: Kerry Archibald <kerrya@element.io> * threads test helpers Signed-off-by: Kerry Archibald <kerrya@element.io> * forgotten copyright Signed-off-by: Kerry Archibald <kerrya@element.io> * comments Signed-off-by: Kerry Archibald <kerrya@element.io> * fix threads helper unsigned Signed-off-by: Kerry Archibald <kerrya@element.io> * test filter creation when thread capabilities enabled Signed-off-by: Kerry Archibald <kerrya@element.io>
This commit is contained in:
parent
81cda7c749
commit
889b0cebb2
3 changed files with 135 additions and 14 deletions
|
@ -39,7 +39,7 @@ import { Layout } from '../../settings/enums/Layout';
|
|||
import { RoomPermalinkCreator } from '../../utils/permalinks/Permalinks';
|
||||
import Measured from '../views/elements/Measured';
|
||||
|
||||
async function getThreadTimelineSet(
|
||||
export async function getThreadTimelineSet(
|
||||
client: MatrixClient,
|
||||
room: Room,
|
||||
filterType = ThreadFilterType.All,
|
||||
|
@ -89,14 +89,12 @@ async function getThreadTimelineSet(
|
|||
Array.from(room.threads)
|
||||
.sort(([, threadA], [, threadB]) => threadA.replyToEvent.getTs() - threadB.replyToEvent.getTs())
|
||||
.forEach(([, thread]) => {
|
||||
const isOwnEvent = thread.rootEvent.getSender() === client.getUserId();
|
||||
if (filterType !== ThreadFilterType.My || isOwnEvent) {
|
||||
const currentUserParticipated = thread.events.some(event => event.getSender() === client.getUserId());
|
||||
if (filterType !== ThreadFilterType.My || currentUserParticipated) {
|
||||
timelineSet.getLiveTimeline().addEvent(thread.rootEvent, false);
|
||||
}
|
||||
});
|
||||
|
||||
// for (const [, thread] of room.threads) {
|
||||
// }
|
||||
return timelineSet;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue