feat: implement fallback to unauthenticated requests for media fetching on 401 errors

This commit is contained in:
2026-03-13 01:19:58 +11:00
parent 4756bfdc57
commit c07cf58086
8 changed files with 82 additions and 40 deletions

View File

@@ -1,4 +1,4 @@
import React, { MouseEventHandler, forwardRef, useState } from 'react';
import React, { MouseEventHandler, forwardRef, useState, useMemo } from 'react';
import { Room, EventTimeline } from 'matrix-js-sdk';
import { useAtomValue } from 'jotai';
import {
@@ -283,18 +283,22 @@ export function RoomNavItem({
const mDirects = useAtomValue(mDirectAtom);
// Get first participated thread for preview
const firstThreadPreview = (() => {
const threads = room.getThreads();
const participatedThreads = threads.filter((thread) => thread.hasCurrentUserParticipated);
if (participatedThreads.length === 0) return undefined;
const firstThreadPreview = useMemo(() => {
try {
const threads = room.getThreads();
const participatedThreads = threads.filter((thread) => thread.hasCurrentUserParticipated);
if (participatedThreads.length === 0) return undefined;
const firstThread = participatedThreads[0];
const rootEvent = firstThread.rootEvent;
if (!rootEvent) return undefined;
const firstThread = participatedThreads[0];
const rootEvent = firstThread.rootEvent;
if (!rootEvent) return undefined;
const rootBody = rootEvent.getContent()?.body ?? '';
return rootBody;
})();
const rootBody = rootEvent.getContent()?.body ?? '';
return rootBody;
} catch (error) {
return undefined;
}
}, [room]);
// Get parent space for DMs
const parentSpaceInfo = (() => {