mirror of
https://github.com/SableClient/Sable.git
synced 2026-11-20 17:11:17 -08:00
feat(threads): add core thread state management and types
- Add roomToOpenThread atom family for tracking active thread per room - Add roomToThreadBrowser atom family for thread browser visibility - Add Thread, ThreadEvent, and NotificationCountType exports to matrix-sdk types - Update toggleReaction to support thread timeline sets - Foundation for thread feature state management
This commit is contained in:
1 parent
78ebffac2e
commit
cc22321cf7
4 files changed
+37
-2
No files matched your search
@@ -0,0 +1,14 @@
|
||||
import { atom } from 'jotai';
|
||||
import { atomFamily } from 'jotai/utils';
|
||||
|
||||
const createOpenThreadAtom = () => atom<string | undefined>(undefined);
|
||||
export type TOpenThreadAtom = ReturnType<typeof createOpenThreadAtom>;
|
||||
|
||||
/**
|
||||
* Tracks the currently-open thread root event ID per room.
|
||||
* Key: roomId
|
||||
* Value: eventId of the thread root, or undefined if no thread is open.
|
||||
*/
|
||||
export const roomIdToOpenThreadAtomFamily = atomFamily<string, TOpenThreadAtom>(() =>
|
||||
createOpenThreadAtom()
|
||||
);
|
||||
@@ -0,0 +1,13 @@
|
||||
import { atom } from 'jotai';
|
||||
import { atomFamily } from 'jotai/utils';
|
||||
|
||||
const createThreadBrowserAtom = () => atom<boolean>(false);
|
||||
export type TThreadBrowserAtom = ReturnType<typeof createThreadBrowserAtom>;
|
||||
|
||||
/**
|
||||
* Tracks whether the thread browser panel is open per room.
|
||||
* Key: roomId
|
||||
*/
|
||||
export const roomIdToThreadBrowserAtomFamily = atomFamily<string, TThreadBrowserAtom>(() =>
|
||||
createThreadBrowserAtom()
|
||||
);
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
} from 'browser-encrypt-attachment';
|
||||
import {
|
||||
EventTimeline,
|
||||
EventTimelineSet,
|
||||
MatrixClient,
|
||||
MatrixError,
|
||||
MatrixEvent,
|
||||
@@ -387,9 +388,13 @@ export const toggleReaction = (
|
||||
room: Room,
|
||||
targetEventId: string,
|
||||
key: string,
|
||||
shortcode?: string
|
||||
shortcode?: string,
|
||||
timelineSet?: EventTimelineSet
|
||||
) => {
|
||||
const relations = getEventReactions(room.getUnfilteredTimelineSet(), targetEventId);
|
||||
const relations = getEventReactions(
|
||||
timelineSet ?? room.getUnfilteredTimelineSet(),
|
||||
targetEventId
|
||||
);
|
||||
const allReactions = relations?.getSortedAnnotationsByKey() ?? [];
|
||||
const [, reactionsSet] = allReactions.find(([k]: [string, any]) => k === key) ?? [];
|
||||
const reactions: MatrixEvent[] = reactionsSet ? Array.from(reactionsSet) : [];
|
||||
|
||||
@@ -51,3 +51,6 @@ export * from 'matrix-js-sdk/lib/common-crypto/CryptoBackend';
|
||||
|
||||
export * from 'matrix-js-sdk/lib/matrixrtc/CallMembership';
|
||||
export * from 'matrix-js-sdk/lib/matrixrtc/MatrixRTCSession';
|
||||
|
||||
export { ThreadEvent } from 'matrix-js-sdk/lib/models/thread';
|
||||
export type { Thread } from 'matrix-js-sdk/lib/models/thread';
|
||||
Reference in new issue
Block a user