Switch to importing most things from the main matrix-js-sdk export (#11406)
* Switch to importing most things from the main matrix-js-sdk export * fix imports * Iterate * Fix tests
This commit is contained in:
parent
0842559fb2
commit
ad73b0c16e
52 changed files with 262 additions and 277 deletions
|
@ -15,19 +15,18 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { EventType, MatrixEvent, Room, RoomStateEvent } from "matrix-js-sdk/src/matrix";
|
||||
import { parseTopicContent, TopicState } from "matrix-js-sdk/src/content-helpers";
|
||||
import { EventType, MatrixEvent, Room, RoomStateEvent, ContentHelpers } from "matrix-js-sdk/src/matrix";
|
||||
import { MRoomTopicEventContent } from "matrix-js-sdk/src/@types/topic";
|
||||
import { Optional } from "matrix-events-sdk";
|
||||
|
||||
import { useTypedEventEmitter } from "../useEventEmitter";
|
||||
|
||||
export const getTopic = (room?: Room): Optional<TopicState> => {
|
||||
export const getTopic = (room?: Room): Optional<ContentHelpers.TopicState> => {
|
||||
const content = room?.currentState?.getStateEvents(EventType.RoomTopic, "")?.getContent<MRoomTopicEventContent>();
|
||||
return !!content ? parseTopicContent(content) : null;
|
||||
return !!content ? ContentHelpers.parseTopicContent(content) : null;
|
||||
};
|
||||
|
||||
export function useTopic(room?: Room): Optional<TopicState> {
|
||||
export function useTopic(room?: Room): Optional<ContentHelpers.TopicState> {
|
||||
const [topic, setTopic] = useState(getTopic(room));
|
||||
useTypedEventEmitter(room?.currentState, RoomStateEvent.Events, (ev: MatrixEvent) => {
|
||||
if (ev.getType() !== EventType.RoomTopic) return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue