feat: implement fallback to unauthenticated requests for media fetching on 401 errors
This commit is contained in:
@@ -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 = (() => {
|
||||
|
||||
Reference in New Issue
Block a user