Ok need to check if navigation is undefined

This commit is contained in:
Lim Chee Aun 2023-11-01 23:14:13 +08:00
parent d35d0cbe18
commit d9dab6b5ee

View file

@ -179,7 +179,8 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
const showMedia = parseInt(mediaParam, 10) > 0; const showMedia = parseInt(mediaParam, 10) > 0;
const firstLoad = useRef( const firstLoad = useRef(
!states.prevLocation && !states.prevLocation &&
(history.length === 1 || navigation?.entries?.()?.length === 1), (history.length === 1 ||
('navigation' in window && navigation?.entries?.()?.length === 1)),
); );
const [viewMode, setViewMode] = useState( const [viewMode, setViewMode] = useState(
searchParams.get('view') || firstLoad.current ? 'full' : null, searchParams.get('view') || firstLoad.current ? 'full' : null,
@ -879,7 +880,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
const prevLocationIsStatusPage = useMemo(() => { const prevLocationIsStatusPage = useMemo(() => {
// Navigation API // Navigation API
if (navigation?.entries) { if ('navigation' in window && navigation?.entries) {
const prevEntry = navigation.entries()[navigation.currentEntry.index - 1]; const prevEntry = navigation.entries()[navigation.currentEntry.index - 1];
if (prevEntry?.url) { if (prevEntry?.url) {
return STATUS_URL_REGEX.test(prevEntry.url); return STATUS_URL_REGEX.test(prevEntry.url);