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:
@@ -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;
|
||||
|
||||
@@ -14,8 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { RoomType, IProtocol, IPublicRoomsChunkRoom } from "matrix-js-sdk/src/matrix";
|
||||
import { IRoomDirectoryOptions } from "matrix-js-sdk/src/@types/requests";
|
||||
import { RoomType, IProtocol, IPublicRoomsChunkRoom, IRoomDirectoryOptions } from "matrix-js-sdk/src/matrix";
|
||||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
import { IPublicRoomDirectoryConfig } from "../components/views/directory/NetworkDropdown";
|
||||
|
||||
@@ -15,15 +15,14 @@ limitations under the License.
|
||||
*/
|
||||
|
||||
import { useCallback, useEffect, useMemo, useState } from "react";
|
||||
import { Room, RoomType } from "matrix-js-sdk/src/matrix";
|
||||
import { IHierarchyRoom } from "matrix-js-sdk/src/@types/spaces";
|
||||
import { Room, RoomType, HierarchyRoom } from "matrix-js-sdk/src/matrix";
|
||||
import { RoomHierarchy } from "matrix-js-sdk/src/room-hierarchy";
|
||||
import { normalize } from "matrix-js-sdk/src/utils";
|
||||
|
||||
import { MatrixClientPeg } from "../MatrixClientPeg";
|
||||
|
||||
export const useSpaceResults = (space: Room | undefined, query: string): [IHierarchyRoom[], boolean] => {
|
||||
const [rooms, setRooms] = useState<IHierarchyRoom[]>([]);
|
||||
export const useSpaceResults = (space: Room | undefined, query: string): [HierarchyRoom[], boolean] => {
|
||||
const [rooms, setRooms] = useState<HierarchyRoom[]>([]);
|
||||
const [hierarchy, setHierarchy] = useState<RoomHierarchy>();
|
||||
|
||||
const resetHierarchy = useCallback(() => {
|
||||
|
||||
Reference in New Issue
Block a user