9273eb5f2e
P3-1: Message Bookmarks — right-click any message to bookmark; saved to io.lotus.bookmarks account data (max 500, syncs across devices); star icon in sidebar opens BookmarksPanel with filter, Jump-to-message, and remove buttons; reactive to AccountData events P3-2: Message Scheduling (MSC4140) — clock button next to send opens ScheduleMessageModal with datetime-local picker; validates ≥1 min future; calls PUT org.matrix.msc4140 delayed event API; collapsible ScheduledMessagesTray above composer lists pending messages with cancel; local Jotai atom tracks scheduled messages per room P3-3: File Upload Compression — opt-in checkbox per JPEG/PNG file ≥200KB in upload preview; canvas API compresses at 0.82 quality; shows before/ after size estimate; compressed blob used in upload when checked P3-7: Room Insights — new Insights tab in room settings; top 5 active members (bar chart), top 5 reactions (chips), media breakdown (4 tiles), 24-hour activity heatmap (CSS bar chart); all from local cache only with disclaimer banner; never the first tab shown Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
62 lines
2.0 KiB
TypeScript
62 lines
2.0 KiB
TypeScript
import { atom } from 'jotai';
|
|
import { atomFamily } from 'jotai/utils';
|
|
import { Descendant } from 'slate';
|
|
import { EncryptedAttachmentInfo } from 'browser-encrypt-attachment';
|
|
import { IEventRelation } from 'matrix-js-sdk';
|
|
import { createUploadAtomFamily } from '../upload';
|
|
import { TUploadContent } from '../../utils/matrix';
|
|
import { createListAtom } from '../list';
|
|
import { CompressionResult } from '../../utils/imageCompression';
|
|
|
|
export type TUploadMetadata = {
|
|
markedAsSpoiler: boolean;
|
|
caption?: string;
|
|
/** User has opted in to compressing this image before upload */
|
|
compressImage?: boolean;
|
|
/** Cached compression result (populated in the background when compressImage is set to true) */
|
|
compressionResult?: CompressionResult | null;
|
|
};
|
|
|
|
export type TUploadItem = {
|
|
file: TUploadContent;
|
|
originalFile: TUploadContent;
|
|
metadata: TUploadMetadata;
|
|
encInfo: EncryptedAttachmentInfo | undefined;
|
|
};
|
|
|
|
export type TUploadListAtom = ReturnType<typeof createListAtom<TUploadItem>>;
|
|
|
|
export const roomIdToUploadItemsAtomFamily = atomFamily<string, TUploadListAtom>(createListAtom);
|
|
|
|
export const roomUploadAtomFamily = createUploadAtomFamily();
|
|
|
|
export type RoomIdToMsgAction =
|
|
| {
|
|
type: 'PUT';
|
|
roomId: string;
|
|
msg: Descendant[];
|
|
}
|
|
| {
|
|
type: 'DELETE';
|
|
roomId: string;
|
|
};
|
|
|
|
const createMsgDraftAtom = () => atom<Descendant[]>([]);
|
|
export type TMsgDraftAtom = ReturnType<typeof createMsgDraftAtom>;
|
|
export const roomIdToMsgDraftAtomFamily = atomFamily<string, TMsgDraftAtom>(() =>
|
|
createMsgDraftAtom(),
|
|
);
|
|
|
|
export type IReplyDraft = {
|
|
userId: string;
|
|
eventId: string;
|
|
body: string;
|
|
formattedBody?: string | undefined;
|
|
relation?: IEventRelation | undefined;
|
|
};
|
|
const createReplyDraftAtom = () => atom<IReplyDraft | undefined>(undefined);
|
|
export type TReplyDraftAtom = ReturnType<typeof createReplyDraftAtom>;
|
|
export const roomIdToReplyDraftAtomFamily = atomFamily<string, TReplyDraftAtom>(() =>
|
|
createReplyDraftAtom(),
|
|
);
|