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:
Kerry 2022-02-24 09:44:34 +01:00 committed by GitHub
parent 81cda7c749
commit 889b0cebb2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 135 additions and 14 deletions

View file

@ -1,4 +1,3 @@
/*
Copyright 2022 The Matrix.org Foundation C.I.C.
@ -15,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { IUnsigned, MatrixClient, MatrixEvent, Room } from "matrix-js-sdk";
import { MatrixClient, MatrixEvent, RelationType, Room } from "matrix-js-sdk";
import { Thread } from "matrix-js-sdk/src/models/thread";
import { mkMessage, MessageEventProps } from "./test-utils";
@ -26,7 +25,7 @@ export const makeThreadEvent = ({ rootEventId, replyToEventId, ...props }: Messa
...props,
relatesTo: {
event_id: rootEventId,
rel_type: "io.element.thread",
rel_type: RelationType.Thread,
['m.in_reply_to']: {
event_id: replyToEventId,
},
@ -50,12 +49,12 @@ type MakeThreadEventsProps = {
export const makeThreadEvents = ({
roomId, authorId, participantUserIds, length = 2, ts = 1, currentUserId,
}): { rootEvent: MatrixEvent, events: MatrixEvent[] } => {
}: MakeThreadEventsProps): { rootEvent: MatrixEvent, events: MatrixEvent[] } => {
const rootEvent = mkMessage({
user: authorId,
event: true,
room: roomId,
msg: 'root event message',
msg: 'root event message ' + Math.random(),
ts,
});
@ -79,10 +78,14 @@ export const makeThreadEvents = ({
}
rootEvent.setUnsigned({
latest_event: events[events.length - 1],
count: length,
current_user_participated: [...participantUserIds, authorId].includes(currentUserId),
} as IUnsigned);
"m.relations": {
[RelationType.Thread]: {
latest_event: events[events.length - 1],
count: length,
current_user_participated: [...participantUserIds, authorId].includes(currentUserId),
},
},
});
return { rootEvent, events };
};