diff --git a/spec/unit/content-helpers.spec.ts b/spec/unit/content-helpers.spec.ts index 1993b832ca..911cd69e34 100644 --- a/spec/unit/content-helpers.spec.ts +++ b/spec/unit/content-helpers.spec.ts @@ -211,13 +211,11 @@ describe("Topic content helpers", () => { it("creates an empty event when the topic is falsey", () => { expect(makeTopicContent(undefined)).toEqual({ topic: undefined, - [M_TOPIC.name]: [ - ], + [M_TOPIC.name]: [], }); expect(makeTopicContent(null)).toEqual({ topic: null, - [M_TOPIC.name]: [ - ], + [M_TOPIC.name]: [], }); }); }); diff --git a/src/@types/state_events.ts b/src/@types/state_events.ts index d570c5a129..a580c41c43 100644 --- a/src/@types/state_events.ts +++ b/src/@types/state_events.ts @@ -90,7 +90,7 @@ export interface RoomNameEventContent { } export interface RoomTopicEventContent { - topic: string; + topic: string | undefined | null; } export interface RoomAvatarEventContent { diff --git a/src/client.ts b/src/client.ts index 5e1c8deee3..c05e6a1a1e 100644 --- a/src/client.ts +++ b/src/client.ts @@ -4490,11 +4490,13 @@ export class MatrixClient extends TypedEventEmitter { + public setRoomTopic(roomId: string, topic?: string, htmlTopic?: string): Promise { const content = ContentHelpers.makeTopicContent(topic, htmlTopic); return this.sendStateEvent(roomId, EventType.RoomTopic, content); } diff --git a/src/content-helpers.ts b/src/content-helpers.ts index 32020e764d..fb27b98cb9 100644 --- a/src/content-helpers.ts +++ b/src/content-helpers.ts @@ -14,6 +14,8 @@ See the License for the specific language governing permissions and limitations under the License. */ +import { Optional } from "matrix-events-sdk"; + import { MBeaconEventContent, MBeaconInfoContent, MBeaconInfoEventContent } from "./@types/beacon.ts"; import { MsgType } from "./@types/event.ts"; import { M_TEXT, REFERENCE_RELATION } from "./@types/extensible_events.ts"; @@ -31,7 +33,6 @@ import { } from "./@types/location.ts"; import { MRoomTopicEventContent, MTopicContent, M_TOPIC } from "./@types/topic.ts"; import { RoomMessageEventContent } from "./@types/events.ts"; -import { Optional } from "matrix-events-sdk"; /** * Generates the content for a HTML Message event