- {sortedPinnedEvent.length > 0 ? (
+ {events && events.length > 0 ? (
(
}}
>
{virtualizer.getVirtualItems().map((vItem) => {
- const eventId = sortedPinnedEvent[vItem.index];
- if (!eventId) return null;
+ const event = events[vItem.index];
+ if (!event.getId()) return null;
return (
(
variant="SurfaceVariant"
direction="Column"
>
-
@@ -441,7 +476,7 @@ export const ThreadsMenu = forwardRef(
No Threads
- This room does not have any threads yet.
+ Threads you are participating in will appear here.
diff --git a/src/app/features/room/threads-menu/index.ts b/src/app/features/room/threads-menu/index.ts
new file mode 100644
index 00000000..98286736
--- /dev/null
+++ b/src/app/features/room/threads-menu/index.ts
@@ -0,0 +1 @@
+export * from './ThreadsMenu';
diff --git a/src/app/hooks/useRoomThreads.ts b/src/app/hooks/useRoomThreads.ts
index 8050a5d9..d5ef24d6 100644
--- a/src/app/hooks/useRoomThreads.ts
+++ b/src/app/hooks/useRoomThreads.ts
@@ -1,9 +1,29 @@
-// import { Room } from 'matrix-js-sdk';
-// import { useMatrixClient } from './useMatrixClient';
+import { useCallback } from 'react';
+import { Direction, MatrixEvent, Room, ThreadFilterType } from 'matrix-js-sdk';
+import { useMatrixClient } from './useMatrixClient';
+import { AsyncStatus, useAsyncCallbackValue } from './useAsyncCallback';
-// export const useRoomThreads = (room: Room) => {
-// const mx = useMatrixClient();
+export const useRoomMyThreads = (room: Room): MatrixEvent[] | undefined => {
+ const mx = useMatrixClient();
-// mx.createThreadListMessagesRequest;
-// mx.processThreadRoots;
-// };
+ const [fetchState] = useAsyncCallbackValue(
+ useCallback(
+ () =>
+ mx.createThreadListMessagesRequest(
+ room.roomId,
+ null,
+ 30,
+ Direction.Backward,
+ ThreadFilterType.My
+ ),
+ [mx, room]
+ )
+ );
+
+ if (fetchState.status === AsyncStatus.Success) {
+ const roomEvents = fetchState.data.chunk;
+ const mEvents = roomEvents.map((event) => new MatrixEvent(event)).reverse();
+ return mEvents;
+ }
+ return undefined;
+};
diff --git a/src/app/utils/room.ts b/src/app/utils/room.ts
index b4bba2ad..e80edb20 100644
--- a/src/app/utils/room.ts
+++ b/src/app/utils/room.ts
@@ -8,6 +8,7 @@ import {
IPowerLevelsContent,
IPushRule,
IPushRules,
+ IThreadBundledRelationship,
JoinRule,
MatrixClient,
MatrixEvent,
@@ -16,6 +17,7 @@ import {
RelationType,
Room,
RoomMember,
+ THREAD_RELATION_TYPE,
} from 'matrix-js-sdk';
import { CryptoBackend } from 'matrix-js-sdk/lib/common-crypto/CryptoBackend';
import { AccountDataEvent } from '../../types/matrix/accountData';
@@ -551,3 +553,13 @@ export const guessPerfectParent = (
return perfectParent;
};
+
+export const getEventThreadDetail = (
+ mEvent: MatrixEvent
+): IThreadBundledRelationship | undefined => {
+ const details = mEvent.getServerAggregatedRelation(
+ THREAD_RELATION_TYPE.name
+ );
+
+ return details;
+};