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,12 +118,16 @@ function StatusPage(params) {
instance={instance} instance={instance}
index={mediaIndex - 1} index={mediaIndex - 1}
onClose={() => { onClose={() => {
if (showMediaOnly) { if (snapStates.prevLocation) {
location.hash = closeLink; history.back();
} else { } else {
searchParams.delete('media'); if (showMediaOnly) {
searchParams.delete('mediaStatusID'); location.hash = closeLink;
setSearchParams(searchParams); } else {
searchParams.delete('media');
searchParams.delete('mediaStatusID');
setSearchParams(searchParams);
}
} }
}} }}
/> />