Compare commits
2
Commits
831ce01150
...
230ca4fcf0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
230ca4fcf0 | ||
|
|
9591d8d01b |
@@ -45,7 +45,7 @@ async function leaveRoomsSequentially(
|
|||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const total = roomIds.length;
|
const total = roomIds.length;
|
||||||
|
|
||||||
for (let i = 0; i < roomIds.length; i++) {
|
for (let i = 0; i < roomIds.length; i += 1) {
|
||||||
const roomId = roomIds[i];
|
const roomId = roomIds[i];
|
||||||
onProgress?.(i, total);
|
onProgress?.(i, total);
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ export const Video = forwardRef<HTMLVideoElement, VideoProps>(
|
|||||||
}, [ref]);
|
}, [ref]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!onExpand) return;
|
if (!onExpand) return undefined;
|
||||||
const video = videoRef.current;
|
const video = videoRef.current;
|
||||||
if (!video) return;
|
if (!video) return undefined;
|
||||||
|
|
||||||
const handleFullscreenRequest = (evt: Event) => {
|
const handleFullscreenRequest = (evt: Event) => {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export async function collectInaccessibleSpaceChildren(
|
|||||||
if (!spaceRoom || spaceRoom.getMyMembership() !== Membership.Join) return;
|
if (!spaceRoom || spaceRoom.getMyMembership() !== Membership.Join) return;
|
||||||
if (!canEditSpaceChildren(mx, spaceRoom)) return;
|
if (!canEditSpaceChildren(mx, spaceRoom)) return;
|
||||||
|
|
||||||
for (const childId of getSpaceChildren(spaceRoom)) {
|
getSpaceChildren(spaceRoom).forEach((childId) => {
|
||||||
childCount += 1;
|
childCount += 1;
|
||||||
const childRoom = mx.getRoom(childId);
|
const childRoom = mx.getRoom(childId);
|
||||||
// Lobby uses joined-only getRoom; left/invite rooms still render as Inaccessible.
|
// Lobby uses joined-only getRoom; left/invite rooms still render as Inaccessible.
|
||||||
@@ -100,22 +100,22 @@ export async function collectInaccessibleSpaceChildren(
|
|||||||
if (joined && childRoom && isSpace(childRoom)) {
|
if (joined && childRoom && isSpace(childRoom)) {
|
||||||
joinedCount += 1;
|
joinedCount += 1;
|
||||||
walk(childId);
|
walk(childId);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (joined) {
|
if (joined) {
|
||||||
joinedCount += 1;
|
joinedCount += 1;
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasHierarchySummary = hierarchySummaries.has(childId);
|
const hasHierarchySummary = hierarchySummaries.has(childId);
|
||||||
if (hasHierarchySummary) {
|
if (hasHierarchySummary) {
|
||||||
joinableCount += 1;
|
joinableCount += 1;
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
inaccessible.push({ parentId: spaceId, roomId: childId });
|
inaccessible.push({ parentId: spaceId, roomId: childId });
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
walk(rootSpaceId);
|
walk(rootSpaceId);
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export function SettingTile({
|
|||||||
const anchorId = anchorIdProp ?? autoAnchorId;
|
const anchorId = anchorIdProp ?? autoAnchorId;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!anchorId || !focusAnchorId || anchorId !== focusAnchorId) return;
|
if (!anchorId || !focusAnchorId || anchorId !== focusAnchorId) return undefined;
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
|
|
||||||
@@ -57,7 +57,7 @@ export function SettingTile({
|
|||||||
}, [anchorId, focusAnchorId, setAnchorId]);
|
}, [anchorId, focusAnchorId, setAnchorId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!highlighted) return;
|
if (!highlighted) return undefined;
|
||||||
const timer = window.setTimeout(() => setHighlighted(false), 1400);
|
const timer = window.setTimeout(() => setHighlighted(false), 1400);
|
||||||
return () => window.clearTimeout(timer);
|
return () => window.clearTimeout(timer);
|
||||||
}, [highlighted]);
|
}, [highlighted]);
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ export function TitleBar({ mx, children }: TitleBarProps) {
|
|||||||
|
|
||||||
// Subscribe to room changes for unread updates and new messages
|
// Subscribe to room changes for unread updates and new messages
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mx) return;
|
if (!mx) return undefined;
|
||||||
|
|
||||||
const update = () => setUpdateCounter((c) => c + 1);
|
const update = () => setUpdateCounter((c) => c + 1);
|
||||||
|
|
||||||
@@ -473,7 +473,7 @@ export function TitleBar({ mx, children }: TitleBarProps) {
|
|||||||
|
|
||||||
// Clear notifications when user reads messages in a room
|
// Clear notifications when user reads messages in a room
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mx) return;
|
if (!mx) return undefined;
|
||||||
|
|
||||||
const handleReceipt = (event: MatrixEvent, room: Room) => {
|
const handleReceipt = (event: MatrixEvent, room: Room) => {
|
||||||
const myUserId = mx.getUserId();
|
const myUserId = mx.getUserId();
|
||||||
|
|||||||
@@ -295,24 +295,23 @@ export async function fetchLiveKitJWTFromServers(
|
|||||||
|
|
||||||
if (!livekitFocus) {
|
if (!livekitFocus) {
|
||||||
console.log(`No LiveKit config on ${homeserver}, trying next...`);
|
console.log(`No LiveKit config on ${homeserver}, trying next...`);
|
||||||
continue;
|
} else {
|
||||||
|
// Always get OpenID token from user's own homeserver
|
||||||
|
// (Can't use access token on remote homeserver)
|
||||||
|
const openIdToken = await requestOpenIdToken(userHomeserver, userId, accessToken);
|
||||||
|
|
||||||
|
// Exchange for LiveKit JWT
|
||||||
|
const jwt = await fetchLiveKitJWT(
|
||||||
|
livekitFocus.livekit_service_url,
|
||||||
|
roomId,
|
||||||
|
userId,
|
||||||
|
deviceId,
|
||||||
|
openIdToken,
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log(`Successfully got LiveKit JWT from ${homeserver}`);
|
||||||
|
return { jwt, homeserver };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always get OpenID token from user's own homeserver
|
|
||||||
// (Can't use access token on remote homeserver)
|
|
||||||
const openIdToken = await requestOpenIdToken(userHomeserver, userId, accessToken);
|
|
||||||
|
|
||||||
// Exchange for LiveKit JWT
|
|
||||||
const jwt = await fetchLiveKitJWT(
|
|
||||||
livekitFocus.livekit_service_url,
|
|
||||||
roomId,
|
|
||||||
userId,
|
|
||||||
deviceId,
|
|
||||||
openIdToken,
|
|
||||||
);
|
|
||||||
|
|
||||||
console.log(`Successfully got LiveKit JWT from ${homeserver}`);
|
|
||||||
return { jwt, homeserver };
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.warn(`Failed to get LiveKit JWT from ${homeserver}:`, error);
|
console.warn(`Failed to get LiveKit JWT from ${homeserver}:`, error);
|
||||||
// Continue to next homeserver
|
// Continue to next homeserver
|
||||||
|
|||||||
+119
-108
@@ -44,6 +44,34 @@ function isForumRootContent(content: Record<string, unknown>): boolean {
|
|||||||
return typeof formatted === 'string' && /<h1[\s>]/i.test(formatted);
|
return typeof formatted === 'string' && /<h1[\s>]/i.test(formatted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function postTitleFromContent(content: Record<string, unknown>): { title: string; body: string } {
|
||||||
|
const rawBody = typeof content.body === 'string' ? content.body : '';
|
||||||
|
const customTitle =
|
||||||
|
typeof content['com.matrixsso.title'] === 'string'
|
||||||
|
? String(content['com.matrixsso.title']).trim()
|
||||||
|
: '';
|
||||||
|
const htmlTitle =
|
||||||
|
typeof content.formatted_body === 'string'
|
||||||
|
? titleFromFormattedBody(content.formatted_body)
|
||||||
|
: undefined;
|
||||||
|
const firstLine = rawBody.split(/\r?\n/, 1)[0]?.trim() ?? '';
|
||||||
|
const title = (customTitle || htmlTitle || firstLine || '(untitled post)').slice(0, 160);
|
||||||
|
|
||||||
|
let body = rawBody;
|
||||||
|
if (customTitle && rawBody.startsWith(customTitle)) {
|
||||||
|
body = rawBody.slice(customTitle.length).replace(/^\s+/, '');
|
||||||
|
} else {
|
||||||
|
const [leadingBlock, ...restBlocks] = rawBody.split(/\r?\n\r?\n/);
|
||||||
|
if (restBlocks.length > 0 && leadingBlock.trim() === firstLine) {
|
||||||
|
body = restBlocks.join('\n\n').trim();
|
||||||
|
} else if (firstLine && rawBody.startsWith(firstLine)) {
|
||||||
|
body = rawBody.slice(firstLine.length).replace(/^\s+/, '');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return { title, body: body || rawBody };
|
||||||
|
}
|
||||||
|
|
||||||
function syncForumRootContentAfterEdit(
|
function syncForumRootContentAfterEdit(
|
||||||
merged: Record<string, unknown>,
|
merged: Record<string, unknown>,
|
||||||
baseContent: Record<string, unknown>,
|
baseContent: Record<string, unknown>,
|
||||||
@@ -109,34 +137,6 @@ function parseBundledThreadReplyCount(event: IRoomEvent): number | undefined {
|
|||||||
return Math.floor(count);
|
return Math.floor(count);
|
||||||
}
|
}
|
||||||
|
|
||||||
function postTitleFromContent(content: Record<string, unknown>): { title: string; body: string } {
|
|
||||||
const rawBody = typeof content.body === 'string' ? content.body : '';
|
|
||||||
const customTitle =
|
|
||||||
typeof content['com.matrixsso.title'] === 'string'
|
|
||||||
? String(content['com.matrixsso.title']).trim()
|
|
||||||
: '';
|
|
||||||
const htmlTitle =
|
|
||||||
typeof content.formatted_body === 'string'
|
|
||||||
? titleFromFormattedBody(content.formatted_body)
|
|
||||||
: undefined;
|
|
||||||
const firstLine = rawBody.split(/\r?\n/, 1)[0]?.trim() ?? '';
|
|
||||||
const title = (customTitle || htmlTitle || firstLine || '(untitled post)').slice(0, 160);
|
|
||||||
|
|
||||||
let body = rawBody;
|
|
||||||
if (customTitle && rawBody.startsWith(customTitle)) {
|
|
||||||
body = rawBody.slice(customTitle.length).replace(/^\s+/, '');
|
|
||||||
} else {
|
|
||||||
const [leadingBlock, ...restBlocks] = rawBody.split(/\r?\n\r?\n/);
|
|
||||||
if (restBlocks.length > 0 && leadingBlock.trim() === firstLine) {
|
|
||||||
body = restBlocks.join('\n\n').trim();
|
|
||||||
} else if (firstLine && rawBody.startsWith(firstLine)) {
|
|
||||||
body = rawBody.slice(firstLine.length).replace(/^\s+/, '');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return { title, body: body || rawBody };
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Title + body for a forum matrix message payload (including edits). */
|
/** Title + body for a forum matrix message payload (including edits). */
|
||||||
export function forumPostTitleFromContent(content: Record<string, unknown>): string {
|
export function forumPostTitleFromContent(content: Record<string, unknown>): string {
|
||||||
return postTitleFromContent(content).title;
|
return postTitleFromContent(content).title;
|
||||||
@@ -144,9 +144,27 @@ export function forumPostTitleFromContent(content: Record<string, unknown>): str
|
|||||||
|
|
||||||
function sortRepliesRecursively(posts: ForumPost[]) {
|
function sortRepliesRecursively(posts: ForumPost[]) {
|
||||||
posts.sort((a, b) => a.timestamp - b.timestamp);
|
posts.sort((a, b) => a.timestamp - b.timestamp);
|
||||||
for (const post of posts) {
|
posts.forEach((post) => {
|
||||||
if (post.replies.length > 0) sortRepliesRecursively(post.replies);
|
if (post.replies.length > 0) sortRepliesRecursively(post.replies);
|
||||||
}
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function mergeRootPosts(existing: ForumPost[], incoming: ForumPost[]): ForumPost[] {
|
||||||
|
const byId = new Map(existing.map((post) => [post.eventId, post]));
|
||||||
|
incoming.forEach((post) => {
|
||||||
|
const previous = byId.get(post.eventId);
|
||||||
|
if (!previous) {
|
||||||
|
byId.set(post.eventId, post);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const replyIds = new Set(previous.replies.map((reply) => reply.eventId));
|
||||||
|
const mergedReplies = [
|
||||||
|
...previous.replies,
|
||||||
|
...post.replies.filter((reply) => !replyIds.has(reply.eventId)),
|
||||||
|
];
|
||||||
|
byId.set(post.eventId, { ...post, replies: mergedReplies });
|
||||||
|
});
|
||||||
|
return [...byId.values()].sort((a, b) => b.timestamp - a.timestamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildPosts(mx: MatrixClient, roomId: string, timelineEvents: IRoomEvent[]): ForumPost[] {
|
function buildPosts(mx: MatrixClient, roomId: string, timelineEvents: IRoomEvent[]): ForumPost[] {
|
||||||
@@ -202,7 +220,7 @@ function buildPosts(mx: MatrixClient, roomId: string, timelineEvents: IRoomEvent
|
|||||||
.sort((a, b) => a.timestamp - b.timestamp);
|
.sort((a, b) => a.timestamp - b.timestamp);
|
||||||
|
|
||||||
const postsById = new Map<string, ForumPost>();
|
const postsById = new Map<string, ForumPost>();
|
||||||
for (const event of normalized) {
|
normalized.forEach((event) => {
|
||||||
postsById.set(event.eventId, {
|
postsById.set(event.eventId, {
|
||||||
eventId: event.eventId,
|
eventId: event.eventId,
|
||||||
title: event.title,
|
title: event.title,
|
||||||
@@ -214,14 +232,14 @@ function buildPosts(mx: MatrixClient, roomId: string, timelineEvents: IRoomEvent
|
|||||||
bundledReplyCount: event.bundledReplyCount,
|
bundledReplyCount: event.bundledReplyCount,
|
||||||
replies: [],
|
replies: [],
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
const roots: ForumPost[] = [];
|
const roots: ForumPost[] = [];
|
||||||
const placedReplyIds = new Set<string>();
|
const placedReplyIds = new Set<string>();
|
||||||
|
|
||||||
for (const event of normalized) {
|
normalized.forEach((event) => {
|
||||||
const current = postsById.get(event.eventId);
|
const current = postsById.get(event.eventId);
|
||||||
if (!current) continue;
|
if (!current) return;
|
||||||
|
|
||||||
const { relation } = event;
|
const { relation } = event;
|
||||||
let threadRootId: string | null = null;
|
let threadRootId: string | null = null;
|
||||||
@@ -236,10 +254,10 @@ function buildPosts(mx: MatrixClient, roomId: string, timelineEvents: IRoomEvent
|
|||||||
|
|
||||||
if (!threadRootId) {
|
if (!threadRootId) {
|
||||||
roots.push(current);
|
roots.push(current);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (placedReplyIds.has(event.eventId)) continue;
|
if (placedReplyIds.has(event.eventId)) return;
|
||||||
|
|
||||||
if (parentEventId && parentEventId !== threadRootId) {
|
if (parentEventId && parentEventId !== threadRootId) {
|
||||||
const parent = postsById.get(parentEventId);
|
const parent = postsById.get(parentEventId);
|
||||||
@@ -247,7 +265,7 @@ function buildPosts(mx: MatrixClient, roomId: string, timelineEvents: IRoomEvent
|
|||||||
current.replyToEventId = parentEventId;
|
current.replyToEventId = parentEventId;
|
||||||
parent.replies.push(current);
|
parent.replies.push(current);
|
||||||
placedReplyIds.add(event.eventId);
|
placedReplyIds.add(event.eventId);
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
current.replyToEventId = parentEventId;
|
current.replyToEventId = parentEventId;
|
||||||
@@ -257,7 +275,7 @@ function buildPosts(mx: MatrixClient, roomId: string, timelineEvents: IRoomEvent
|
|||||||
threadRoot.replies.push(current);
|
threadRoot.replies.push(current);
|
||||||
placedReplyIds.add(event.eventId);
|
placedReplyIds.add(event.eventId);
|
||||||
}
|
}
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const threadRoot = postsById.get(threadRootId);
|
const threadRoot = postsById.get(threadRootId);
|
||||||
@@ -265,7 +283,7 @@ function buildPosts(mx: MatrixClient, roomId: string, timelineEvents: IRoomEvent
|
|||||||
threadRoot.replies.push(current);
|
threadRoot.replies.push(current);
|
||||||
placedReplyIds.add(event.eventId);
|
placedReplyIds.add(event.eventId);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
sortRepliesRecursively(roots);
|
sortRepliesRecursively(roots);
|
||||||
return roots.sort((a, b) => b.timestamp - a.timestamp);
|
return roots.sort((a, b) => b.timestamp - a.timestamp);
|
||||||
@@ -285,14 +303,13 @@ export async function listForumTopics(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const parentByRoomId = new Map<string, string>();
|
const parentByRoomId = new Map<string, string>();
|
||||||
for (const room of rooms) {
|
rooms.forEach((room) => {
|
||||||
if (!room?.room_id || !Array.isArray(room.children_state)) continue;
|
if (!room?.room_id || !Array.isArray(room.children_state)) return;
|
||||||
for (const childState of room.children_state) {
|
room.children_state.forEach((childState) => {
|
||||||
if (childState?.type !== 'm.space.child' || typeof childState.state_key !== 'string')
|
if (childState?.type !== 'm.space.child' || typeof childState.state_key !== 'string') return;
|
||||||
continue;
|
|
||||||
parentByRoomId.set(childState.state_key, room.room_id);
|
parentByRoomId.set(childState.state_key, room.room_id);
|
||||||
}
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
const fromHierarchy = rooms
|
const fromHierarchy = rooms
|
||||||
.filter((room) => room?.room_id && room.room_id !== spaceRoomId)
|
.filter((room) => room?.room_id && room.room_id !== spaceRoomId)
|
||||||
@@ -321,8 +338,8 @@ export async function listForumTopics(
|
|||||||
const parentRoom = mx.getRoom(parentId);
|
const parentRoom = mx.getRoom(parentId);
|
||||||
if (!parentRoom) return;
|
if (!parentRoom) return;
|
||||||
|
|
||||||
for (const childId of getSpaceChildren(parentRoom)) {
|
getSpaceChildren(parentRoom).forEach((childId) => {
|
||||||
if (childId === spaceRoomId || visited.has(childId)) continue;
|
if (childId === spaceRoomId || visited.has(childId)) return;
|
||||||
const child = mx.getRoom(childId);
|
const child = mx.getRoom(childId);
|
||||||
const name = child?.name || childId;
|
const name = child?.name || childId;
|
||||||
const childIsSpace = isSpace(child ?? null);
|
const childIsSpace = isSpace(child ?? null);
|
||||||
@@ -333,7 +350,7 @@ export async function listForumTopics(
|
|||||||
parentRoomId: parentId,
|
parentRoomId: parentId,
|
||||||
});
|
});
|
||||||
if (childIsSpace) collectFromSpace(childId, depth + 1);
|
if (childIsSpace) collectFromSpace(childId, depth + 1);
|
||||||
}
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
collectFromSpace(spaceRoomId, 0);
|
collectFromSpace(spaceRoomId, 0);
|
||||||
@@ -371,35 +388,17 @@ export async function listTopicFeedPosts(
|
|||||||
return { posts: merged, nextBatch: nextBatch ?? null };
|
return { posts: merged, nextBatch: nextBatch ?? null };
|
||||||
}
|
}
|
||||||
|
|
||||||
function mergeRootPosts(existing: ForumPost[], incoming: ForumPost[]): ForumPost[] {
|
|
||||||
const byId = new Map(existing.map((post) => [post.eventId, post]));
|
|
||||||
for (const post of incoming) {
|
|
||||||
const previous = byId.get(post.eventId);
|
|
||||||
if (!previous) {
|
|
||||||
byId.set(post.eventId, post);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
const replyIds = new Set(previous.replies.map((reply) => reply.eventId));
|
|
||||||
const mergedReplies = [
|
|
||||||
...previous.replies,
|
|
||||||
...post.replies.filter((reply) => !replyIds.has(reply.eventId)),
|
|
||||||
];
|
|
||||||
byId.set(post.eventId, { ...post, replies: mergedReplies });
|
|
||||||
}
|
|
||||||
return [...byId.values()].sort((a, b) => b.timestamp - a.timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
function mergeUniqueRoomEvents(...lists: IRoomEvent[][]): IRoomEvent[] {
|
function mergeUniqueRoomEvents(...lists: IRoomEvent[][]): IRoomEvent[] {
|
||||||
const seen = new Set<string>();
|
const seen = new Set<string>();
|
||||||
const unique: IRoomEvent[] = [];
|
const unique: IRoomEvent[] = [];
|
||||||
for (const list of lists) {
|
lists.forEach((list) => {
|
||||||
for (const event of list) {
|
list.forEach((event) => {
|
||||||
const id = event.event_id;
|
const id = event.event_id;
|
||||||
if (!id || seen.has(id)) continue;
|
if (!id || seen.has(id)) return;
|
||||||
seen.add(id);
|
seen.add(id);
|
||||||
unique.push(event);
|
unique.push(event);
|
||||||
}
|
});
|
||||||
}
|
});
|
||||||
return unique;
|
return unique;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -437,6 +436,29 @@ function matrixEventToRoomEvent(mEvent: MatrixEvent): IRoomEvent {
|
|||||||
return mEvent.event as IRoomEvent;
|
return mEvent.event as IRoomEvent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function collectLocalReplaceEdits(room: Room, targetIds: Set<string>): IRoomEvent[] {
|
||||||
|
const events: IRoomEvent[] = [];
|
||||||
|
const seen = new Set<string>();
|
||||||
|
|
||||||
|
room
|
||||||
|
.getUnfilteredTimelineSet()
|
||||||
|
.getLiveTimeline()
|
||||||
|
.getEvents()
|
||||||
|
.forEach((mEvent) => {
|
||||||
|
if (mEvent.isRedacted() || mEvent.getType() !== EventType.RoomMessage) return;
|
||||||
|
const relation = mEvent.getRelation();
|
||||||
|
if (relation?.rel_type !== RelationType.Replace) return;
|
||||||
|
const targetId = relation.event_id;
|
||||||
|
if (!targetId || !targetIds.has(targetId)) return;
|
||||||
|
const id = mEvent.getId();
|
||||||
|
if (!id || seen.has(id)) return;
|
||||||
|
seen.add(id);
|
||||||
|
events.push(matrixEventToRoomEvent(mEvent));
|
||||||
|
});
|
||||||
|
|
||||||
|
return events;
|
||||||
|
}
|
||||||
|
|
||||||
/** Thread events already in the local room timeline (includes unsent/local echo). */
|
/** Thread events already in the local room timeline (includes unsent/local echo). */
|
||||||
export function collectLocalThreadEvents(
|
export function collectLocalThreadEvents(
|
||||||
mx: MatrixClient,
|
mx: MatrixClient,
|
||||||
@@ -466,13 +488,17 @@ export function collectLocalThreadEvents(
|
|||||||
const thread = room.getThread(rootId);
|
const thread = room.getThread(rootId);
|
||||||
if (thread) {
|
if (thread) {
|
||||||
add(thread.rootEvent);
|
add(thread.rootEvent);
|
||||||
for (const reply of thread.events) add(reply);
|
thread.events.forEach((reply) => add(reply));
|
||||||
for (const reply of thread.liveTimeline?.getEvents() ?? []) add(reply);
|
(thread.liveTimeline?.getEvents() ?? []).forEach((reply) => add(reply));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const mEvent of room.getUnfilteredTimelineSet().getLiveTimeline().getEvents()) {
|
room
|
||||||
add(mEvent);
|
.getUnfilteredTimelineSet()
|
||||||
}
|
.getLiveTimeline()
|
||||||
|
.getEvents()
|
||||||
|
.forEach((mEvent) => {
|
||||||
|
add(mEvent);
|
||||||
|
});
|
||||||
|
|
||||||
const targetIds = new Set(seen);
|
const targetIds = new Set(seen);
|
||||||
events.push(...collectLocalReplaceEdits(room, targetIds));
|
events.push(...collectLocalReplaceEdits(room, targetIds));
|
||||||
@@ -480,25 +506,6 @@ export function collectLocalThreadEvents(
|
|||||||
return events;
|
return events;
|
||||||
}
|
}
|
||||||
|
|
||||||
function collectLocalReplaceEdits(room: Room, targetIds: Set<string>): IRoomEvent[] {
|
|
||||||
const events: IRoomEvent[] = [];
|
|
||||||
const seen = new Set<string>();
|
|
||||||
|
|
||||||
for (const mEvent of room.getUnfilteredTimelineSet().getLiveTimeline().getEvents()) {
|
|
||||||
if (mEvent.isRedacted() || mEvent.getType() !== EventType.RoomMessage) continue;
|
|
||||||
const relation = mEvent.getRelation();
|
|
||||||
if (relation?.rel_type !== RelationType.Replace) continue;
|
|
||||||
const targetId = relation.event_id;
|
|
||||||
if (!targetId || !targetIds.has(targetId)) continue;
|
|
||||||
const id = mEvent.getId();
|
|
||||||
if (!id || seen.has(id)) continue;
|
|
||||||
seen.add(id);
|
|
||||||
events.push(matrixEventToRoomEvent(mEvent));
|
|
||||||
}
|
|
||||||
|
|
||||||
return events;
|
|
||||||
}
|
|
||||||
|
|
||||||
function collectLocalRootPosts(mx: MatrixClient, roomId: string): IRoomEvent[] {
|
function collectLocalRootPosts(mx: MatrixClient, roomId: string): IRoomEvent[] {
|
||||||
const room = mx.getRoom(roomId);
|
const room = mx.getRoom(roomId);
|
||||||
if (!room) return [];
|
if (!room) return [];
|
||||||
@@ -506,18 +513,22 @@ function collectLocalRootPosts(mx: MatrixClient, roomId: string): IRoomEvent[] {
|
|||||||
const seen = new Set<string>();
|
const seen = new Set<string>();
|
||||||
const events: IRoomEvent[] = [];
|
const events: IRoomEvent[] = [];
|
||||||
|
|
||||||
for (const mEvent of room.getUnfilteredTimelineSet().getLiveTimeline().getEvents()) {
|
room
|
||||||
if (mEvent.isRedacted() || mEvent.getType() !== EventType.RoomMessage) continue;
|
.getUnfilteredTimelineSet()
|
||||||
if (isSecondaryMatrixEvent(mEvent)) continue;
|
.getLiveTimeline()
|
||||||
const relation = threadRelationFromContent(mEvent.getContent());
|
.getEvents()
|
||||||
const isThreadReply =
|
.forEach((mEvent) => {
|
||||||
relation?.rel_type === RelationType.Thread || relation?.rel_type === 'm.thread';
|
if (mEvent.isRedacted() || mEvent.getType() !== EventType.RoomMessage) return;
|
||||||
if (isThreadReply) continue;
|
if (isSecondaryMatrixEvent(mEvent)) return;
|
||||||
const id = mEvent.getId();
|
const relation = threadRelationFromContent(mEvent.getContent());
|
||||||
if (!id || seen.has(id)) continue;
|
const isThreadReply =
|
||||||
seen.add(id);
|
relation?.rel_type === RelationType.Thread || relation?.rel_type === 'm.thread';
|
||||||
events.push(matrixEventToRoomEvent(mEvent));
|
if (isThreadReply) return;
|
||||||
}
|
const id = mEvent.getId();
|
||||||
|
if (!id || seen.has(id)) return;
|
||||||
|
seen.add(id);
|
||||||
|
events.push(matrixEventToRoomEvent(mEvent));
|
||||||
|
});
|
||||||
|
|
||||||
const rootIds = new Set(events.map((event) => event.event_id).filter(Boolean) as string[]);
|
const rootIds = new Set(events.map((event) => event.event_id).filter(Boolean) as string[]);
|
||||||
events.push(...collectLocalReplaceEdits(room, rootIds));
|
events.push(...collectLocalReplaceEdits(room, rootIds));
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import { applyTopicStatusSort, filterPostsBySearch, parseTopicSearchQuery } from
|
|||||||
|
|
||||||
export function countAllReplies(replies: ForumPost[] | undefined): number {
|
export function countAllReplies(replies: ForumPost[] | undefined): number {
|
||||||
let total = 0;
|
let total = 0;
|
||||||
for (const reply of replies || []) {
|
(replies || []).forEach((reply) => {
|
||||||
total += 1;
|
total += 1;
|
||||||
total += countAllReplies(reply.replies);
|
total += countAllReplies(reply.replies);
|
||||||
}
|
});
|
||||||
return total;
|
return total;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,9 +15,10 @@ export function maxThreadTimestamp(post: ForumPost): number {
|
|||||||
const stack = [...(post.replies || [])];
|
const stack = [...(post.replies || [])];
|
||||||
while (stack.length > 0) {
|
while (stack.length > 0) {
|
||||||
const current = stack.pop();
|
const current = stack.pop();
|
||||||
if (!current) continue;
|
if (current) {
|
||||||
if (current.timestamp > maxValue) maxValue = current.timestamp;
|
if (current.timestamp > maxValue) maxValue = current.timestamp;
|
||||||
if (current.replies?.length) stack.push(...current.replies);
|
if (current.replies?.length) stack.push(...current.replies);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return maxValue;
|
return maxValue;
|
||||||
}
|
}
|
||||||
@@ -54,7 +55,7 @@ export function buildForumSections(topics: ForumTopic[]): ForumSection[] {
|
|||||||
const postableTopics = topics.filter((topic) => !topic.isSpace);
|
const postableTopics = topics.filter((topic) => !topic.isSpace);
|
||||||
const sections: ForumSection[] = [];
|
const sections: ForumSection[] = [];
|
||||||
|
|
||||||
for (const space of spaces) {
|
spaces.forEach((space) => {
|
||||||
const childTopics = postableTopics.filter((topic) => topic.parentRoomId === space.roomId);
|
const childTopics = postableTopics.filter((topic) => topic.parentRoomId === space.roomId);
|
||||||
|
|
||||||
sections.push({
|
sections.push({
|
||||||
@@ -63,7 +64,7 @@ export function buildForumSections(topics: ForumTopic[]): ForumSection[] {
|
|||||||
description: space.topic || null,
|
description: space.topic || null,
|
||||||
topics: childTopics.sort((a, b) => a.name.localeCompare(b.name)),
|
topics: childTopics.sort((a, b) => a.name.localeCompare(b.name)),
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
const coveredTopicIds = new Set(
|
const coveredTopicIds = new Set(
|
||||||
sections.flatMap((section) => section.topics.map((topic) => topic.roomId)),
|
sections.flatMap((section) => section.topics.map((topic) => topic.roomId)),
|
||||||
|
|||||||
@@ -142,15 +142,15 @@ export function collectAuthorHintsFromThreads(
|
|||||||
): TopicSearchAuthorHint[] {
|
): TopicSearchAuthorHint[] {
|
||||||
const map = new Map<string, TopicSearchAuthorHint>();
|
const map = new Map<string, TopicSearchAuthorHint>();
|
||||||
|
|
||||||
for (const thread of threads) {
|
threads.forEach((thread) => {
|
||||||
const userId = thread.sender;
|
const userId = thread.sender;
|
||||||
if (!userId || map.has(userId)) {
|
if (!userId || map.has(userId)) {
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
const localpart = userId.startsWith('@') ? userId.slice(1).split(':')[0] : userId;
|
const localpart = userId.startsWith('@') ? userId.slice(1).split(':')[0] : userId;
|
||||||
const displayName = (thread.senderDisplayName || localpart).trim() || localpart;
|
const displayName = (thread.senderDisplayName || localpart).trim() || localpart;
|
||||||
map.set(userId, { userId, displayName, localpart });
|
map.set(userId, { userId, displayName, localpart });
|
||||||
}
|
});
|
||||||
|
|
||||||
return [...map.values()].sort(
|
return [...map.values()].sort(
|
||||||
(a, b) => a.displayName.localeCompare(b.displayName) || a.localpart.localeCompare(b.localpart),
|
(a, b) => a.displayName.localeCompare(b.displayName) || a.localpart.localeCompare(b.localpart),
|
||||||
@@ -159,12 +159,12 @@ export function collectAuthorHintsFromThreads(
|
|||||||
|
|
||||||
export function collectTitleHintsFromThreads(threads: Array<{ title: string }>): string[] {
|
export function collectTitleHintsFromThreads(threads: Array<{ title: string }>): string[] {
|
||||||
const titles = new Set<string>();
|
const titles = new Set<string>();
|
||||||
for (const thread of threads) {
|
threads.forEach((thread) => {
|
||||||
const title = String(thread.title || '').trim();
|
const title = String(thread.title || '').trim();
|
||||||
if (title) {
|
if (title) {
|
||||||
titles.add(title);
|
titles.add(title);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return [...titles].sort((a, b) => a.localeCompare(b));
|
return [...titles].sort((a, b) => a.localeCompare(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,31 +221,31 @@ function escapeRegex(value: string): string {
|
|||||||
function collectTerms(qualifiers: ParsedTopicSearch['qualifiers'], freeText: string): string[] {
|
function collectTerms(qualifiers: ParsedTopicSearch['qualifiers'], freeText: string): string[] {
|
||||||
const terms = new Set<string>();
|
const terms = new Set<string>();
|
||||||
|
|
||||||
for (const list of Object.values(qualifiers)) {
|
Object.values(qualifiers).forEach((list) => {
|
||||||
for (const value of list) {
|
list.forEach((value) => {
|
||||||
const trimmed = String(value || '').trim();
|
const trimmed = String(value || '').trim();
|
||||||
if (trimmed) {
|
if (trimmed) {
|
||||||
terms.add(trimmed.toLowerCase());
|
terms.add(trimmed.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
if (freeText) {
|
if (freeText) {
|
||||||
const quoted = [...freeText.matchAll(/"([^"]+)"/g)].map((match) => match[1]);
|
const quoted = [...freeText.matchAll(/"([^"]+)"/g)].map((match) => match[1]);
|
||||||
let scratch = freeText;
|
let scratch = freeText;
|
||||||
for (const phrase of quoted) {
|
quoted.forEach((phrase) => {
|
||||||
if (phrase.trim()) {
|
if (phrase.trim()) {
|
||||||
terms.add(phrase.trim().toLowerCase());
|
terms.add(phrase.trim().toLowerCase());
|
||||||
}
|
}
|
||||||
scratch = scratch.replace(`"${phrase}"`, ' ');
|
scratch = scratch.replace(`"${phrase}"`, ' ');
|
||||||
}
|
});
|
||||||
|
|
||||||
for (const word of scratch.split(/\s+/)) {
|
scratch.split(/\s+/).forEach((word) => {
|
||||||
const trimmed = word.trim();
|
const trimmed = word.trim();
|
||||||
if (trimmed) {
|
if (trimmed) {
|
||||||
terms.add(trimmed.toLowerCase());
|
terms.add(trimmed.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return [...terms];
|
return [...terms];
|
||||||
@@ -306,10 +306,10 @@ function nodeText(node: ForumPost): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function walkReplyTree(node: ForumPost, visit: (node: ForumPost) => void): void {
|
function walkReplyTree(node: ForumPost, visit: (node: ForumPost) => void): void {
|
||||||
for (const reply of node.replies || []) {
|
(node.replies || []).forEach((reply) => {
|
||||||
visit(reply);
|
visit(reply);
|
||||||
walkReplyTree(reply, visit);
|
walkReplyTree(reply, visit);
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function termsMatchAll(terms: string[], haystack: string): boolean {
|
function termsMatchAll(terms: string[], haystack: string): boolean {
|
||||||
@@ -426,10 +426,10 @@ export function highlightSearchTerms(text: string, terms: string[]): string {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let result = text;
|
let result = text;
|
||||||
for (const term of usable) {
|
usable.forEach((term) => {
|
||||||
const re = new RegExp(`(${escapeRegex(term)})`, 'gi');
|
const re = new RegExp(`(${escapeRegex(term)})`, 'gi');
|
||||||
result = result.replace(re, '<mark class="search-hit">$1</mark>');
|
result = result.replace(re, '<mark class="search-hit">$1</mark>');
|
||||||
}
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,10 +152,6 @@ const useCanDropLobbyItem = (
|
|||||||
return canDrop;
|
return canDrop;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function Lobby() {
|
|
||||||
return <SpaceCardLobby />;
|
|
||||||
}
|
|
||||||
|
|
||||||
function SpaceCardLobby() {
|
function SpaceCardLobby() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
@@ -611,3 +607,6 @@ function SpaceCardLobby() {
|
|||||||
</PowerLevelsContextProvider>
|
</PowerLevelsContextProvider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
export function Lobby() {
|
||||||
|
return <SpaceCardLobby />;
|
||||||
|
}
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ export function LobbyHeader({ showProfile, showSpaceToolbar, powerLevels }: Lobb
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!showSpaceToolbar || !menuAnchor || addExisting) return;
|
if (!showSpaceToolbar || !menuAnchor || addExisting) return undefined;
|
||||||
|
|
||||||
let outsideTimer: number | undefined;
|
let outsideTimer: number | undefined;
|
||||||
const clearOutsideTimer = () => {
|
const clearOutsideTimer = () => {
|
||||||
|
|||||||
@@ -128,16 +128,16 @@ const searchLocalRoomTimeline = (room: Room, term: string): ResultItem[] => {
|
|||||||
for (let i = events.length - 1; i >= 0; i -= 1) {
|
for (let i = events.length - 1; i >= 0; i -= 1) {
|
||||||
const event = events[i];
|
const event = events[i];
|
||||||
const haystack = getSearchableBody(event);
|
const haystack = getSearchableBody(event);
|
||||||
if (!haystack || !haystack.toLowerCase().includes(needle)) continue;
|
if (haystack && haystack.toLowerCase().includes(needle)) {
|
||||||
|
const searchEvent = eventToSearchEvent(event, room.roomId);
|
||||||
const searchEvent = eventToSearchEvent(event, room.roomId);
|
if (searchEvent) {
|
||||||
if (!searchEvent) continue;
|
matches.push({
|
||||||
|
rank: 1,
|
||||||
matches.push({
|
event: searchEvent,
|
||||||
rank: 1,
|
context: EMPTY_CONTEXT,
|
||||||
event: searchEvent,
|
});
|
||||||
context: EMPTY_CONTEXT,
|
}
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches;
|
return matches;
|
||||||
|
|||||||
@@ -30,19 +30,6 @@ type EmojiConfettiBurstCanvasProps = {
|
|||||||
onComplete: (burstId: string) => void;
|
onComplete: (burstId: string) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function EmojiConfettiBurstCanvas({ burst, onComplete }: EmojiConfettiBurstCanvasProps) {
|
|
||||||
const primaryEmoji = burst.emojis[0] ?? '🎉';
|
|
||||||
const fullscreen = isFullscreenBurstEmoji(primaryEmoji);
|
|
||||||
|
|
||||||
if (fullscreen) {
|
|
||||||
return (
|
|
||||||
<FireworkBurstCanvas burst={burst} primaryEmoji={primaryEmoji} onComplete={onComplete} />
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return <LocalBurstCanvas burst={burst} primaryEmoji={primaryEmoji} onComplete={onComplete} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
type BurstCanvasProps = {
|
type BurstCanvasProps = {
|
||||||
burst: EmojiConfettiBurst;
|
burst: EmojiConfettiBurst;
|
||||||
primaryEmoji: string;
|
primaryEmoji: string;
|
||||||
@@ -387,3 +374,15 @@ function LocalBurstCanvas({ burst, primaryEmoji, onComplete }: BurstCanvasProps)
|
|||||||
document.body,
|
document.body,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
export function EmojiConfettiBurstCanvas({ burst, onComplete }: EmojiConfettiBurstCanvasProps) {
|
||||||
|
const primaryEmoji = burst.emojis[0] ?? '🎉';
|
||||||
|
const fullscreen = isFullscreenBurstEmoji(primaryEmoji);
|
||||||
|
|
||||||
|
if (fullscreen) {
|
||||||
|
return (
|
||||||
|
<FireworkBurstCanvas burst={burst} primaryEmoji={primaryEmoji} onComplete={onComplete} />
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <LocalBurstCanvas burst={burst} primaryEmoji={primaryEmoji} onComplete={onComplete} />;
|
||||||
|
}
|
||||||
|
|||||||
@@ -239,30 +239,28 @@ export function stepBurstParticles(
|
|||||||
const particle = particles[i];
|
const particle = particles[i];
|
||||||
const burstElapsed = now - particle.burstStartMs;
|
const burstElapsed = now - particle.burstStartMs;
|
||||||
|
|
||||||
|
const ageMs = now - particle.bornAt;
|
||||||
|
|
||||||
if (burstElapsed > BURST_TOTAL_MS) {
|
if (burstElapsed > BURST_TOTAL_MS) {
|
||||||
particles[i] = particles[particles.length - 1];
|
particles[i] = particles[particles.length - 1];
|
||||||
particles.pop();
|
particles.pop();
|
||||||
continue;
|
} else if (ageMs >= 0) {
|
||||||
|
const dragFactor = particle.drag ** (dtSeconds * 60);
|
||||||
|
|
||||||
|
switch (particle.style) {
|
||||||
|
case 'spiral':
|
||||||
|
stepSpiralParticle(particle, dtSeconds);
|
||||||
|
break;
|
||||||
|
case 'bounce':
|
||||||
|
stepBounceParticle(particle, dtSeconds, dragFactor);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
stepDefaultParticle(particle, dtSeconds, dragFactor);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
particle.phase += dtSeconds * (particle.twinkle ? 9 : 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
const ageMs = now - particle.bornAt;
|
|
||||||
if (ageMs < 0) continue;
|
|
||||||
|
|
||||||
const dragFactor = particle.drag ** (dtSeconds * 60);
|
|
||||||
|
|
||||||
switch (particle.style) {
|
|
||||||
case 'spiral':
|
|
||||||
stepSpiralParticle(particle, dtSeconds);
|
|
||||||
break;
|
|
||||||
case 'bounce':
|
|
||||||
stepBounceParticle(particle, dtSeconds, dragFactor);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
stepDefaultParticle(particle, dtSeconds, dragFactor);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
particle.phase += dtSeconds * (particle.twinkle ? 9 : 5);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -333,9 +331,9 @@ export function drawBurstParticles(
|
|||||||
dpr: number,
|
dpr: number,
|
||||||
now: number,
|
now: number,
|
||||||
) {
|
) {
|
||||||
for (const particle of particles) {
|
particles.forEach((particle) => {
|
||||||
const state = particleDrawState(particle, now);
|
const state = particleDrawState(particle, now);
|
||||||
if (!state) continue;
|
if (!state) return;
|
||||||
|
|
||||||
context.globalAlpha = state.opacity;
|
context.globalAlpha = state.opacity;
|
||||||
|
|
||||||
@@ -348,7 +346,7 @@ export function drawBurstParticles(
|
|||||||
|
|
||||||
context.setTransform(cos, sin, -sin, cos, state.x * dpr, state.y * dpr);
|
context.setTransform(cos, sin, -sin, cos, state.x * dpr, state.y * dpr);
|
||||||
context.drawImage(emojiCanvas, -halfSize, -halfSize, drawSize, drawSize);
|
context.drawImage(emojiCanvas, -halfSize, -halfSize, drawSize, drawSize);
|
||||||
}
|
});
|
||||||
|
|
||||||
context.globalAlpha = 1;
|
context.globalAlpha = 1;
|
||||||
context.setTransform(dpr, 0, 0, dpr, 0, 0);
|
context.setTransform(dpr, 0, 0, dpr, 0, 0);
|
||||||
|
|||||||
@@ -94,10 +94,6 @@ type EmojiBitmap = {
|
|||||||
canvasScale: number;
|
canvasScale: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
function getEmojiCanvas(emoji: string, tintColor?: string, cssPx?: number): HTMLCanvasElement {
|
|
||||||
return getEmojiBitmap(emoji, tintColor, cssPx, 0).canvas;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEmojiBitmap(
|
function getEmojiBitmap(
|
||||||
emoji: string,
|
emoji: string,
|
||||||
tintColor: string | undefined,
|
tintColor: string | undefined,
|
||||||
@@ -138,6 +134,10 @@ function getEmojiBitmap(
|
|||||||
return { canvas, canvasScale: size / Math.max(fontPx, 1) };
|
return { canvas, canvasScale: size / Math.max(fontPx, 1) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getEmojiCanvas(emoji: string, tintColor?: string, cssPx?: number): HTMLCanvasElement {
|
||||||
|
return getEmojiBitmap(emoji, tintColor, cssPx, 0).canvas;
|
||||||
|
}
|
||||||
|
|
||||||
function setHeroEmoji(hero: HeroFace, emoji: string) {
|
function setHeroEmoji(hero: HeroFace, emoji: string) {
|
||||||
const bitmap = getEmojiBitmap(emoji, undefined, hero.drawSize, HERO_PAD_RATIO);
|
const bitmap = getEmojiBitmap(emoji, undefined, hero.drawSize, HERO_PAD_RATIO);
|
||||||
hero.emoji = emoji;
|
hero.emoji = emoji;
|
||||||
@@ -288,14 +288,14 @@ function settleParticle(sim: FireworkSim, p: FireworkParticle) {
|
|||||||
// Prefer the intended column; spill to neighbors if that stack is already tall.
|
// Prefer the intended column; spill to neighbors if that stack is already tall.
|
||||||
let bestCol = col;
|
let bestCol = col;
|
||||||
let bestH = sim.pileCols[col];
|
let bestH = sim.pileCols[col];
|
||||||
for (const delta of [0, -1, 1, -2, 2]) {
|
[0, -1, 1, -2, 2].forEach((delta) => {
|
||||||
const c = col + delta;
|
const c = col + delta;
|
||||||
if (c < 0 || c >= cols) continue;
|
if (c < 0 || c >= cols) return;
|
||||||
if (sim.pileCols[c] < bestH) {
|
if (sim.pileCols[c] < bestH) {
|
||||||
bestH = sim.pileCols[c];
|
bestH = sim.pileCols[c];
|
||||||
bestCol = c;
|
bestCol = c;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
const stack = sim.pileCols[bestCol];
|
const stack = sim.pileCols[bestCol];
|
||||||
sim.pileCols[bestCol] = stack + 1;
|
sim.pileCols[bestCol] = stack + 1;
|
||||||
@@ -408,32 +408,32 @@ export function stepFireworkSim(sim: FireworkSim, now: number, dtSeconds: number
|
|||||||
|
|
||||||
for (let i = 0; i < sim.particles.length; i += 1) {
|
for (let i = 0; i < sim.particles.length; i += 1) {
|
||||||
const p = sim.particles[i];
|
const p = sim.particles[i];
|
||||||
if (p.settled) continue;
|
if (!p.settled) {
|
||||||
|
p.vy += g * dt;
|
||||||
|
p.vx *= DRAG;
|
||||||
|
p.vy *= DRAG;
|
||||||
|
p.x += p.vx * dt;
|
||||||
|
p.y += p.vy * dt;
|
||||||
|
p.angle += p.spin * dt;
|
||||||
|
|
||||||
p.vy += g * dt;
|
if (p.x < left) {
|
||||||
p.vx *= DRAG;
|
p.x = left;
|
||||||
p.vy *= DRAG;
|
p.vx = Math.abs(p.vx) * BOUNCE;
|
||||||
p.x += p.vx * dt;
|
} else if (p.x > right) {
|
||||||
p.y += p.vy * dt;
|
p.x = right;
|
||||||
p.angle += p.spin * dt;
|
p.vx = -Math.abs(p.vx) * BOUNCE;
|
||||||
|
}
|
||||||
|
|
||||||
if (p.x < left) {
|
if (p.y >= floor - p.halfSize) {
|
||||||
p.x = left;
|
p.y = floor - p.halfSize;
|
||||||
p.vx = Math.abs(p.vx) * BOUNCE;
|
const speed = Math.hypot(p.vx, p.vy);
|
||||||
} else if (p.x > right) {
|
if (speed < SETTLE_SPEED || Math.abs(p.vy) < SETTLE_SPEED * 0.55) {
|
||||||
p.x = right;
|
settleParticle(sim, p);
|
||||||
p.vx = -Math.abs(p.vx) * BOUNCE;
|
} else {
|
||||||
}
|
p.vy = -Math.abs(p.vy) * BOUNCE;
|
||||||
|
p.vx *= 0.85;
|
||||||
if (p.y >= floor - p.halfSize) {
|
p.spin *= 0.7;
|
||||||
p.y = floor - p.halfSize;
|
}
|
||||||
const speed = Math.hypot(p.vx, p.vy);
|
|
||||||
if (speed < SETTLE_SPEED || Math.abs(p.vy) < SETTLE_SPEED * 0.55) {
|
|
||||||
settleParticle(sim, p);
|
|
||||||
} else {
|
|
||||||
p.vy = -Math.abs(p.vy) * BOUNCE;
|
|
||||||
p.vx *= 0.85;
|
|
||||||
p.spin *= 0.7;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -472,30 +472,30 @@ export function drawFireworkSim(context: CanvasRenderingContext2D, sim: Firework
|
|||||||
|
|
||||||
for (let i = 0; i < sim.particles.length; i += 1) {
|
for (let i = 0; i < sim.particles.length; i += 1) {
|
||||||
const p = sim.particles[i];
|
const p = sim.particles[i];
|
||||||
if (p.settled) continue;
|
if (!p.settled) {
|
||||||
|
const ageMs = now - p.bornAt;
|
||||||
|
if (ageMs >= 0) {
|
||||||
|
let opacity = fade;
|
||||||
|
let scale = 1;
|
||||||
|
if (ageMs < SPARKLE_IN_MS) {
|
||||||
|
const t = ageMs / SPARKLE_IN_MS;
|
||||||
|
const appear = t * t * (3 - 2 * t);
|
||||||
|
scale = 0.5 + 0.65 * appear;
|
||||||
|
opacity *= appear;
|
||||||
|
}
|
||||||
|
if (opacity > 0.02) {
|
||||||
|
const rad = (p.angle * Math.PI) / 180;
|
||||||
|
const size = p.drawSize * scale;
|
||||||
|
const half = size / 2;
|
||||||
|
const cos = Math.cos(rad);
|
||||||
|
const sin = Math.sin(rad);
|
||||||
|
|
||||||
const ageMs = now - p.bornAt;
|
context.globalAlpha = opacity;
|
||||||
if (ageMs < 0) continue;
|
context.setTransform(cos, sin, -sin, cos, p.x, p.y);
|
||||||
|
context.drawImage(p.emojiCanvas, -half, -half, size, size);
|
||||||
let opacity = fade;
|
}
|
||||||
let scale = 1;
|
}
|
||||||
if (ageMs < SPARKLE_IN_MS) {
|
|
||||||
const t = ageMs / SPARKLE_IN_MS;
|
|
||||||
const appear = t * t * (3 - 2 * t);
|
|
||||||
scale = 0.5 + 0.65 * appear;
|
|
||||||
opacity *= appear;
|
|
||||||
}
|
}
|
||||||
if (opacity <= 0.02) continue;
|
|
||||||
|
|
||||||
const rad = (p.angle * Math.PI) / 180;
|
|
||||||
const size = p.drawSize * scale;
|
|
||||||
const half = size / 2;
|
|
||||||
const cos = Math.cos(rad);
|
|
||||||
const sin = Math.sin(rad);
|
|
||||||
|
|
||||||
context.globalAlpha = opacity;
|
|
||||||
context.setTransform(cos, sin, -sin, cos, p.x, p.y);
|
|
||||||
context.drawImage(p.emojiCanvas, -half, -half, size, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
context.globalAlpha = 1;
|
context.globalAlpha = 1;
|
||||||
|
|||||||
@@ -38,18 +38,6 @@ function scheduleBurstFromValues(
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function scheduleBurst(
|
|
||||||
event: MatrixEvent,
|
|
||||||
onBurst: (burst: EmojiConfettiBurst) => void,
|
|
||||||
attempt = 0,
|
|
||||||
) {
|
|
||||||
const eventId = event.getId();
|
|
||||||
if (!eventId) return;
|
|
||||||
|
|
||||||
const { emojis, targetEventId } = parseEmojiConfettiContent(event.getContent());
|
|
||||||
scheduleBurstFromValues(eventId, emojis, targetEventId, onBurst, attempt);
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseEmojiConfettiContent(content: unknown): { emojis: string[]; targetEventId?: string } {
|
function parseEmojiConfettiContent(content: unknown): { emojis: string[]; targetEventId?: string } {
|
||||||
const confettiContent = content as EmojiConfettiContent;
|
const confettiContent = content as EmojiConfettiContent;
|
||||||
const emojis = Array.isArray(confettiContent.emojis)
|
const emojis = Array.isArray(confettiContent.emojis)
|
||||||
@@ -67,6 +55,18 @@ function parseEmojiConfettiContent(content: unknown): { emojis: string[]; target
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function scheduleBurst(
|
||||||
|
event: MatrixEvent,
|
||||||
|
onBurst: (burst: EmojiConfettiBurst) => void,
|
||||||
|
attempt = 0,
|
||||||
|
) {
|
||||||
|
const eventId = event.getId();
|
||||||
|
if (!eventId) return;
|
||||||
|
|
||||||
|
const { emojis, targetEventId } = parseEmojiConfettiContent(event.getContent());
|
||||||
|
scheduleBurstFromValues(eventId, emojis, targetEventId, onBurst, attempt);
|
||||||
|
}
|
||||||
|
|
||||||
export function useEmojiConfetti(room: Room) {
|
export function useEmojiConfetti(room: Room) {
|
||||||
const [bursts, setBursts] = useState<EmojiConfettiBurst[]>([]);
|
const [bursts, setBursts] = useState<EmojiConfettiBurst[]>([]);
|
||||||
const seenEventIdsRef = useRef(new Set<string>());
|
const seenEventIdsRef = useRef(new Set<string>());
|
||||||
|
|||||||
@@ -238,7 +238,7 @@ const formatDayLabel = (ts: number): string => {
|
|||||||
const groupMediaByMonthAndDay = (items: RoomMediaItem[]): MediaMonthGroup[] => {
|
const groupMediaByMonthAndDay = (items: RoomMediaItem[]): MediaMonthGroup[] => {
|
||||||
const months: MediaMonthGroup[] = [];
|
const months: MediaMonthGroup[] = [];
|
||||||
|
|
||||||
for (const item of items) {
|
items.forEach((item) => {
|
||||||
const date = new Date(item.ts);
|
const date = new Date(item.ts);
|
||||||
const monthKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`;
|
const monthKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`;
|
||||||
const dayKey = `${monthKey}-${String(date.getDate()).padStart(2, '0')}`;
|
const dayKey = `${monthKey}-${String(date.getDate()).padStart(2, '0')}`;
|
||||||
@@ -264,7 +264,7 @@ const groupMediaByMonthAndDay = (items: RoomMediaItem[]): MediaMonthGroup[] => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
day.items.push(item);
|
day.items.push(item);
|
||||||
}
|
});
|
||||||
|
|
||||||
return months;
|
return months;
|
||||||
};
|
};
|
||||||
@@ -295,9 +295,9 @@ export const MediaDrawer = as<'div', MediaDrawerProps>(
|
|||||||
|
|
||||||
const senders = useMemo<MediaSenderChip[]>(() => {
|
const senders = useMemo<MediaSenderChip[]>(() => {
|
||||||
const counts = new Map<string, number>();
|
const counts = new Map<string, number>();
|
||||||
for (const item of items) {
|
items.forEach((item) => {
|
||||||
counts.set(item.sender, (counts.get(item.sender) ?? 0) + 1);
|
counts.set(item.sender, (counts.get(item.sender) ?? 0) + 1);
|
||||||
}
|
});
|
||||||
|
|
||||||
return Array.from(counts.entries())
|
return Array.from(counts.entries())
|
||||||
.map(([userId, count]) => ({
|
.map(([userId, count]) => ({
|
||||||
|
|||||||
@@ -177,7 +177,7 @@ export function Settings({ initialPage, requestClose }: SettingsProps) {
|
|||||||
|
|
||||||
// Fallback scroll if the page just mounted and tiles need a moment to render.
|
// Fallback scroll if the page just mounted and tiles need a moment to render.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!focusAnchorId) return;
|
if (!focusAnchorId) return undefined;
|
||||||
let cancelled = false;
|
let cancelled = false;
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -388,11 +388,11 @@ export function CollectiblesSection({ collectibles, onApply }: CollectiblesSecti
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setSelectedByGroup((prev) => {
|
setSelectedByGroup((prev) => {
|
||||||
const next = { ...prev };
|
const next = { ...prev };
|
||||||
for (const group of filteredGroups) {
|
filteredGroups.forEach((group) => {
|
||||||
if (!next[group.id] || !group.items.some((item) => item.skuId === next[group.id])) {
|
if (!next[group.id] || !group.items.some((item) => item.skuId === next[group.id])) {
|
||||||
next[group.id] = group.items[0]?.skuId ?? '';
|
next[group.id] = group.items[0]?.skuId ?? '';
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return next;
|
return next;
|
||||||
});
|
});
|
||||||
}, [filteredGroups]);
|
}, [filteredGroups]);
|
||||||
|
|||||||
@@ -88,10 +88,10 @@ function ProfileBanner({
|
|||||||
const decoration = collectibles.avatar_decoration;
|
const decoration = collectibles.avatar_decoration;
|
||||||
if (!decoration) return undefined;
|
if (!decoration) return undefined;
|
||||||
const assetUrls: Record<string, string | undefined> = {};
|
const assetUrls: Record<string, string | undefined> = {};
|
||||||
for (const [role, mxc] of Object.entries(decoration.assets)) {
|
Object.entries(decoration.assets).forEach(([role, mxc]) => {
|
||||||
assetUrls[`avatar_decoration:${role}`] =
|
assetUrls[`avatar_decoration:${role}`] =
|
||||||
mxcUrlToHttp(mx, mxc, useAuthentication) ?? undefined;
|
mxcUrlToHttp(mx, mxc, useAuthentication) ?? undefined;
|
||||||
}
|
});
|
||||||
return pickAvatarDecorationUrl(assetUrls);
|
return pickAvatarDecorationUrl(assetUrls);
|
||||||
}, [collectibles.avatar_decoration, mx, useAuthentication]);
|
}, [collectibles.avatar_decoration, mx, useAuthentication]);
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ type DeveloperToolsProps = {
|
|||||||
export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
||||||
const mx = useMatrixClient();
|
const mx = useMatrixClient();
|
||||||
const [developerTools, setDeveloperTools] = useSetting(settingsAtom, 'developerTools');
|
const [developerTools, setDeveloperTools] = useSetting(settingsAtom, 'developerTools');
|
||||||
|
const [debugPackets, setDebugPackets] = useSetting(settingsAtom, 'debugPackets');
|
||||||
const [expand, setExpend] = useState(false);
|
const [expand, setExpend] = useState(false);
|
||||||
const [accountDataType, setAccountDataType] = useState<string | null>();
|
const [accountDataType, setAccountDataType] = useState<string | null>();
|
||||||
const [profileExpand, setProfileExpand] = useState(false);
|
const [profileExpand, setProfileExpand] = useState(false);
|
||||||
@@ -162,6 +163,30 @@ export function DeveloperTools({ requestClose }: DeveloperToolsProps) {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
<SettingTile
|
||||||
|
title="Debug Packets"
|
||||||
|
description="Record every Matrix HTTP request and response."
|
||||||
|
after={
|
||||||
|
<Switch variant="Primary" value={debugPackets} onChange={setDebugPackets} />
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
{window.electron?.debug && (
|
||||||
|
<SettingTile
|
||||||
|
title="Packet Window"
|
||||||
|
after={
|
||||||
|
<Button
|
||||||
|
onClick={() => window.electron?.debug?.openWindow()}
|
||||||
|
variant="Secondary"
|
||||||
|
fill="Soft"
|
||||||
|
size="300"
|
||||||
|
radii="300"
|
||||||
|
outlined
|
||||||
|
>
|
||||||
|
<Text size="B300">Open packet window</Text>
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</SequenceCard>
|
</SequenceCard>
|
||||||
{developerTools && (
|
{developerTools && (
|
||||||
<SequenceCard
|
<SequenceCard
|
||||||
|
|||||||
@@ -30,9 +30,9 @@ export function getStoreVersion(): number {
|
|||||||
*/
|
*/
|
||||||
export function dispatchPluginButtonsChanged(): void {
|
export function dispatchPluginButtonsChanged(): void {
|
||||||
storeVersion += 1;
|
storeVersion += 1;
|
||||||
for (const listener of listeners) {
|
listeners.forEach((listener) => {
|
||||||
listener();
|
listener();
|
||||||
}
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
interface PluginButtonSlotProps {
|
interface PluginButtonSlotProps {
|
||||||
|
|||||||
@@ -49,51 +49,47 @@ export function PluginLoader({ matrixClient, children }: PluginLoaderProps) {
|
|||||||
console.error(
|
console.error(
|
||||||
`[PluginLoader] Plugin ${installedPlugin.id} does not export a valid plugin object`,
|
`[PluginLoader] Plugin ${installedPlugin.id} does not export a valid plugin object`,
|
||||||
);
|
);
|
||||||
continue;
|
} else if (typeof plugin.onLoad !== 'function') {
|
||||||
}
|
|
||||||
|
|
||||||
if (typeof plugin.onLoad !== 'function') {
|
|
||||||
console.error(
|
console.error(
|
||||||
`[PluginLoader] Plugin ${installedPlugin.id} does not have an onLoad function`,
|
`[PluginLoader] Plugin ${installedPlugin.id} does not have an onLoad function`,
|
||||||
);
|
);
|
||||||
continue;
|
} else {
|
||||||
}
|
const context = createPluginContext(
|
||||||
|
{
|
||||||
const context = createPluginContext(
|
pluginId: installedPlugin.id,
|
||||||
{
|
eventClient: matrixClient as any,
|
||||||
pluginId: installedPlugin.id,
|
onNotify: async (opts) => {
|
||||||
eventClient: matrixClient as any,
|
await sendNotification({
|
||||||
onNotify: async (opts) => {
|
title: opts.title,
|
||||||
await sendNotification({
|
body: opts.body,
|
||||||
title: opts.title,
|
path: undefined,
|
||||||
body: opts.body,
|
});
|
||||||
path: undefined,
|
},
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
pluginRegistry,
|
||||||
pluginRegistry,
|
);
|
||||||
);
|
|
||||||
|
|
||||||
const compatContext = Object.assign(context as Record<string, unknown>, {
|
const compatContext = Object.assign(context as Record<string, unknown>, {
|
||||||
matrixClient,
|
matrixClient,
|
||||||
matrix: {
|
matrix: {
|
||||||
on: (eventType: string, handler: (...args: unknown[]) => void) =>
|
on: (eventType: string, handler: (...args: unknown[]) => void) =>
|
||||||
matrixClient.on(eventType as any, handler as any),
|
matrixClient.on(eventType as any, handler as any),
|
||||||
off: (eventType: string, handler: (...args: unknown[]) => void) =>
|
off: (eventType: string, handler: (...args: unknown[]) => void) =>
|
||||||
matrixClient.off(eventType as any, handler as any),
|
matrixClient.off(eventType as any, handler as any),
|
||||||
},
|
},
|
||||||
React,
|
React,
|
||||||
lucide,
|
lucide,
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('[PluginLoader] compatContext.React:', !!compatContext.React);
|
console.log('[PluginLoader] compatContext.React:', !!compatContext.React);
|
||||||
console.log('[PluginLoader] compatContext.ui:', !!compatContext.ui);
|
console.log('[PluginLoader] compatContext.ui:', !!compatContext.ui);
|
||||||
console.log('[PluginLoader] About to register plugin and call onLoad...');
|
console.log('[PluginLoader] About to register plugin and call onLoad...');
|
||||||
|
|
||||||
pluginRegistry.registerPlugin(installedPlugin.id, plugin, context);
|
pluginRegistry.registerPlugin(installedPlugin.id, plugin, context);
|
||||||
await plugin.onLoad(compatContext as any);
|
await plugin.onLoad(compatContext as any);
|
||||||
console.log(`[PluginLoader] Successfully loaded plugin: ${installedPlugin.id}`);
|
console.log(`[PluginLoader] Successfully loaded plugin: ${installedPlugin.id}`);
|
||||||
dispatchPluginButtonsChanged();
|
dispatchPluginButtonsChanged();
|
||||||
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`[PluginLoader] Failed to load plugin ${installedPlugin.id}:`, error);
|
console.error(`[PluginLoader] Failed to load plugin ${installedPlugin.id}:`, error);
|
||||||
pluginRegistry.addLog(installedPlugin.id, 'error', ['Failed to load:', error]);
|
pluginRegistry.addLog(installedPlugin.id, 'error', ['Failed to load:', error]);
|
||||||
|
|||||||
@@ -253,6 +253,11 @@ export const SETTINGS_SEARCH_CATALOG: SettingsSearchEntry[] = [
|
|||||||
keywords: ['debug'],
|
keywords: ['debug'],
|
||||||
},
|
},
|
||||||
{ page: SettingsPages.DeveloperToolsPage, title: 'Access Token', keywords: ['auth', 'secret'] },
|
{ page: SettingsPages.DeveloperToolsPage, title: 'Access Token', keywords: ['auth', 'secret'] },
|
||||||
|
{
|
||||||
|
page: SettingsPages.DeveloperToolsPage,
|
||||||
|
title: 'Debug Packets',
|
||||||
|
keywords: ['http', 'network', 'request', 'response'],
|
||||||
|
},
|
||||||
{ page: SettingsPages.DeveloperToolsPage, title: 'Account Data', keywords: ['global', 'events'] },
|
{ page: SettingsPages.DeveloperToolsPage, title: 'Account Data', keywords: ['global', 'events'] },
|
||||||
{
|
{
|
||||||
page: SettingsPages.DeveloperToolsPage,
|
page: SettingsPages.DeveloperToolsPage,
|
||||||
|
|||||||
@@ -115,93 +115,93 @@ export function Permissions({ requestClose }: PermissionsProps) {
|
|||||||
for (const childId of syncableChildren) {
|
for (const childId of syncableChildren) {
|
||||||
try {
|
try {
|
||||||
const childRoom = mx.getRoom(childId);
|
const childRoom = mx.getRoom(childId);
|
||||||
if (!childRoom) continue;
|
if (childRoom) {
|
||||||
|
// Get current power levels in the child room
|
||||||
// Get current power levels in the child room
|
const childPowerLevelsEvent = childRoom.currentState.getStateEvents(
|
||||||
const childPowerLevelsEvent = childRoom.currentState.getStateEvents(
|
StateEvent.RoomPowerLevels,
|
||||||
StateEvent.RoomPowerLevels,
|
'',
|
||||||
'',
|
|
||||||
);
|
|
||||||
const childPowerLevels = childPowerLevelsEvent?.getContent() || {};
|
|
||||||
|
|
||||||
// Get my power level in the child room
|
|
||||||
const myPowerInChild =
|
|
||||||
childPowerLevels.users?.[myUserId] ?? childPowerLevels.users_default ?? 0;
|
|
||||||
|
|
||||||
// Build merged users: only sync users with power <= mine, preserve higher-powered users
|
|
||||||
const mergedUsers: Record<string, number> = {};
|
|
||||||
|
|
||||||
// Copy users from parent where power <= my power in child
|
|
||||||
if (powerLevels.users) {
|
|
||||||
Object.entries(powerLevels.users).forEach(([userId, power]) => {
|
|
||||||
if (power <= myPowerInChild) {
|
|
||||||
mergedUsers[userId] = power;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preserve all users in child room who have power >= mine
|
|
||||||
if (childPowerLevels.users) {
|
|
||||||
Object.entries(childPowerLevels.users).forEach(([userId, power]) => {
|
|
||||||
if (power >= myPowerInChild) {
|
|
||||||
mergedUsers[userId] = power;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cap all power level values at my power level
|
|
||||||
const capPowerLevel = (value: any) => {
|
|
||||||
if (typeof value === 'number') {
|
|
||||||
return Math.min(value, myPowerInChild);
|
|
||||||
}
|
|
||||||
return value;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create the merged power levels with capped values
|
|
||||||
const mergedPowerLevels: any = {
|
|
||||||
...powerLevels,
|
|
||||||
users: mergedUsers,
|
|
||||||
ban: capPowerLevel(powerLevels.ban),
|
|
||||||
kick: capPowerLevel(powerLevels.kick),
|
|
||||||
redact: capPowerLevel(powerLevels.redact),
|
|
||||||
invite: capPowerLevel(powerLevels.invite),
|
|
||||||
events_default: capPowerLevel(powerLevels.events_default),
|
|
||||||
state_default: capPowerLevel(powerLevels.state_default),
|
|
||||||
users_default: capPowerLevel(powerLevels.users_default),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Cap event-specific power levels
|
|
||||||
if (powerLevels.events) {
|
|
||||||
mergedPowerLevels.events = {};
|
|
||||||
Object.entries(powerLevels.events).forEach(([eventType, power]) => {
|
|
||||||
mergedPowerLevels.events[eventType] = capPowerLevel(power);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cap notification power levels
|
|
||||||
if (powerLevels.notifications) {
|
|
||||||
mergedPowerLevels.notifications = {};
|
|
||||||
Object.entries(powerLevels.notifications).forEach(([key, power]) => {
|
|
||||||
mergedPowerLevels.notifications[key] = capPowerLevel(power);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
await mx.sendStateEvent(childId, StateEvent.RoomPowerLevels as any, mergedPowerLevels);
|
|
||||||
|
|
||||||
// Also copy power level tags if they exist
|
|
||||||
if (powerLevelTags) {
|
|
||||||
await mx.sendStateEvent(
|
|
||||||
childId,
|
|
||||||
'in.cinny.room.power_level_tags' as any,
|
|
||||||
powerLevelTags,
|
|
||||||
);
|
);
|
||||||
}
|
const childPowerLevels = childPowerLevelsEvent?.getContent() || {};
|
||||||
|
|
||||||
completed += 1;
|
// Get my power level in the child room
|
||||||
|
const myPowerInChild =
|
||||||
|
childPowerLevels.users?.[myUserId] ?? childPowerLevels.users_default ?? 0;
|
||||||
|
|
||||||
// Add a small delay to avoid rate limiting
|
// Build merged users: only sync users with power <= mine, preserve higher-powered users
|
||||||
if (completed < total) {
|
const mergedUsers: Record<string, number> = {};
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
||||||
|
// Copy users from parent where power <= my power in child
|
||||||
|
if (powerLevels.users) {
|
||||||
|
Object.entries(powerLevels.users).forEach(([userId, power]) => {
|
||||||
|
if (power <= myPowerInChild) {
|
||||||
|
mergedUsers[userId] = power;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preserve all users in child room who have power >= mine
|
||||||
|
if (childPowerLevels.users) {
|
||||||
|
Object.entries(childPowerLevels.users).forEach(([userId, power]) => {
|
||||||
|
if (power >= myPowerInChild) {
|
||||||
|
mergedUsers[userId] = power;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cap all power level values at my power level
|
||||||
|
const capPowerLevel = (value: any) => {
|
||||||
|
if (typeof value === 'number') {
|
||||||
|
return Math.min(value, myPowerInChild);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Create the merged power levels with capped values
|
||||||
|
const mergedPowerLevels: any = {
|
||||||
|
...powerLevels,
|
||||||
|
users: mergedUsers,
|
||||||
|
ban: capPowerLevel(powerLevels.ban),
|
||||||
|
kick: capPowerLevel(powerLevels.kick),
|
||||||
|
redact: capPowerLevel(powerLevels.redact),
|
||||||
|
invite: capPowerLevel(powerLevels.invite),
|
||||||
|
events_default: capPowerLevel(powerLevels.events_default),
|
||||||
|
state_default: capPowerLevel(powerLevels.state_default),
|
||||||
|
users_default: capPowerLevel(powerLevels.users_default),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Cap event-specific power levels
|
||||||
|
if (powerLevels.events) {
|
||||||
|
mergedPowerLevels.events = {};
|
||||||
|
Object.entries(powerLevels.events).forEach(([eventType, power]) => {
|
||||||
|
mergedPowerLevels.events[eventType] = capPowerLevel(power);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cap notification power levels
|
||||||
|
if (powerLevels.notifications) {
|
||||||
|
mergedPowerLevels.notifications = {};
|
||||||
|
Object.entries(powerLevels.notifications).forEach(([key, power]) => {
|
||||||
|
mergedPowerLevels.notifications[key] = capPowerLevel(power);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await mx.sendStateEvent(childId, StateEvent.RoomPowerLevels as any, mergedPowerLevels);
|
||||||
|
|
||||||
|
// Also copy power level tags if they exist
|
||||||
|
if (powerLevelTags) {
|
||||||
|
await mx.sendStateEvent(
|
||||||
|
childId,
|
||||||
|
'in.cinny.room.power_level_tags' as any,
|
||||||
|
powerLevelTags,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
completed += 1;
|
||||||
|
|
||||||
|
// Add a small delay to avoid rate limiting
|
||||||
|
if (completed < total) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to sync permissions to ${childId}:`, error);
|
console.error(`Failed to sync permissions to ${childId}:`, error);
|
||||||
@@ -221,84 +221,84 @@ export function Permissions({ requestClose }: PermissionsProps) {
|
|||||||
for (const childId of syncableChildren) {
|
for (const childId of syncableChildren) {
|
||||||
try {
|
try {
|
||||||
const childRoom = mx.getRoom(childId);
|
const childRoom = mx.getRoom(childId);
|
||||||
if (!childRoom) continue;
|
if (childRoom) {
|
||||||
|
// Get current power levels in the child room
|
||||||
|
const childPowerLevelsEvent = childRoom.currentState.getStateEvents(
|
||||||
|
StateEvent.RoomPowerLevels,
|
||||||
|
'',
|
||||||
|
);
|
||||||
|
const childPowerLevels = childPowerLevelsEvent?.getContent() || {};
|
||||||
|
|
||||||
// Get current power levels in the child room
|
// Get my power level in the child room
|
||||||
const childPowerLevelsEvent = childRoom.currentState.getStateEvents(
|
const myPowerInChild =
|
||||||
StateEvent.RoomPowerLevels,
|
childPowerLevels.users?.[myUserId] ?? childPowerLevels.users_default ?? 0;
|
||||||
'',
|
|
||||||
);
|
|
||||||
const childPowerLevels = childPowerLevelsEvent?.getContent() || {};
|
|
||||||
|
|
||||||
// Get my power level in the child room
|
// Build merged users: only sync users with power <= mine, preserve higher-powered users
|
||||||
const myPowerInChild =
|
const mergedUsers: Record<string, number> = {};
|
||||||
childPowerLevels.users?.[myUserId] ?? childPowerLevels.users_default ?? 0;
|
|
||||||
|
|
||||||
// Build merged users: only sync users with power <= mine, preserve higher-powered users
|
// Copy users from parent where power <= my power in child
|
||||||
const mergedUsers: Record<string, number> = {};
|
if (powerLevels.users) {
|
||||||
|
Object.entries(powerLevels.users).forEach(([userId, power]) => {
|
||||||
// Copy users from parent where power <= my power in child
|
if (power <= myPowerInChild) {
|
||||||
if (powerLevels.users) {
|
mergedUsers[userId] = power;
|
||||||
Object.entries(powerLevels.users).forEach(([userId, power]) => {
|
}
|
||||||
if (power <= myPowerInChild) {
|
});
|
||||||
mergedUsers[userId] = power;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preserve all users in child room who have power >= mine
|
|
||||||
if (childPowerLevels.users) {
|
|
||||||
Object.entries(childPowerLevels.users).forEach(([userId, power]) => {
|
|
||||||
if (power >= myPowerInChild) {
|
|
||||||
mergedUsers[userId] = power;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cap all power level values at my power level
|
|
||||||
const capPowerLevel = (value: any) => {
|
|
||||||
if (typeof value === 'number') {
|
|
||||||
return Math.min(value, myPowerInChild);
|
|
||||||
}
|
}
|
||||||
return value;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create the merged power levels with capped values
|
// Preserve all users in child room who have power >= mine
|
||||||
const mergedPowerLevels: any = {
|
if (childPowerLevels.users) {
|
||||||
...powerLevels,
|
Object.entries(childPowerLevels.users).forEach(([userId, power]) => {
|
||||||
users: mergedUsers,
|
if (power >= myPowerInChild) {
|
||||||
ban: capPowerLevel(powerLevels.ban),
|
mergedUsers[userId] = power;
|
||||||
kick: capPowerLevel(powerLevels.kick),
|
}
|
||||||
redact: capPowerLevel(powerLevels.redact),
|
});
|
||||||
invite: capPowerLevel(powerLevels.invite),
|
}
|
||||||
events_default: capPowerLevel(powerLevels.events_default),
|
|
||||||
state_default: capPowerLevel(powerLevels.state_default),
|
|
||||||
users_default: capPowerLevel(powerLevels.users_default),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Cap event-specific power levels
|
// Cap all power level values at my power level
|
||||||
if (powerLevels.events) {
|
const capPowerLevel = (value: any) => {
|
||||||
mergedPowerLevels.events = {};
|
if (typeof value === 'number') {
|
||||||
Object.entries(powerLevels.events).forEach(([eventType, power]) => {
|
return Math.min(value, myPowerInChild);
|
||||||
mergedPowerLevels.events[eventType] = capPowerLevel(power);
|
}
|
||||||
});
|
return value;
|
||||||
}
|
};
|
||||||
|
|
||||||
// Cap notification power levels
|
// Create the merged power levels with capped values
|
||||||
if (powerLevels.notifications) {
|
const mergedPowerLevels: any = {
|
||||||
mergedPowerLevels.notifications = {};
|
...powerLevels,
|
||||||
Object.entries(powerLevels.notifications).forEach(([key, power]) => {
|
users: mergedUsers,
|
||||||
mergedPowerLevels.notifications[key] = capPowerLevel(power);
|
ban: capPowerLevel(powerLevels.ban),
|
||||||
});
|
kick: capPowerLevel(powerLevels.kick),
|
||||||
}
|
redact: capPowerLevel(powerLevels.redact),
|
||||||
|
invite: capPowerLevel(powerLevels.invite),
|
||||||
|
events_default: capPowerLevel(powerLevels.events_default),
|
||||||
|
state_default: capPowerLevel(powerLevels.state_default),
|
||||||
|
users_default: capPowerLevel(powerLevels.users_default),
|
||||||
|
};
|
||||||
|
|
||||||
await mx.sendStateEvent(childId, StateEvent.RoomPowerLevels as any, mergedPowerLevels);
|
// Cap event-specific power levels
|
||||||
|
if (powerLevels.events) {
|
||||||
|
mergedPowerLevels.events = {};
|
||||||
|
Object.entries(powerLevels.events).forEach(([eventType, power]) => {
|
||||||
|
mergedPowerLevels.events[eventType] = capPowerLevel(power);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
completed += 1;
|
// Cap notification power levels
|
||||||
|
if (powerLevels.notifications) {
|
||||||
|
mergedPowerLevels.notifications = {};
|
||||||
|
Object.entries(powerLevels.notifications).forEach(([key, power]) => {
|
||||||
|
mergedPowerLevels.notifications[key] = capPowerLevel(power);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
// Add a small delay to avoid rate limiting
|
await mx.sendStateEvent(childId, StateEvent.RoomPowerLevels as any, mergedPowerLevels);
|
||||||
if (completed < total) {
|
|
||||||
await new Promise((resolve) => setTimeout(resolve, 100));
|
completed += 1;
|
||||||
|
|
||||||
|
// Add a small delay to avoid rate limiting
|
||||||
|
if (completed < total) {
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 100));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`Failed to sync power levels to ${childId}:`, error);
|
console.error(`Failed to sync power levels to ${childId}:`, error);
|
||||||
|
|||||||
@@ -268,13 +268,13 @@ export function useAutoJoinOnSpaceVisit(space: Room | undefined): void {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!space || !settings.autoJoinSpaceRooms) {
|
if (!space || !settings.autoJoinSpaceRooms) {
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (!isSpace(space)) {
|
if (!isSpace(space)) {
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (space.getMyMembership() !== Membership.Join) {
|
if (space.getMyMembership() !== Membership.Join) {
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
const spaceId = space.roomId;
|
const spaceId = space.roomId;
|
||||||
|
|||||||
@@ -154,9 +154,10 @@ export const useRoomMediaEvents = (room: Room) => {
|
|||||||
for (const raw of response.chunk ?? []) {
|
for (const raw of response.chunk ?? []) {
|
||||||
const mEvent = await decryptEvent(raw);
|
const mEvent = await decryptEvent(raw);
|
||||||
const item = toMediaItem(mEvent);
|
const item = toMediaItem(mEvent);
|
||||||
if (!item || cache.seenIds.has(item.eventId)) continue;
|
if (item && !cache.seenIds.has(item.eventId)) {
|
||||||
cache.seenIds.add(item.eventId);
|
cache.seenIds.add(item.eventId);
|
||||||
collected.push(item);
|
collected.push(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (collected.length >= TARGET_BATCH || !response.end) break;
|
if (collected.length >= TARGET_BATCH || !response.end) break;
|
||||||
@@ -212,9 +213,10 @@ export const useRoomMediaEvents = (room: Room) => {
|
|||||||
for (let i = localEvents.length - 1; i >= 0; i -= 1) {
|
for (let i = localEvents.length - 1; i >= 0; i -= 1) {
|
||||||
const mEvent = await decryptEvent(localEvents[i]);
|
const mEvent = await decryptEvent(localEvents[i]);
|
||||||
const item = toMediaItem(mEvent);
|
const item = toMediaItem(mEvent);
|
||||||
if (!item || cache.seenIds.has(item.eventId)) continue;
|
if (item && !cache.seenIds.has(item.eventId)) {
|
||||||
cache.seenIds.add(item.eventId);
|
cache.seenIds.add(item.eventId);
|
||||||
localFound.push(item);
|
localFound.push(item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cancelled) return;
|
if (cancelled) return;
|
||||||
|
|||||||
@@ -42,11 +42,12 @@ const MAX_AUTO_PAGE_COUNT = 50;
|
|||||||
export function buildParentByRoomId(rooms: Iterable<IHierarchyRoom>): Map<string, string> {
|
export function buildParentByRoomId(rooms: Iterable<IHierarchyRoom>): Map<string, string> {
|
||||||
const parentByRoomId = new Map<string, string>();
|
const parentByRoomId = new Map<string, string>();
|
||||||
for (const room of rooms) {
|
for (const room of rooms) {
|
||||||
if (!room?.room_id || !Array.isArray(room.children_state)) continue;
|
if (room?.room_id && Array.isArray(room.children_state)) {
|
||||||
for (const childState of room.children_state) {
|
room.children_state.forEach((childState) => {
|
||||||
if (childState?.type !== StateEvent.SpaceChild) continue;
|
if (childState?.type !== StateEvent.SpaceChild) return;
|
||||||
if (typeof childState.state_key !== 'string') continue;
|
if (typeof childState.state_key !== 'string') return;
|
||||||
parentByRoomId.set(childState.state_key, room.room_id);
|
parentByRoomId.set(childState.state_key, room.room_id);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return parentByRoomId;
|
return parentByRoomId;
|
||||||
|
|||||||
@@ -110,10 +110,11 @@ export function useOtherUserCollectibles(userId: string): CollectibleProfileFiel
|
|||||||
] as const;
|
] as const;
|
||||||
|
|
||||||
for (const [kind, collectible] of entries) {
|
for (const [kind, collectible] of entries) {
|
||||||
if (!collectible) continue;
|
if (collectible) {
|
||||||
for (const [role, mxc] of Object.entries(collectible.assets)) {
|
for (const [role, mxc] of Object.entries(collectible.assets)) {
|
||||||
const blobUrl = await getProfileAssetUrl(mx, mxc, useAuthentication);
|
const blobUrl = await getProfileAssetUrl(mx, mxc, useAuthentication);
|
||||||
if (blobUrl) urls[`${kind}:${role}`] = blobUrl;
|
if (blobUrl) urls[`${kind}:${role}`] = blobUrl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,12 +97,12 @@ export function useTypingVerbs(userIds: string[]): Record<string, string | undef
|
|||||||
if (!cancelled) setTick((tick) => tick + 1);
|
if (!cancelled) setTick((tick) => tick + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const userId of key.split(',')) {
|
key.split(',').forEach((userId) => {
|
||||||
if (getCachedProfileFields(userId)) continue;
|
if (getCachedProfileFields(userId)) return;
|
||||||
getProfileFields(mx, userId)
|
getProfileFields(mx, userId)
|
||||||
.then(rerender)
|
.then(rerender)
|
||||||
.catch(() => undefined);
|
.catch(() => undefined);
|
||||||
}
|
});
|
||||||
|
|
||||||
return () => {
|
return () => {
|
||||||
cancelled = true;
|
cancelled = true;
|
||||||
@@ -111,6 +111,8 @@ export function useTypingVerbs(userIds: string[]): Record<string, string | undef
|
|||||||
}, [mx, key]);
|
}, [mx, key]);
|
||||||
|
|
||||||
const verbs: Record<string, string | undefined> = {};
|
const verbs: Record<string, string | undefined> = {};
|
||||||
for (const userId of userIds) verbs[userId] = getCachedTypingVerb(userId);
|
userIds.forEach((userId) => {
|
||||||
|
verbs[userId] = getCachedTypingVerb(userId);
|
||||||
|
});
|
||||||
return verbs;
|
return verbs;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const useViewTransitions = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!supportsViewTransitions()) {
|
if (!supportsViewTransitions()) {
|
||||||
return;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark that we support view transitions
|
// Mark that we support view transitions
|
||||||
|
|||||||
+110
-113
@@ -174,6 +174,51 @@ export function initPaarrotAPI(matrixClient: MatrixClient) {
|
|||||||
console.log('Paarrot API: Handler initialized');
|
console.log('Paarrot API: Handler initialized');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the currently active room ID
|
||||||
|
* Extracts room ID from the current URL pathname
|
||||||
|
*/
|
||||||
|
function getCurrentRoomId(): string | null {
|
||||||
|
try {
|
||||||
|
// Get the pathname from URL
|
||||||
|
// Support both normal routing and hash routing
|
||||||
|
let { pathname } = window.location;
|
||||||
|
|
||||||
|
// If using hash router, parse from hash
|
||||||
|
if (window.location.hash) {
|
||||||
|
const hashMatch = window.location.hash.match(/#(.+)/);
|
||||||
|
if (hashMatch) {
|
||||||
|
pathname = hashMatch[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// URL patterns:
|
||||||
|
// /home/:roomIdOrAlias/:eventId?/
|
||||||
|
// /direct/:roomIdOrAlias/:eventId?/
|
||||||
|
// /:spaceIdOrAlias/:roomIdOrAlias/:eventId?/
|
||||||
|
|
||||||
|
// Try to match room patterns
|
||||||
|
const patterns = [
|
||||||
|
/^\/home\/([^/]+)/, // /home/:roomIdOrAlias
|
||||||
|
/^\/direct\/([^/]+)/, // /direct/:roomIdOrAlias
|
||||||
|
/^\/[^/]+\/([^/]+)/, // /:spaceIdOrAlias/:roomIdOrAlias (space rooms)
|
||||||
|
];
|
||||||
|
|
||||||
|
for (const pattern of patterns) {
|
||||||
|
const match = pathname.match(pattern);
|
||||||
|
if (match && match[1]) {
|
||||||
|
// Decode URI component in case the room ID was encoded
|
||||||
|
return decodeURIComponent(match[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Paarrot API: Error getting current room ID:', error);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get current app status
|
* Get current app status
|
||||||
*/
|
*/
|
||||||
@@ -483,49 +528,48 @@ function collectRecentMessages(room: any, limit: number): ApiMessage[] {
|
|||||||
|
|
||||||
for (let i = liveEvents.length - 1; i >= 0 && messages.length < limit; i -= 1) {
|
for (let i = liveEvents.length - 1; i >= 0 && messages.length < limit; i -= 1) {
|
||||||
const evt = liveEvents[i];
|
const evt = liveEvents[i];
|
||||||
if (!evt) continue;
|
|
||||||
if (typeof evt.isRedacted === 'function' && evt.isRedacted()) continue;
|
|
||||||
if (reactionOrEditEvent(evt)) continue;
|
|
||||||
|
|
||||||
const type = evt.getType?.();
|
|
||||||
if (
|
if (
|
||||||
type !== MessageEvent.RoomMessage &&
|
evt &&
|
||||||
type !== MessageEvent.RoomMessageEncrypted &&
|
!(typeof evt.isRedacted === 'function' && evt.isRedacted()) &&
|
||||||
type !== MessageEvent.Sticker
|
!reactionOrEditEvent(evt)
|
||||||
) {
|
) {
|
||||||
continue;
|
const type = evt.getType?.();
|
||||||
|
if (
|
||||||
|
type === MessageEvent.RoomMessage ||
|
||||||
|
type === MessageEvent.RoomMessageEncrypted ||
|
||||||
|
type === MessageEvent.Sticker
|
||||||
|
) {
|
||||||
|
const content = evt.getContent?.() ?? {};
|
||||||
|
const sender = evt.getSender?.() ?? '';
|
||||||
|
const member = sender ? room.getMember?.(sender) : null;
|
||||||
|
|
||||||
|
if (type === MessageEvent.RoomMessageEncrypted && !content.msgtype) {
|
||||||
|
messages.push({
|
||||||
|
eventId: evt.getId?.() ?? '',
|
||||||
|
roomId,
|
||||||
|
roomName,
|
||||||
|
isDirect,
|
||||||
|
sender,
|
||||||
|
senderName: member?.name ?? sender,
|
||||||
|
timestamp: evt.getTs?.() ?? 0,
|
||||||
|
msgtype: 'm.encrypted',
|
||||||
|
body: '[encrypted]',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
messages.push({
|
||||||
|
eventId: evt.getId?.() ?? '',
|
||||||
|
roomId,
|
||||||
|
roomName,
|
||||||
|
isDirect,
|
||||||
|
sender,
|
||||||
|
senderName: member?.name ?? sender,
|
||||||
|
timestamp: evt.getTs?.() ?? 0,
|
||||||
|
msgtype: content.msgtype || (type === MessageEvent.Sticker ? 'm.sticker' : 'm.text'),
|
||||||
|
body: content.body || '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const content = evt.getContent?.() ?? {};
|
|
||||||
const sender = evt.getSender?.() ?? '';
|
|
||||||
const member = sender ? room.getMember?.(sender) : null;
|
|
||||||
|
|
||||||
if (type === MessageEvent.RoomMessageEncrypted && !content.msgtype) {
|
|
||||||
messages.push({
|
|
||||||
eventId: evt.getId?.() ?? '',
|
|
||||||
roomId,
|
|
||||||
roomName,
|
|
||||||
isDirect,
|
|
||||||
sender,
|
|
||||||
senderName: member?.name ?? sender,
|
|
||||||
timestamp: evt.getTs?.() ?? 0,
|
|
||||||
msgtype: 'm.encrypted',
|
|
||||||
body: '[encrypted]',
|
|
||||||
});
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
messages.push({
|
|
||||||
eventId: evt.getId?.() ?? '',
|
|
||||||
roomId,
|
|
||||||
roomName,
|
|
||||||
isDirect,
|
|
||||||
sender,
|
|
||||||
senderName: member?.name ?? sender,
|
|
||||||
timestamp: evt.getTs?.() ?? 0,
|
|
||||||
msgtype: content.msgtype || (type === MessageEvent.Sticker ? 'm.sticker' : 'm.text'),
|
|
||||||
body: content.body || '',
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return messages.reverse();
|
return messages.reverse();
|
||||||
@@ -592,35 +636,33 @@ async function getUnreadsByScope(matrixClient: any, scope: MessageScope) {
|
|||||||
}> = [];
|
}> = [];
|
||||||
|
|
||||||
for (const room of rooms) {
|
for (const room of rooms) {
|
||||||
if (getNotificationType(matrixClient, room.roomId) === NotificationType.Mute) {
|
if (
|
||||||
continue;
|
getNotificationType(matrixClient, room.roomId) !== NotificationType.Mute &&
|
||||||
}
|
(roomHaveNotification(room) || roomHaveUnread(matrixClient, room))
|
||||||
if (!roomHaveNotification(room) && !roomHaveUnread(matrixClient, room)) {
|
) {
|
||||||
continue;
|
const unreadInfo = getUnreadInfo(room);
|
||||||
}
|
const latestMessages = collectRecentMessages(room, 1);
|
||||||
|
const latest = latestMessages[0];
|
||||||
|
|
||||||
const unreadInfo = getUnreadInfo(room);
|
unreads.push({
|
||||||
const latestMessages = collectRecentMessages(room, 1);
|
roomId: room.roomId,
|
||||||
const latest = latestMessages[0];
|
name: room.name || 'Unnamed Room',
|
||||||
|
isDirect: isDirectRoom(room),
|
||||||
unreads.push({
|
avatar: room.getMxcAvatarUrl?.() || null,
|
||||||
roomId: room.roomId,
|
total: unreadInfo.total,
|
||||||
name: room.name || 'Unnamed Room',
|
highlight: unreadInfo.highlight,
|
||||||
isDirect: isDirectRoom(room),
|
latest: latest
|
||||||
avatar: room.getMxcAvatarUrl?.() || null,
|
? {
|
||||||
total: unreadInfo.total,
|
eventId: latest.eventId,
|
||||||
highlight: unreadInfo.highlight,
|
sender: latest.sender,
|
||||||
latest: latest
|
senderName: latest.senderName,
|
||||||
? {
|
timestamp: latest.timestamp,
|
||||||
eventId: latest.eventId,
|
msgtype: latest.msgtype,
|
||||||
sender: latest.sender,
|
body: latest.body,
|
||||||
senderName: latest.senderName,
|
}
|
||||||
timestamp: latest.timestamp,
|
: undefined,
|
||||||
msgtype: latest.msgtype,
|
});
|
||||||
body: latest.body,
|
}
|
||||||
}
|
|
||||||
: undefined,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
unreads.sort((a, b) => {
|
unreads.sort((a, b) => {
|
||||||
@@ -638,49 +680,4 @@ async function getUnreadsByScope(matrixClient: any, scope: MessageScope) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the currently active room ID
|
|
||||||
* Extracts room ID from the current URL pathname
|
|
||||||
*/
|
|
||||||
function getCurrentRoomId(): string | null {
|
|
||||||
try {
|
|
||||||
// Get the pathname from URL
|
|
||||||
// Support both normal routing and hash routing
|
|
||||||
let { pathname } = window.location;
|
|
||||||
|
|
||||||
// If using hash router, parse from hash
|
|
||||||
if (window.location.hash) {
|
|
||||||
const hashMatch = window.location.hash.match(/#(.+)/);
|
|
||||||
if (hashMatch) {
|
|
||||||
pathname = hashMatch[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// URL patterns:
|
|
||||||
// /home/:roomIdOrAlias/:eventId?/
|
|
||||||
// /direct/:roomIdOrAlias/:eventId?/
|
|
||||||
// /:spaceIdOrAlias/:roomIdOrAlias/:eventId?/
|
|
||||||
|
|
||||||
// Try to match room patterns
|
|
||||||
const patterns = [
|
|
||||||
/^\/home\/([^/]+)/, // /home/:roomIdOrAlias
|
|
||||||
/^\/direct\/([^/]+)/, // /direct/:roomIdOrAlias
|
|
||||||
/^\/[^/]+\/([^/]+)/, // /:spaceIdOrAlias/:roomIdOrAlias (space rooms)
|
|
||||||
];
|
|
||||||
|
|
||||||
for (const pattern of patterns) {
|
|
||||||
const match = pathname.match(pattern);
|
|
||||||
if (match && match[1]) {
|
|
||||||
// Decode URI component in case the room ID was encoded
|
|
||||||
return decodeURIComponent(match[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
} catch (error) {
|
|
||||||
console.error('Paarrot API: Error getting current room ID:', error);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default { initPaarrotAPI };
|
export default { initPaarrotAPI };
|
||||||
|
|||||||
@@ -569,35 +569,35 @@ function AndroidShareIntentHandler() {
|
|||||||
// Upload file
|
// Upload file
|
||||||
const uploadResult = await mx.uploadContent(fileToUpload);
|
const uploadResult = await mx.uploadContent(fileToUpload);
|
||||||
const mxc = uploadResult?.content_uri;
|
const mxc = uploadResult?.content_uri;
|
||||||
if (!mxc) continue;
|
if (mxc) {
|
||||||
|
// Determine message type and send
|
||||||
|
const fileType = originalFile.type;
|
||||||
|
let msgtype = 'm.file' as const;
|
||||||
|
if (fileType.startsWith('image/')) msgtype = 'm.image' as const;
|
||||||
|
else if (fileType.startsWith('video/')) msgtype = 'm.video' as const;
|
||||||
|
else if (fileType.startsWith('audio/')) msgtype = 'm.audio' as const;
|
||||||
|
|
||||||
// Determine message type and send
|
const fileContent: any = {
|
||||||
const fileType = originalFile.type;
|
msgtype,
|
||||||
let msgtype = 'm.file' as const;
|
body: originalFile.name,
|
||||||
if (fileType.startsWith('image/')) msgtype = 'm.image' as const;
|
filename: originalFile.name,
|
||||||
else if (fileType.startsWith('video/')) msgtype = 'm.video' as const;
|
info: {
|
||||||
else if (fileType.startsWith('audio/')) msgtype = 'm.audio' as const;
|
mimetype: originalFile.type,
|
||||||
|
size: originalFile.size,
|
||||||
const fileContent: any = {
|
},
|
||||||
msgtype,
|
|
||||||
body: originalFile.name,
|
|
||||||
filename: originalFile.name,
|
|
||||||
info: {
|
|
||||||
mimetype: originalFile.type,
|
|
||||||
size: originalFile.size,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
if (encInfo) {
|
|
||||||
fileContent.file = {
|
|
||||||
...encInfo,
|
|
||||||
url: mxc,
|
|
||||||
};
|
};
|
||||||
} else {
|
|
||||||
fileContent.url = mxc;
|
|
||||||
}
|
|
||||||
|
|
||||||
await mx.sendMessage(roomId, fileContent);
|
if (encInfo) {
|
||||||
|
fileContent.file = {
|
||||||
|
...encInfo,
|
||||||
|
url: mxc,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
fileContent.url = mxc;
|
||||||
|
}
|
||||||
|
|
||||||
|
await mx.sendMessage(roomId, fileContent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -645,7 +645,7 @@ function AndroidShareIntentHandler() {
|
|||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isAndroidShareSupported()) return;
|
if (!isAndroidShareSupported()) return undefined;
|
||||||
|
|
||||||
let mounted = true;
|
let mounted = true;
|
||||||
let listenerHandle: { remove: () => Promise<void> } | undefined;
|
let listenerHandle: { remove: () => Promise<void> } | undefined;
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ const useLogoutListener = (mx?: MatrixClient) => {
|
|||||||
*/
|
*/
|
||||||
const useVisibilitySync = (mx?: MatrixClient) => {
|
const useVisibilitySync = (mx?: MatrixClient) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mx || !isTauriMobile()) return;
|
if (!mx || !isTauriMobile()) return undefined;
|
||||||
|
|
||||||
const handleVisibilityChange = () => {
|
const handleVisibilityChange = () => {
|
||||||
if (document.visibilityState === 'visible') {
|
if (document.visibilityState === 'visible') {
|
||||||
@@ -96,7 +96,7 @@ const useVisibilitySync = (mx?: MatrixClient) => {
|
|||||||
*/
|
*/
|
||||||
const useBackgroundSync = (mx?: MatrixClient) => {
|
const useBackgroundSync = (mx?: MatrixClient) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mx || !isTauriMobile()) return;
|
if (!mx || !isTauriMobile()) return undefined;
|
||||||
|
|
||||||
// Start background sync with credentials from the Matrix client
|
// Start background sync with credentials from the Matrix client
|
||||||
const startSync = async () => {
|
const startSync = async () => {
|
||||||
@@ -298,7 +298,7 @@ export function ClientRoot({ children }: ClientRootProps) {
|
|||||||
|
|
||||||
// Timeout if sync takes too long - nudge the client rather than immediately erroring
|
// Timeout if sync takes too long - nudge the client rather than immediately erroring
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mx || !loading) return;
|
if (!mx || !loading) return undefined;
|
||||||
|
|
||||||
const timeout = setTimeout(() => {
|
const timeout = setTimeout(() => {
|
||||||
console.warn('[ClientRoot] Sync taking too long, nudging client...');
|
console.warn('[ClientRoot] Sync taking too long, nudging client...');
|
||||||
@@ -394,7 +394,7 @@ export function ClientRoot({ children }: ClientRootProps) {
|
|||||||
|
|
||||||
// Also nudge sync when the laptop wakes / network returns
|
// Also nudge sync when the laptop wakes / network returns
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!mx) return;
|
if (!mx) return undefined;
|
||||||
|
|
||||||
const nudge = () => {
|
const nudge = () => {
|
||||||
if (document.visibilityState !== 'visible') return;
|
if (document.visibilityState !== 'visible') return;
|
||||||
|
|||||||
@@ -0,0 +1,25 @@
|
|||||||
|
export interface DebugPacket {
|
||||||
|
id: number;
|
||||||
|
ts: number;
|
||||||
|
phase: 'start' | 'end';
|
||||||
|
method: string;
|
||||||
|
url: string;
|
||||||
|
path: string;
|
||||||
|
status?: number;
|
||||||
|
ms?: number;
|
||||||
|
txnId?: string;
|
||||||
|
eventId?: string;
|
||||||
|
req?: string;
|
||||||
|
res?: string;
|
||||||
|
error?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
let nextId = 0;
|
||||||
|
|
||||||
|
export function recordPacket(packet: Omit<DebugPacket, 'id'>) {
|
||||||
|
const full: DebugPacket = { id: nextId, ...packet };
|
||||||
|
nextId += 1;
|
||||||
|
|
||||||
|
// Web and mobile builds have no electron bridge, so nothing is recorded there
|
||||||
|
window.electron?.debug?.send(full);
|
||||||
|
}
|
||||||
@@ -63,6 +63,7 @@ export interface Settings {
|
|||||||
dateFormatString: string;
|
dateFormatString: string;
|
||||||
|
|
||||||
developerTools: boolean;
|
developerTools: boolean;
|
||||||
|
debugPackets: boolean;
|
||||||
|
|
||||||
autoJoinSpaceRooms: boolean;
|
autoJoinSpaceRooms: boolean;
|
||||||
|
|
||||||
@@ -109,6 +110,7 @@ const defaultSettings: Settings = {
|
|||||||
dateFormatString: 'D MMM YYYY',
|
dateFormatString: 'D MMM YYYY',
|
||||||
|
|
||||||
developerTools: false,
|
developerTools: false,
|
||||||
|
debugPackets: false,
|
||||||
|
|
||||||
autoJoinSpaceRooms: true,
|
autoJoinSpaceRooms: true,
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ export function pruneAvatarCache(): void {
|
|||||||
if (loadedAvatars.size > MAX_CACHE_SIZE) {
|
if (loadedAvatars.size > MAX_CACHE_SIZE) {
|
||||||
const iterator = loadedAvatars.values();
|
const iterator = loadedAvatars.values();
|
||||||
// Remove oldest entries (first added)
|
// Remove oldest entries (first added)
|
||||||
for (let i = 0; i < loadedAvatars.size - MAX_CACHE_SIZE; i++) {
|
for (let i = 0; i < loadedAvatars.size - MAX_CACHE_SIZE; i += 1) {
|
||||||
const result = iterator.next();
|
const result = iterator.next();
|
||||||
if (!result.done) {
|
if (!result.done) {
|
||||||
loadedAvatars.delete(result.value);
|
loadedAvatars.delete(result.value);
|
||||||
|
|||||||
@@ -543,6 +543,19 @@ export const setAppForegroundState = async (foreground: boolean): Promise<void>
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/** Returns the current native UnifiedPush status, or undefined if unavailable. */
|
||||||
|
export const getBackgroundSyncStatus = async (): Promise<UnifiedPushStatus | undefined> => {
|
||||||
|
if (!isBackgroundSyncSupported()) return undefined;
|
||||||
|
try {
|
||||||
|
const { registerPlugin } = await loadCapacitorCore();
|
||||||
|
const MatrixBackgroundSync = registerPlugin<MatrixBackgroundSyncPlugin>('MatrixBackgroundSync');
|
||||||
|
return await MatrixBackgroundSync.getStatus();
|
||||||
|
} catch (err) {
|
||||||
|
console.warn('[BackgroundSync] getStatus failed:', err);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Re-opens the UnifiedPush distributor selection dialog.
|
* Re-opens the UnifiedPush distributor selection dialog.
|
||||||
* Allows users to re-select or change their push notification distributor without terminal access.
|
* Allows users to re-select or change their push notification distributor without terminal access.
|
||||||
@@ -581,16 +594,3 @@ export const requestResetPushRegistration = async (): Promise<{ success: boolean
|
|||||||
return { success: false };
|
return { success: false };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Returns the current native UnifiedPush status, or undefined if unavailable. */
|
|
||||||
export const getBackgroundSyncStatus = async (): Promise<UnifiedPushStatus | undefined> => {
|
|
||||||
if (!isBackgroundSyncSupported()) return undefined;
|
|
||||||
try {
|
|
||||||
const { registerPlugin } = await loadCapacitorCore();
|
|
||||||
const MatrixBackgroundSync = registerPlugin<MatrixBackgroundSyncPlugin>('MatrixBackgroundSync');
|
|
||||||
return await MatrixBackgroundSync.getStatus();
|
|
||||||
} catch (err) {
|
|
||||||
console.warn('[BackgroundSync] getStatus failed:', err);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ export function pickCatalogStaticPreviewUrl(item: DiscordCollectibleItem): strin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function pickCatalogProfileEffectLoopUrl(item: DiscordCollectibleItem): string | undefined {
|
||||||
|
return catalogAssetUrl(item, 'effect_1', 'effect_0', 'effect_2', 'effect_3');
|
||||||
|
}
|
||||||
|
|
||||||
export function pickCatalogAnimatedPreviewUrl(item: DiscordCollectibleItem): string | undefined {
|
export function pickCatalogAnimatedPreviewUrl(item: DiscordCollectibleItem): string | undefined {
|
||||||
switch (item.type) {
|
switch (item.type) {
|
||||||
case 'nameplate':
|
case 'nameplate':
|
||||||
@@ -47,10 +51,6 @@ export function pickCatalogProfileEffectIntroUrl(item: DiscordCollectibleItem):
|
|||||||
return catalogAssetUrl(item, 'effect_0');
|
return catalogAssetUrl(item, 'effect_0');
|
||||||
}
|
}
|
||||||
|
|
||||||
export function pickCatalogProfileEffectLoopUrl(item: DiscordCollectibleItem): string | undefined {
|
|
||||||
return catalogAssetUrl(item, 'effect_1', 'effect_0', 'effect_2', 'effect_3');
|
|
||||||
}
|
|
||||||
|
|
||||||
export function catalogProfileEffectIntroDurationMs(
|
export function catalogProfileEffectIntroDurationMs(
|
||||||
item: DiscordCollectibleItem,
|
item: DiscordCollectibleItem,
|
||||||
): number | undefined {
|
): number | undefined {
|
||||||
|
|||||||
@@ -141,9 +141,9 @@ function replaceCdnUrls<T>(value: T, urlToMxc: Map<string, string>): T {
|
|||||||
}
|
}
|
||||||
if (typeof value === 'object') {
|
if (typeof value === 'object') {
|
||||||
const out: Record<string, unknown> = {};
|
const out: Record<string, unknown> = {};
|
||||||
for (const [key, entry] of Object.entries(value as Record<string, unknown>)) {
|
Object.entries(value as Record<string, unknown>).forEach(([key, entry]) => {
|
||||||
out[key] = replaceCdnUrls(entry, urlToMxc);
|
out[key] = replaceCdnUrls(entry, urlToMxc);
|
||||||
}
|
});
|
||||||
return out as T;
|
return out as T;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@@ -280,12 +280,12 @@ function dedupeVariantItems(items: DiscordCollectibleItem[]): DiscordCollectible
|
|||||||
export function groupCollectibleItems(items: DiscordCollectibleItem[]): CollectibleVariantGroup[] {
|
export function groupCollectibleItems(items: DiscordCollectibleItem[]): CollectibleVariantGroup[] {
|
||||||
const map = new Map<string, DiscordCollectibleItem[]>();
|
const map = new Map<string, DiscordCollectibleItem[]>();
|
||||||
|
|
||||||
for (const item of items) {
|
items.forEach((item) => {
|
||||||
const key = variantGroupKey(item);
|
const key = variantGroupKey(item);
|
||||||
const list = map.get(key);
|
const list = map.get(key);
|
||||||
if (list) list.push(item);
|
if (list) list.push(item);
|
||||||
else map.set(key, [item]);
|
else map.set(key, [item]);
|
||||||
}
|
});
|
||||||
|
|
||||||
return [...map.entries()]
|
return [...map.entries()]
|
||||||
.map(([id, groupItems]) => {
|
.map(([id, groupItems]) => {
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ export function convertEmoticons(text: string): string {
|
|||||||
// e.g., :-) before :)
|
// e.g., :-) before :)
|
||||||
const emoticons = Object.keys(EMOTICON_MAP).sort((a, b) => b.length - a.length);
|
const emoticons = Object.keys(EMOTICON_MAP).sort((a, b) => b.length - a.length);
|
||||||
|
|
||||||
for (const emoticon of emoticons) {
|
emoticons.forEach((emoticon) => {
|
||||||
// Escape special regex characters
|
// Escape special regex characters
|
||||||
const escapedEmoticon = emoticon.replace(/[.*+?^${}()|[\]\\<>]/g, '\\$&');
|
const escapedEmoticon = emoticon.replace(/[.*+?^${}()|[\]\\<>]/g, '\\$&');
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ export function convertEmoticons(text: string): string {
|
|||||||
// Otherwise convert to emoji
|
// Otherwise convert to emoji
|
||||||
return prefix + EMOTICON_MAP[emoticon];
|
return prefix + EMOTICON_MAP[emoticon];
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -111,7 +111,7 @@ export function convertEmoticonsInHtml(html: string): string {
|
|||||||
// Sort emoticons by length (longest first) to handle overlapping patterns
|
// Sort emoticons by length (longest first) to handle overlapping patterns
|
||||||
const emoticons = Object.keys(EMOTICON_MAP).sort((a, b) => b.length - a.length);
|
const emoticons = Object.keys(EMOTICON_MAP).sort((a, b) => b.length - a.length);
|
||||||
|
|
||||||
for (const emoticon of emoticons) {
|
emoticons.forEach((emoticon) => {
|
||||||
// Convert emoticon to HTML entity version (for < and >)
|
// Convert emoticon to HTML entity version (for < and >)
|
||||||
const htmlEmoticon = emoticon.replace(/</g, '<').replace(/>/g, '>');
|
const htmlEmoticon = emoticon.replace(/</g, '<').replace(/>/g, '>');
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ export function convertEmoticonsInHtml(html: string): string {
|
|||||||
// Otherwise convert to emoji
|
// Otherwise convert to emoji
|
||||||
return prefix + EMOTICON_MAP[emoticon];
|
return prefix + EMOTICON_MAP[emoticon];
|
||||||
});
|
});
|
||||||
}
|
});
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,13 +85,13 @@ export function fuzzyMatchAny(
|
|||||||
texts: Array<string | undefined | null>,
|
texts: Array<string | undefined | null>,
|
||||||
): FuzzyMatch | null {
|
): FuzzyMatch | null {
|
||||||
let best: FuzzyMatch | null = null;
|
let best: FuzzyMatch | null = null;
|
||||||
for (const text of texts) {
|
texts.forEach((text) => {
|
||||||
if (!text) continue;
|
if (!text) return;
|
||||||
const match = fuzzyMatch(query, text);
|
const match = fuzzyMatch(query, text);
|
||||||
if (match && (!best || match.score > best.score)) {
|
if (match && (!best || match.score > best.score)) {
|
||||||
best = match;
|
best = match;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
return best;
|
return best;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -106,12 +106,12 @@ export function fuzzyFilter<T>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
const results: Array<{ item: T; score: number }> = [];
|
const results: Array<{ item: T; score: number }> = [];
|
||||||
for (const item of items) {
|
items.forEach((item) => {
|
||||||
const match = fuzzyMatchAny(q, getTexts(item));
|
const match = fuzzyMatchAny(q, getTexts(item));
|
||||||
if (match) {
|
if (match) {
|
||||||
results.push({ item, score: match.score });
|
results.push({ item, score: match.score });
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
results.sort((a, b) => b.score - a.score);
|
results.sort((a, b) => b.score - a.score);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -268,6 +268,34 @@ export function needsPngForMetadata(metadata: ImageMetadata): boolean {
|
|||||||
return Boolean(metadata.banner || metadata.avatarBorderColor || metadata.gradient);
|
return Boolean(metadata.banner || metadata.avatarBorderColor || metadata.gradient);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a Blob from Uint8Array without relying on BufferSource/BlobPart quirks
|
||||||
|
* across TS DOM lib / Electron versions (avoids SharedArrayBuffer typing issues).
|
||||||
|
*/
|
||||||
|
export function uint8ArrayToBlob(data: Uint8Array, type: string): Blob {
|
||||||
|
const copy = new ArrayBuffer(data.byteLength);
|
||||||
|
new Uint8Array(copy).set(data);
|
||||||
|
return new Blob([copy], { type });
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the MIME type for an image format
|
||||||
|
*/
|
||||||
|
export function getMimeType(format: ImageFormat): string {
|
||||||
|
switch (format) {
|
||||||
|
case 'png':
|
||||||
|
return 'image/png';
|
||||||
|
case 'webp':
|
||||||
|
return 'image/webp';
|
||||||
|
case 'jpeg':
|
||||||
|
return 'image/jpeg';
|
||||||
|
case 'gif':
|
||||||
|
return 'image/gif';
|
||||||
|
default:
|
||||||
|
return 'application/octet-stream';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert image data to PNG via canvas (needed for banner/border/gradient metadata).
|
* Convert image data to PNG via canvas (needed for banner/border/gradient metadata).
|
||||||
*/
|
*/
|
||||||
@@ -304,16 +332,6 @@ export async function convertImageDataToPng(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Build a Blob from Uint8Array without relying on BufferSource/BlobPart quirks
|
|
||||||
* across TS DOM lib / Electron versions (avoids SharedArrayBuffer typing issues).
|
|
||||||
*/
|
|
||||||
export function uint8ArrayToBlob(data: Uint8Array, type: string): Blob {
|
|
||||||
const copy = new ArrayBuffer(data.byteLength);
|
|
||||||
new Uint8Array(copy).set(data);
|
|
||||||
return new Blob([copy], { type });
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Embed paarrot metadata (color and/or banner) into image data
|
* Embed paarrot metadata (color and/or banner) into image data
|
||||||
* Preserves existing metadata that is not being updated
|
* Preserves existing metadata that is not being updated
|
||||||
@@ -376,24 +394,6 @@ export function removeColorFromImage(imageData: ArrayBuffer | Uint8Array): Uint8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the MIME type for an image format
|
|
||||||
*/
|
|
||||||
export function getMimeType(format: ImageFormat): string {
|
|
||||||
switch (format) {
|
|
||||||
case 'png':
|
|
||||||
return 'image/png';
|
|
||||||
case 'webp':
|
|
||||||
return 'image/webp';
|
|
||||||
case 'jpeg':
|
|
||||||
return 'image/jpeg';
|
|
||||||
case 'gif':
|
|
||||||
return 'image/gif';
|
|
||||||
default:
|
|
||||||
return 'application/octet-stream';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the file extension for an image format
|
* Get the file extension for an image format
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -134,11 +134,11 @@ function parseStoredCollectible(value: unknown): StoredCollectible | undefined {
|
|||||||
if (!sku_id || !name || !assets || typeof assets !== 'object') return undefined;
|
if (!sku_id || !name || !assets || typeof assets !== 'object') return undefined;
|
||||||
|
|
||||||
const parsedAssets: Record<string, string> = {};
|
const parsedAssets: Record<string, string> = {};
|
||||||
for (const [key, mxc] of Object.entries(assets as Record<string, unknown>)) {
|
Object.entries(assets as Record<string, unknown>).forEach(([key, mxc]) => {
|
||||||
if (typeof mxc === 'string' && mxc.startsWith('mxc://')) {
|
if (typeof mxc === 'string' && mxc.startsWith('mxc://')) {
|
||||||
parsedAssets[key] = mxc;
|
parsedAssets[key] = mxc;
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
if (Object.keys(parsedAssets).length === 0) return undefined;
|
if (Object.keys(parsedAssets).length === 0) return undefined;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
+32
-32
@@ -152,6 +152,38 @@ export const getPaarrotUiContent = (room: Room | null): PaarrotUiContent | undef
|
|||||||
|
|
||||||
export const hasRoomAppUi = (room: Room | null): boolean => getPaarrotUiContent(room) !== undefined;
|
export const hasRoomAppUi = (room: Room | null): boolean => getPaarrotUiContent(room) !== undefined;
|
||||||
|
|
||||||
|
export function isValidChild(mEvent: MatrixEvent): boolean {
|
||||||
|
if (mEvent.getType() !== StateEvent.SpaceChild) return false;
|
||||||
|
const stateKey = mEvent.getStateKey();
|
||||||
|
if (!stateKey || !stateKey.startsWith('!')) return false;
|
||||||
|
// via is required; omitting it (e.g. empty {}) removes the child per Matrix spec
|
||||||
|
return Array.isArray(mEvent.getContent<{ via?: string[] }>().via);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getAllParents = (roomToParents: RoomToParents, roomId: string): Set<string> => {
|
||||||
|
const allParents = new Set<string>();
|
||||||
|
|
||||||
|
const addAllParentIds = (rId: string) => {
|
||||||
|
if (allParents.has(rId)) return;
|
||||||
|
allParents.add(rId);
|
||||||
|
|
||||||
|
const parents = roomToParents.get(rId);
|
||||||
|
parents?.forEach((id) => addAllParentIds(id));
|
||||||
|
};
|
||||||
|
addAllParentIds(roomId);
|
||||||
|
allParents.delete(roomId);
|
||||||
|
return allParents;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getSpaceChildren = (room: Room) =>
|
||||||
|
getStateEvents(room, StateEvent.SpaceChild).reduce<string[]>((filtered, mEvent) => {
|
||||||
|
const stateKey = mEvent.getStateKey();
|
||||||
|
if (isValidChild(mEvent) && stateKey) {
|
||||||
|
filtered.push(stateKey);
|
||||||
|
}
|
||||||
|
return filtered;
|
||||||
|
}, []);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* m.forum space root (forum board lobby), not a plain m.space or a lone m.forum topic channel.
|
* m.forum space root (forum board lobby), not a plain m.space or a lone m.forum topic channel.
|
||||||
* Matrix sets create type m.forum on forum spaces but SDK isSpaceRoom() is often still false;
|
* Matrix sets create type m.forum on forum spaces but SDK isSpaceRoom() is often still false;
|
||||||
@@ -201,38 +233,6 @@ export const isUnsupportedRoom = (room: Room | null): boolean => {
|
|||||||
return roomType !== RoomType.Space && roomType !== RoomType.Forum;
|
return roomType !== RoomType.Space && roomType !== RoomType.Forum;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function isValidChild(mEvent: MatrixEvent): boolean {
|
|
||||||
if (mEvent.getType() !== StateEvent.SpaceChild) return false;
|
|
||||||
const stateKey = mEvent.getStateKey();
|
|
||||||
if (!stateKey || !stateKey.startsWith('!')) return false;
|
|
||||||
// via is required; omitting it (e.g. empty {}) removes the child per Matrix spec
|
|
||||||
return Array.isArray(mEvent.getContent<{ via?: string[] }>().via);
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getAllParents = (roomToParents: RoomToParents, roomId: string): Set<string> => {
|
|
||||||
const allParents = new Set<string>();
|
|
||||||
|
|
||||||
const addAllParentIds = (rId: string) => {
|
|
||||||
if (allParents.has(rId)) return;
|
|
||||||
allParents.add(rId);
|
|
||||||
|
|
||||||
const parents = roomToParents.get(rId);
|
|
||||||
parents?.forEach((id) => addAllParentIds(id));
|
|
||||||
};
|
|
||||||
addAllParentIds(roomId);
|
|
||||||
allParents.delete(roomId);
|
|
||||||
return allParents;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const getSpaceChildren = (room: Room) =>
|
|
||||||
getStateEvents(room, StateEvent.SpaceChild).reduce<string[]>((filtered, mEvent) => {
|
|
||||||
const stateKey = mEvent.getStateKey();
|
|
||||||
if (isValidChild(mEvent) && stateKey) {
|
|
||||||
filtered.push(stateKey);
|
|
||||||
}
|
|
||||||
return filtered;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
export const mapParentWithChildren = (
|
export const mapParentWithChildren = (
|
||||||
roomToParents: RoomToParents,
|
roomToParents: RoomToParents,
|
||||||
roomId: string,
|
roomId: string,
|
||||||
|
|||||||
+18
-18
@@ -1,3 +1,21 @@
|
|||||||
|
/**
|
||||||
|
* Check if we're running inside Electron (not Tauri)
|
||||||
|
*/
|
||||||
|
export const isElectron = (): boolean => typeof window !== 'undefined' && 'electron' in window;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if we're running inside a Capacitor native app
|
||||||
|
*/
|
||||||
|
export const isCapacitorNative = (): boolean => {
|
||||||
|
if (typeof window === 'undefined') return false;
|
||||||
|
const cap = (window as any).Capacitor;
|
||||||
|
return Boolean(
|
||||||
|
cap?.isNativePlatform?.() ||
|
||||||
|
cap?.getPlatform?.() === 'android' ||
|
||||||
|
cap?.getPlatform?.() === 'ios',
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open an external URL using Electron's shell.openExternal, or window.open in browser
|
* Open an external URL using Electron's shell.openExternal, or window.open in browser
|
||||||
* @param url The URL to open
|
* @param url The URL to open
|
||||||
@@ -174,24 +192,6 @@ export const setupNotificationTapListener = async (
|
|||||||
*/
|
*/
|
||||||
export const isTauri = (): boolean => '__TAURI__' in window || '__TAURI_INTERNALS__' in window;
|
export const isTauri = (): boolean => '__TAURI__' in window || '__TAURI_INTERNALS__' in window;
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if we're running inside Electron (not Tauri)
|
|
||||||
*/
|
|
||||||
export const isElectron = (): boolean => typeof window !== 'undefined' && 'electron' in window;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if we're running inside a Capacitor native app
|
|
||||||
*/
|
|
||||||
export const isCapacitorNative = (): boolean => {
|
|
||||||
if (typeof window === 'undefined') return false;
|
|
||||||
const cap = (window as any).Capacitor;
|
|
||||||
return Boolean(
|
|
||||||
cap?.isNativePlatform?.() ||
|
|
||||||
cap?.getPlatform?.() === 'android' ||
|
|
||||||
cap?.getPlatform?.() === 'ios',
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if we're running on a mobile platform (Android/iOS)
|
* Check if we're running on a mobile platform (Android/iOS)
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -3,6 +3,87 @@ import { createClient, MatrixClient, IndexedDBStore, IndexedDBCryptoStore } from
|
|||||||
import { cryptoCallbacks } from './secretStorageKeys';
|
import { cryptoCallbacks } from './secretStorageKeys';
|
||||||
import { clearNavToActivePathStore } from '../app/state/navToActivePath';
|
import { clearNavToActivePathStore } from '../app/state/navToActivePath';
|
||||||
import { Session, getSessionStoreName } from '../app/state/sessions';
|
import { Session, getSessionStoreName } from '../app/state/sessions';
|
||||||
|
import { getSettings } from '../app/state/settings';
|
||||||
|
import { recordPacket } from '../app/state/debugPackets';
|
||||||
|
|
||||||
|
const MAX_BODY = 8192;
|
||||||
|
|
||||||
|
const jsonField = (text: string | undefined, key: string) => {
|
||||||
|
if (!text) return undefined;
|
||||||
|
try {
|
||||||
|
const parsed = JSON.parse(text);
|
||||||
|
return typeof parsed?.[key] === 'string' ? parsed[key] : undefined;
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Bodies are only read from a clone, so the SDK still gets the response it asked for
|
||||||
|
const readBody = async (res: Response) => {
|
||||||
|
const type = res.headers.get('content-type') ?? '';
|
||||||
|
if (!type.includes('json') && !type.includes('text')) return undefined;
|
||||||
|
try {
|
||||||
|
return (await res.clone().text()).slice(0, MAX_BODY);
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const debugFetch = async (input: RequestInfo | URL, init?: RequestInit): Promise<Response> => {
|
||||||
|
if (!getSettings().debugPackets) return globalThis.fetch(input, init);
|
||||||
|
|
||||||
|
// The SDK passes `URL | string`, and a URL instance has href, not url
|
||||||
|
const url = input instanceof URL ? input : new URL(typeof input === 'string' ? input : input.url);
|
||||||
|
const method = init?.method ?? (input instanceof Request ? input.method : 'GET');
|
||||||
|
const req = typeof init?.body === 'string' ? init.body.slice(0, MAX_BODY) : undefined;
|
||||||
|
const txnId = jsonField(req, 'transaction_id');
|
||||||
|
const start = Date.now();
|
||||||
|
|
||||||
|
recordPacket({
|
||||||
|
ts: start,
|
||||||
|
phase: 'start',
|
||||||
|
method,
|
||||||
|
url: url.toString(),
|
||||||
|
path: url.pathname,
|
||||||
|
txnId,
|
||||||
|
req,
|
||||||
|
});
|
||||||
|
|
||||||
|
let res: Response;
|
||||||
|
try {
|
||||||
|
res = await globalThis.fetch(input, init);
|
||||||
|
} catch (error) {
|
||||||
|
recordPacket({
|
||||||
|
ts: Date.now(),
|
||||||
|
phase: 'end',
|
||||||
|
method,
|
||||||
|
url: url.toString(),
|
||||||
|
path: url.pathname,
|
||||||
|
ms: Date.now() - start,
|
||||||
|
txnId,
|
||||||
|
req,
|
||||||
|
error: String(error),
|
||||||
|
});
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
|
||||||
|
const body = await readBody(res);
|
||||||
|
recordPacket({
|
||||||
|
ts: Date.now(),
|
||||||
|
phase: 'end',
|
||||||
|
method,
|
||||||
|
url: url.toString(),
|
||||||
|
path: url.pathname,
|
||||||
|
status: res.status,
|
||||||
|
ms: Date.now() - start,
|
||||||
|
txnId,
|
||||||
|
eventId: jsonField(body, 'event_id'),
|
||||||
|
req,
|
||||||
|
res: body,
|
||||||
|
});
|
||||||
|
|
||||||
|
return res;
|
||||||
|
};
|
||||||
|
|
||||||
// Track if we're currently handling a key conflict to prevent loops
|
// Track if we're currently handling a key conflict to prevent loops
|
||||||
let handlingKeyConflict = false;
|
let handlingKeyConflict = false;
|
||||||
@@ -136,7 +217,7 @@ const setupKeyConflictHandler = (mx: MatrixClient, session: Session): void => {
|
|||||||
|
|
||||||
const errorHandler = (...args: any[]) => {
|
const errorHandler = (...args: any[]) => {
|
||||||
if (checkKeyConflict(args)) {
|
if (checkKeyConflict(args)) {
|
||||||
keyConflictCount++;
|
keyConflictCount += 1;
|
||||||
console.log(
|
console.log(
|
||||||
`[initMatrix] ⚠️ Detected key conflict (${keyConflictCount}/${KEY_CONFLICT_THRESHOLD})`,
|
`[initMatrix] ⚠️ Detected key conflict (${keyConflictCount}/${KEY_CONFLICT_THRESHOLD})`,
|
||||||
);
|
);
|
||||||
@@ -181,7 +262,7 @@ const setupKeyConflictHandler = (mx: MatrixClient, session: Session): void => {
|
|||||||
console.error = errorHandler;
|
console.error = errorHandler;
|
||||||
console.warn = (...args: any[]) => {
|
console.warn = (...args: any[]) => {
|
||||||
if (checkKeyConflict(args)) {
|
if (checkKeyConflict(args)) {
|
||||||
keyConflictCount++;
|
keyConflictCount += 1;
|
||||||
}
|
}
|
||||||
originalWarn.apply(console, args);
|
originalWarn.apply(console, args);
|
||||||
};
|
};
|
||||||
@@ -236,6 +317,7 @@ export const initClient = async (session: Session): Promise<MatrixClient> => {
|
|||||||
timelineSupport: true,
|
timelineSupport: true,
|
||||||
cryptoCallbacks: cryptoCallbacks as any,
|
cryptoCallbacks: cryptoCallbacks as any,
|
||||||
verificationMethods: ['m.sas.v1'],
|
verificationMethods: ['m.sas.v1'],
|
||||||
|
fetchFn: debugFetch,
|
||||||
});
|
});
|
||||||
|
|
||||||
await indexedDBStore.startup();
|
await indexedDBStore.startup();
|
||||||
@@ -399,11 +481,11 @@ export const logoutAllSessions = async () => {
|
|||||||
|
|
||||||
// Clear all IndexedDB databases
|
// Clear all IndexedDB databases
|
||||||
const dbs = await window.indexedDB.databases();
|
const dbs = await window.indexedDB.databases();
|
||||||
for (const idbInfo of dbs) {
|
dbs.forEach((idbInfo) => {
|
||||||
if (idbInfo.name) {
|
if (idbInfo.name) {
|
||||||
window.indexedDB.deleteDatabase(idbInfo.name);
|
window.indexedDB.deleteDatabase(idbInfo.name);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
};
|
};
|
||||||
|
|||||||
Vendored
+7
@@ -1,5 +1,7 @@
|
|||||||
/// <reference types="vite/client" />
|
/// <reference types="vite/client" />
|
||||||
|
|
||||||
|
import type { DebugPacket } from './app/state/debugPackets';
|
||||||
|
|
||||||
declare module 'browser-encrypt-attachment' {
|
declare module 'browser-encrypt-attachment' {
|
||||||
export interface EncryptedAttachmentInfo {
|
export interface EncryptedAttachmentInfo {
|
||||||
v: string;
|
v: string;
|
||||||
@@ -67,6 +69,11 @@ interface ElectronAPI {
|
|||||||
}>;
|
}>;
|
||||||
};
|
};
|
||||||
plugins?: PluginAPI;
|
plugins?: PluginAPI;
|
||||||
|
debug?: {
|
||||||
|
openWindow: () => Promise<{ success: boolean; error?: string }>;
|
||||||
|
send: (packet: DebugPacket) => void;
|
||||||
|
onPacket: (callback: (packet: DebugPacket | DebugPacket[]) => void) => () => void;
|
||||||
|
};
|
||||||
protocol?: {
|
protocol?: {
|
||||||
getStatus: () => Promise<{
|
getStatus: () => Promise<{
|
||||||
success: boolean;
|
success: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user