Try go back if close media modal

This commit is contained in:
Lim Chee Aun 2023-05-26 13:31:02 +08:00
parent 79aaa04af3
commit 49c04a4259

View file

@ -55,6 +55,7 @@ function resetScrollPosition(id) {
function StatusPage(params) { function StatusPage(params) {
const { id } = params; const { id } = params;
const { masto, instance } = api({ instance: params.instance }); const { masto, instance } = api({ instance: params.instance });
const snapStates = useSnapshot(states);
const [searchParams, setSearchParams] = useSearchParams(); const [searchParams, setSearchParams] = useSearchParams();
const mediaParam = searchParams.get('media'); const mediaParam = searchParams.get('media');
const mediaOnlyParam = searchParams.get('media-only'); const mediaOnlyParam = searchParams.get('media-only');
@ -117,6 +118,9 @@ function StatusPage(params) {
instance={instance} instance={instance}
index={mediaIndex - 1} index={mediaIndex - 1}
onClose={() => { onClose={() => {
if (snapStates.prevLocation) {
history.back();
} else {
if (showMediaOnly) { if (showMediaOnly) {
location.hash = closeLink; location.hash = closeLink;
} else { } else {
@ -124,6 +128,7 @@ function StatusPage(params) {
searchParams.delete('mediaStatusID'); searchParams.delete('mediaStatusID');
setSearchParams(searchParams); setSearchParams(searchParams);
} }
}
}} }}
/> />
) : ( ) : (