Check for reload cases too

Prevent status page from going full width when reloading itself

This checks tab's history length, so opening status page on a new tab means
length = 1.

BUT this will fail if someone copies the link and paste to another
**existing** tab with existing pre-populated history.
This commit is contained in:
Lim Chee Aun 2023-10-26 11:42:44 +08:00
parent 0038c2225b
commit 1c87dd6e41

View file

@ -168,7 +168,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
const mediaParam = searchParams.get('media'); const mediaParam = searchParams.get('media');
const showMedia = parseInt(mediaParam, 10) > 0; const showMedia = parseInt(mediaParam, 10) > 0;
const firstLoad = useRef(!states.prevLocation); const firstLoad = useRef(!states.prevLocation && history.length === 1);
const [viewMode, setViewMode] = useState( const [viewMode, setViewMode] = useState(
searchParams.get('view') || firstLoad.current ? 'full' : null, searchParams.get('view') || firstLoad.current ? 'full' : null,
); );