Switch to using stable values for threads (#8019)

This commit is contained in:
Germain 2022-03-11 09:04:22 +00:00 committed by GitHub
parent d38a1fa201
commit 21d3cb08a9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 49 additions and 47 deletions

View file

@ -19,12 +19,13 @@ limitations under the License.
import React from "react"; import React from "react";
import { MatrixClient } from "matrix-js-sdk/src/client"; import { MatrixClient } from "matrix-js-sdk/src/client";
import { IUploadOpts } from "matrix-js-sdk/src/@types/requests"; import { IUploadOpts } from "matrix-js-sdk/src/@types/requests";
import { MsgType, RelationType } from "matrix-js-sdk/src/@types/event"; import { MsgType } from "matrix-js-sdk/src/@types/event";
import encrypt from "browser-encrypt-attachment"; import encrypt from "browser-encrypt-attachment";
import extractPngChunks from "png-chunks-extract"; import extractPngChunks from "png-chunks-extract";
import { IAbortablePromise, IImageInfo } from "matrix-js-sdk/src/@types/partials"; import { IAbortablePromise, IImageInfo } from "matrix-js-sdk/src/@types/partials";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { IEventRelation, ISendEventResponse } from "matrix-js-sdk/src/matrix"; import { IEventRelation, ISendEventResponse } from "matrix-js-sdk/src/matrix";
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread";
import { IEncryptedFile, IMediaEventInfo } from "./customisations/models/IMediaEventContent"; import { IEncryptedFile, IMediaEventInfo } from "./customisations/models/IMediaEventContent";
import dis from './dispatcher/dispatcher'; import dis from './dispatcher/dispatcher';
@ -658,7 +659,7 @@ export default class ContentMessages {
return promBefore; return promBefore;
}).then(function() { }).then(function() {
if (upload.canceled) throw new UploadCanceledError(); if (upload.canceled) throw new UploadCanceledError();
const threadId = relation?.rel_type === RelationType.Thread const threadId = relation?.rel_type === THREAD_RELATION_TYPE.name
? relation.event_id ? relation.event_id
: null; : null;
const prom = matrixClient.sendMessage(roomId, threadId, content); const prom = matrixClient.sendMessage(roomId, threadId, content);

View file

@ -17,15 +17,18 @@ limitations under the License.
import React, { useContext, useEffect, useRef, useState } from 'react'; import React, { useContext, useEffect, useRef, useState } from 'react';
import { EventTimelineSet } from 'matrix-js-sdk/src/models/event-timeline-set'; import { EventTimelineSet } from 'matrix-js-sdk/src/models/event-timeline-set';
import { Room } from 'matrix-js-sdk/src/models/room'; import { Room } from 'matrix-js-sdk/src/models/room';
import { RelationType } from 'matrix-js-sdk/src/@types/event';
import { MatrixClient } from 'matrix-js-sdk/src/client'; import { MatrixClient } from 'matrix-js-sdk/src/client';
import { import {
Filter, Filter,
IFilterDefinition, IFilterDefinition,
UNSTABLE_FILTER_RELATED_BY_SENDERS,
UNSTABLE_FILTER_RELATED_BY_REL_TYPES,
} from 'matrix-js-sdk/src/filter'; } from 'matrix-js-sdk/src/filter';
import { Thread, ThreadEvent } from 'matrix-js-sdk/src/models/thread'; import {
FILTER_RELATED_BY_REL_TYPES,
FILTER_RELATED_BY_SENDERS,
Thread,
ThreadEvent,
THREAD_RELATION_TYPE,
} from 'matrix-js-sdk/src/models/thread';
import { EventTimeline } from 'matrix-js-sdk/src/models/event-timeline'; import { EventTimeline } from 'matrix-js-sdk/src/models/event-timeline';
import BaseCard from "../views/right_panel/BaseCard"; import BaseCard from "../views/right_panel/BaseCard";
@ -54,13 +57,13 @@ export async function getThreadTimelineSet(
const definition: IFilterDefinition = { const definition: IFilterDefinition = {
"room": { "room": {
"timeline": { "timeline": {
[UNSTABLE_FILTER_RELATED_BY_REL_TYPES.name]: [RelationType.Thread], [FILTER_RELATED_BY_REL_TYPES.name]: [THREAD_RELATION_TYPE.name],
}, },
}, },
}; };
if (filterType === ThreadFilterType.My) { if (filterType === ThreadFilterType.My) {
definition.room.timeline[UNSTABLE_FILTER_RELATED_BY_SENDERS.name] = [myUserId]; definition.room.timeline[FILTER_RELATED_BY_SENDERS.name] = [myUserId];
} }
filter.setDefinition(definition); filter.setDefinition(definition);

View file

@ -15,8 +15,7 @@ limitations under the License.
*/ */
import React, { createRef, KeyboardEvent } from 'react'; import React, { createRef, KeyboardEvent } from 'react';
import { Thread, ThreadEvent } from 'matrix-js-sdk/src/models/thread'; import { Thread, ThreadEvent, THREAD_RELATION_TYPE } from 'matrix-js-sdk/src/models/thread';
import { RelationType } from 'matrix-js-sdk/src/@types/event';
import { Room } from 'matrix-js-sdk/src/models/room'; import { Room } from 'matrix-js-sdk/src/models/room';
import { IEventRelation, MatrixEvent } from 'matrix-js-sdk/src/models/event'; import { IEventRelation, MatrixEvent } from 'matrix-js-sdk/src/models/event';
import { TimelineWindow } from 'matrix-js-sdk/src/timeline-window'; import { TimelineWindow } from 'matrix-js-sdk/src/timeline-window';
@ -181,7 +180,7 @@ export default class ThreadView extends React.Component<IProps, IState> {
this.setState({ this.setState({
thread, thread,
lastThreadReply: thread.lastReply((ev: MatrixEvent) => { lastThreadReply: thread.lastReply((ev: MatrixEvent) => {
return ev.isRelation(RelationType.Thread) && !ev.status; return ev.isRelation(THREAD_RELATION_TYPE.name) && !ev.status;
}), }),
}, async () => { }, async () => {
thread.emit(ThreadEvent.ViewThread); thread.emit(ThreadEvent.ViewThread);
@ -201,7 +200,7 @@ export default class ThreadView extends React.Component<IProps, IState> {
if (this.state.thread) { if (this.state.thread) {
this.setState({ this.setState({
lastThreadReply: this.state.thread.lastReply((ev: MatrixEvent) => { lastThreadReply: this.state.thread.lastReply((ev: MatrixEvent) => {
return ev.isRelation(RelationType.Thread) && !ev.status; return ev.isRelation(THREAD_RELATION_TYPE.name) && !ev.status;
}), }),
}); });
} }
@ -288,7 +287,7 @@ export default class ThreadView extends React.Component<IProps, IState> {
private get threadRelation(): IEventRelation { private get threadRelation(): IEventRelation {
return { return {
"rel_type": RelationType.Thread, "rel_type": THREAD_RELATION_TYPE.name,
"event_id": this.state.thread?.id, "event_id": this.state.thread?.id,
"m.in_reply_to": { "m.in_reply_to": {
"event_id": this.state.lastThreadReply?.getId() ?? this.state.thread?.id, "event_id": this.state.lastThreadReply?.getId() ?? this.state.thread?.id,

View file

@ -14,12 +14,12 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { RelationType } from "matrix-js-sdk/src/@types/event";
import { MatrixClient } from "matrix-js-sdk/src/client"; import { MatrixClient } from "matrix-js-sdk/src/client";
import { makeLocationContent } from "matrix-js-sdk/src/content-helpers"; import { makeLocationContent } from "matrix-js-sdk/src/content-helpers";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { IEventRelation } from "matrix-js-sdk/src/models/event"; import { IEventRelation } from "matrix-js-sdk/src/models/event";
import { LocationAssetType } from "matrix-js-sdk/src/@types/location"; import { LocationAssetType } from "matrix-js-sdk/src/@types/location";
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread";
import { _t } from "../../../languageHandler"; import { _t } from "../../../languageHandler";
import Modal from "../../../Modal"; import Modal from "../../../Modal";
@ -41,7 +41,7 @@ export const shareLocation = (
) => async (uri: string, ts: number) => { ) => async (uri: string, ts: number) => {
if (!uri) return false; if (!uri) return false;
try { try {
const threadId = relation?.rel_type === RelationType.Thread ? relation.event_id : null; const threadId = relation?.rel_type === THREAD_RELATION_TYPE.name ? relation.event_id : null;
const assetType = shareType === LocationShareType.Pin ? LocationAssetType.Pin : LocationAssetType.Self; const assetType = shareType === LocationShareType.Pin ? LocationAssetType.Pin : LocationAssetType.Self;
await client.sendMessage(roomId, threadId, makeLocationContent(undefined, uri, ts, undefined, assetType)); await client.sendMessage(roomId, threadId, makeLocationContent(undefined, uri, ts, undefined, assetType));
} catch (e) { } catch (e) {

View file

@ -19,8 +19,9 @@ import classNames from 'classnames';
import { IEventRelation, MatrixEvent } from "matrix-js-sdk/src/models/event"; import { IEventRelation, MatrixEvent } from "matrix-js-sdk/src/models/event";
import { Room } from "matrix-js-sdk/src/models/room"; import { Room } from "matrix-js-sdk/src/models/room";
import { RoomMember } from "matrix-js-sdk/src/models/room-member"; import { RoomMember } from "matrix-js-sdk/src/models/room-member";
import { EventType, RelationType } from 'matrix-js-sdk/src/@types/event'; import { EventType } from 'matrix-js-sdk/src/@types/event';
import { Optional } from "matrix-events-sdk"; import { Optional } from "matrix-events-sdk";
import { THREAD_RELATION_TYPE } from 'matrix-js-sdk/src/models/thread';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import { MatrixClientPeg } from '../../../MatrixClientPeg'; import { MatrixClientPeg } from '../../../MatrixClientPeg';
@ -258,7 +259,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
private renderPlaceholderText = () => { private renderPlaceholderText = () => {
if (this.props.replyToEvent) { if (this.props.replyToEvent) {
const replyingToThread = this.props.relation?.rel_type === RelationType.Thread; const replyingToThread = this.props.relation?.rel_type === THREAD_RELATION_TYPE.name;
if (replyingToThread && this.props.e2eStatus) { if (replyingToThread && this.props.e2eStatus) {
return _t('Reply to encrypted thread…'); return _t('Reply to encrypted thread…');
} else if (replyingToThread) { } else if (replyingToThread) {
@ -426,7 +427,7 @@ export default class MessageComposer extends React.Component<IProps, IState> {
/>; />;
} }
const threadId = this.props.relation?.rel_type === RelationType.Thread const threadId = this.props.relation?.rel_type === THREAD_RELATION_TYPE.name
? this.props.relation.event_id ? this.props.relation.event_id
: null; : null;

View file

@ -20,7 +20,7 @@ import { M_POLL_START } from "matrix-events-sdk";
import React, { createContext, ReactElement, useContext, useRef } from 'react'; import React, { createContext, ReactElement, useContext, useRef } from 'react';
import { Room } from 'matrix-js-sdk/src/models/room'; import { Room } from 'matrix-js-sdk/src/models/room';
import { MatrixClient } from 'matrix-js-sdk/src/client'; import { MatrixClient } from 'matrix-js-sdk/src/client';
import { RelationType } from 'matrix-js-sdk/src/@types/event'; import { THREAD_RELATION_TYPE } from 'matrix-js-sdk/src/models/thread';
import { _t } from '../../../languageHandler'; import { _t } from '../../../languageHandler';
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton"; import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
@ -318,7 +318,7 @@ class PollButton extends React.PureComponent<IPollButtonProps> {
}, },
); );
} else { } else {
const threadId = this.props.relation?.rel_type === RelationType.Thread const threadId = this.props.relation?.rel_type === THREAD_RELATION_TYPE.name
? this.props.relation.event_id ? this.props.relation.event_id
: null; : null;
@ -339,7 +339,7 @@ class PollButton extends React.PureComponent<IPollButtonProps> {
public render() { public render() {
// do not allow sending polls within threads at this time // do not allow sending polls within threads at this time
if (this.props.relation?.rel_type === RelationType.Thread) return null; if (this.props.relation?.rel_type === THREAD_RELATION_TYPE.name) return null;
return ( return (
<CollapsibleButton <CollapsibleButton

View file

@ -22,6 +22,7 @@ import { EventType, RelationType } from "matrix-js-sdk/src/@types/event";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { Room } from 'matrix-js-sdk/src/models/room'; import { Room } from 'matrix-js-sdk/src/models/room';
import { Composer as ComposerEvent } from "matrix-analytics-events/types/typescript/Composer"; import { Composer as ComposerEvent } from "matrix-analytics-events/types/typescript/Composer";
import { THREAD_RELATION_TYPE } from 'matrix-js-sdk/src/models/thread';
import dis from '../../../dispatcher/dispatcher'; import dis from '../../../dispatcher/dispatcher';
import EditorModel from '../../../editor/model'; import EditorModel from '../../../editor/model';
@ -132,7 +133,7 @@ export function createMessageContent(
addReplyToMessageContent(content, replyToEvent, { addReplyToMessageContent(content, replyToEvent, {
permalinkCreator, permalinkCreator,
includeLegacyFallback: includeReplyLegacyFallback, includeLegacyFallback: includeReplyLegacyFallback,
inThread: relation?.rel_type === RelationType.Thread, inThread: relation?.rel_type === THREAD_RELATION_TYPE.name,
}); });
} }
@ -204,7 +205,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
} }
public componentDidUpdate(prevProps: ISendMessageComposerProps): void { public componentDidUpdate(prevProps: ISendMessageComposerProps): void {
const replyingToThread = this.props.relation?.key === RelationType.Thread; const replyingToThread = this.props.relation?.key === THREAD_RELATION_TYPE.name;
const differentEventTarget = this.props.relation?.event_id !== prevProps.relation?.event_id; const differentEventTarget = this.props.relation?.event_id !== prevProps.relation?.event_id;
const threadChanged = replyingToThread && (differentEventTarget); const threadChanged = replyingToThread && (differentEventTarget);
@ -221,7 +222,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
if (this.editorRef.current?.isComposing(event)) { if (this.editorRef.current?.isComposing(event)) {
return; return;
} }
const replyingToThread = this.props.relation?.key === RelationType.Thread; const replyingToThread = this.props.relation?.key === THREAD_RELATION_TYPE.name;
const action = getKeyBindingsManager().getMessageComposerAction(event); const action = getKeyBindingsManager().getMessageComposerAction(event);
switch (action) { switch (action) {
case KeyBindingAction.SendMessage: case KeyBindingAction.SendMessage:
@ -358,7 +359,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
eventName: "Composer", eventName: "Composer",
isEditing: false, isEditing: false,
isReply: !!this.props.replyToEvent, isReply: !!this.props.replyToEvent,
inThread: this.props.relation?.rel_type === RelationType.Thread, inThread: this.props.relation?.rel_type === THREAD_RELATION_TYPE.name,
}; };
if (posthogEvent.inThread) { if (posthogEvent.inThread) {
const threadRoot = this.props.room.findEventById(this.props.relation.event_id); const threadRoot = this.props.room.findEventById(this.props.relation.event_id);
@ -383,7 +384,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
if (!containsEmote(model) && isSlashCommand(this.model)) { if (!containsEmote(model) && isSlashCommand(this.model)) {
const [cmd, args, commandText] = getSlashCommand(this.model); const [cmd, args, commandText] = getSlashCommand(this.model);
if (cmd) { if (cmd) {
const threadId = this.props.relation?.rel_type === RelationType.Thread const threadId = this.props.relation?.rel_type === THREAD_RELATION_TYPE.name
? this.props.relation?.event_id ? this.props.relation?.event_id
: null; : null;
@ -398,7 +399,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
addReplyToMessageContent(content, replyToEvent, { addReplyToMessageContent(content, replyToEvent, {
permalinkCreator: this.props.permalinkCreator, permalinkCreator: this.props.permalinkCreator,
includeLegacyFallback: true, includeLegacyFallback: true,
inThread: this.props.relation?.rel_type === RelationType.Thread, inThread: this.props.relation?.rel_type === THREAD_RELATION_TYPE.name,
}); });
} }
} else { } else {
@ -434,7 +435,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
decorateStartSendingTime(content); decorateStartSendingTime(content);
} }
const threadId = this.props.relation?.rel_type === RelationType.Thread const threadId = this.props.relation?.rel_type === THREAD_RELATION_TYPE.name
? this.props.relation.event_id ? this.props.relation.event_id
: null; : null;
@ -453,7 +454,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
if (containsEmoji(content, effect.emojis)) { if (containsEmoji(content, effect.emojis)) {
// For initial threads launch, chat effects are disabled // For initial threads launch, chat effects are disabled
// see #19731 // see #19731
const isNotThread = this.props.relation?.rel_type !== RelationType.Thread; const isNotThread = this.props.relation?.rel_type !== THREAD_RELATION_TYPE.name;
if (!SettingsStore.getValue("feature_thread") || isNotThread) { if (!SettingsStore.getValue("feature_thread") || isNotThread) {
dis.dispatch({ action: `effects.${effect.command}` }); dis.dispatch({ action: `effects.${effect.command}` });
} }
@ -497,7 +498,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
private get editorStateKey() { private get editorStateKey() {
let key = `mx_cider_state_${this.props.room.roomId}`; let key = `mx_cider_state_${this.props.room.roomId}`;
if (this.props.relation?.rel_type === RelationType.Thread) { if (this.props.relation?.rel_type === THREAD_RELATION_TYPE.name) {
key += `_${this.props.relation.event_id}`; key += `_${this.props.relation.event_id}`;
} }
return key; return key;
@ -508,7 +509,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
} }
private restoreStoredEditorState(partCreator: PartCreator): Part[] { private restoreStoredEditorState(partCreator: PartCreator): Part[] {
const replyingToThread = this.props.relation?.key === RelationType.Thread; const replyingToThread = this.props.relation?.key === THREAD_RELATION_TYPE.name;
if (replyingToThread) { if (replyingToThread) {
return null; return null;
} }
@ -600,7 +601,7 @@ export class SendMessageComposer extends React.Component<ISendMessageComposerPro
}; };
render() { render() {
const threadId = this.props.relation?.rel_type === RelationType.Thread const threadId = this.props.relation?.rel_type === THREAD_RELATION_TYPE.name
? this.props.relation.event_id ? this.props.relation.event_id
: null; : null;
return ( return (

View file

@ -29,10 +29,11 @@ import {
WidgetEventCapability, WidgetEventCapability,
WidgetKind, WidgetKind,
} from "matrix-widget-api"; } from "matrix-widget-api";
import { EventType, RelationType } from "matrix-js-sdk/src/@types/event"; import { EventType } from "matrix-js-sdk/src/@types/event";
import { IContent, IEvent, MatrixEvent } from "matrix-js-sdk/src/models/event"; import { IContent, IEvent, MatrixEvent } from "matrix-js-sdk/src/models/event";
import { Room } from "matrix-js-sdk/src/models/room"; import { Room } from "matrix-js-sdk/src/models/room";
import { logger } from "matrix-js-sdk/src/logger"; import { logger } from "matrix-js-sdk/src/logger";
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread";
import { iterableDiff, iterableIntersection } from "../../utils/iterables"; import { iterableDiff, iterableIntersection } from "../../utils/iterables";
import { MatrixClientPeg } from "../../MatrixClientPeg"; import { MatrixClientPeg } from "../../MatrixClientPeg";
@ -169,7 +170,7 @@ export class StopGapWidgetDriver extends WidgetDriver {
if (containsEmoji(content, effect.emojis)) { if (containsEmoji(content, effect.emojis)) {
// For initial threads launch, chat effects are disabled // For initial threads launch, chat effects are disabled
// see #19731 // see #19731
const isNotThread = content["m.relates_to"].rel_type !== RelationType.Thread; const isNotThread = content["m.relates_to"].rel_type !== THREAD_RELATION_TYPE.name;
if (!SettingsStore.getValue("feature_thread") || isNotThread) { if (!SettingsStore.getValue("feature_thread") || isNotThread) {
dis.dispatch({ action: `effects.${effect.command}` }); dis.dispatch({ action: `effects.${effect.command}` });
} }

View file

@ -15,9 +15,9 @@ limitations under the License.
*/ */
import { IContent, MatrixEvent } from "matrix-js-sdk/src/models/event"; import { IContent, MatrixEvent } from "matrix-js-sdk/src/models/event";
import { RelationType } from "matrix-js-sdk/src/@types/event";
import sanitizeHtml from "sanitize-html"; import sanitizeHtml from "sanitize-html";
import escapeHtml from "escape-html"; import escapeHtml from "escape-html";
import { THREAD_RELATION_TYPE } from "matrix-js-sdk/src/models/thread";
import { PERMITTED_URL_SCHEMES } from "../HtmlUtils"; import { PERMITTED_URL_SCHEMES } from "../HtmlUtils";
import { makeUserPermalink, RoomPermalinkCreator } from "./permalinks/Permalinks"; import { makeUserPermalink, RoomPermalinkCreator } from "./permalinks/Permalinks";
@ -163,7 +163,7 @@ export function makeReplyMixIn(ev?: MatrixEvent, inThread = false): RecursivePar
if (ev.isThreadRelation) { if (ev.isThreadRelation) {
mixin['m.relates_to'] = { mixin['m.relates_to'] = {
...mixin['m.relates_to'], ...mixin['m.relates_to'],
rel_type: RelationType.Thread, rel_type: THREAD_RELATION_TYPE.name,
event_id: ev.threadRootId, event_id: ev.threadRootId,
}; };
} }

View file

@ -18,10 +18,7 @@ import React from 'react';
import { shallow, mount } from "enzyme"; import { shallow, mount } from "enzyme";
import { import {
MatrixClient, MatrixClient,
RelationType,
Room, Room,
UNSTABLE_FILTER_RELATED_BY_REL_TYPES,
UNSTABLE_FILTER_RELATED_BY_SENDERS,
} from 'matrix-js-sdk/src/matrix'; } from 'matrix-js-sdk/src/matrix';
import { mocked } from 'jest-mock'; import { mocked } from 'jest-mock';
import '../../skinned-sdk'; import '../../skinned-sdk';
@ -179,7 +176,7 @@ describe('ThreadPanel', () => {
const [filterKey, filter] = mocked(client).getOrCreateFilter.mock.calls[0]; const [filterKey, filter] = mocked(client).getOrCreateFilter.mock.calls[0];
expect(filterKey).toEqual(`THREAD_PANEL_${room.roomId}_${ThreadFilterType.All}`); expect(filterKey).toEqual(`THREAD_PANEL_${room.roomId}_${ThreadFilterType.All}`);
expect(filter.getDefinition().room.timeline).toEqual({ expect(filter.getDefinition().room.timeline).toEqual({
[UNSTABLE_FILTER_RELATED_BY_REL_TYPES.name]: [RelationType.Thread], related_by_rel_types: ["m.thread"],
}); });
}); });
@ -189,8 +186,8 @@ describe('ThreadPanel', () => {
const [filterKey, filter] = mocked(client).getOrCreateFilter.mock.calls[0]; const [filterKey, filter] = mocked(client).getOrCreateFilter.mock.calls[0];
expect(filterKey).toEqual(`THREAD_PANEL_${room.roomId}_${ThreadFilterType.My}`); expect(filterKey).toEqual(`THREAD_PANEL_${room.roomId}_${ThreadFilterType.My}`);
expect(filter.getDefinition().room.timeline).toEqual({ expect(filter.getDefinition().room.timeline).toEqual({
[UNSTABLE_FILTER_RELATED_BY_REL_TYPES.name]: [RelationType.Thread], related_by_rel_types: ["m.thread"],
[UNSTABLE_FILTER_RELATED_BY_SENDERS.name]: [aliceId], related_by_senders: [aliceId],
}); });
}); });
}); });

View file

@ -18,7 +18,6 @@ import React from "react";
import { act } from "react-dom/test-utils"; import { act } from "react-dom/test-utils";
import { sleep } from "matrix-js-sdk/src/utils"; import { sleep } from "matrix-js-sdk/src/utils";
import { mount } from 'enzyme'; import { mount } from 'enzyme';
import { RelationType } from 'matrix-js-sdk/src/@types/event';
import '../../../skinned-sdk'; // Must be first for skinning to work import '../../../skinned-sdk'; // Must be first for skinning to work
import SendMessageComposer, { import SendMessageComposer, {
@ -298,7 +297,7 @@ describe('<SendMessageComposer/>', () => {
placeholder="" placeholder=""
permalinkCreator={new MatrixToPermalinkConstructor() as any} permalinkCreator={new MatrixToPermalinkConstructor() as any}
relation={{ relation={{
rel_type: RelationType.Thread, rel_type: "m.thread",
event_id: "myFakeThreadId", event_id: "myFakeThreadId",
}} }}
includeReplyLegacyFallback={false} includeReplyLegacyFallback={false}

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
import { MatrixClient, MatrixEvent, RelationType, Room } from "matrix-js-sdk/src/matrix"; import { MatrixClient, MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
import { Thread } from "matrix-js-sdk/src/models/thread"; import { Thread } from "matrix-js-sdk/src/models/thread";
import { mkMessage, MessageEventProps } from "./test-utils"; import { mkMessage, MessageEventProps } from "./test-utils";
@ -25,7 +25,7 @@ export const makeThreadEvent = ({ rootEventId, replyToEventId, ...props }: Messa
...props, ...props,
relatesTo: { relatesTo: {
event_id: rootEventId, event_id: rootEventId,
rel_type: RelationType.Thread, rel_type: "m.thread",
['m.in_reply_to']: { ['m.in_reply_to']: {
event_id: replyToEventId, event_id: replyToEventId,
}, },
@ -79,7 +79,7 @@ export const makeThreadEvents = ({
rootEvent.setUnsigned({ rootEvent.setUnsigned({
"m.relations": { "m.relations": {
[RelationType.Thread]: { "m.thread": {
latest_event: events[events.length - 1], latest_event: events[events.length - 1],
count: length, count: length,
current_user_participated: [...participantUserIds, authorId].includes(currentUserId), current_user_participated: [...participantUserIds, authorId].includes(currentUserId),