mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-20 21:08:52 +01:00
Use useCallback for this
This commit is contained in:
parent
71f177bebe
commit
98e82a68fd
1 changed files with 18 additions and 16 deletions
|
@ -110,6 +110,23 @@ function StatusPage(params) {
|
||||||
? mediaStatus?.mediaAttachments
|
? mediaStatus?.mediaAttachments
|
||||||
: heroStatus?.mediaAttachments;
|
: heroStatus?.mediaAttachments;
|
||||||
|
|
||||||
|
const handleMediaClose = useCallback(() => {
|
||||||
|
if (
|
||||||
|
!window.matchMedia('(min-width: calc(40em + 350px))').matches &&
|
||||||
|
snapStates.prevLocation
|
||||||
|
) {
|
||||||
|
history.back();
|
||||||
|
} else {
|
||||||
|
if (showMediaOnly) {
|
||||||
|
location.hash = closeLink;
|
||||||
|
} else {
|
||||||
|
searchParams.delete('media');
|
||||||
|
searchParams.delete('mediaStatusID');
|
||||||
|
setSearchParams(searchParams);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [showMediaOnly, closeLink, snapStates.prevLocation]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="deck-backdrop">
|
<div class="deck-backdrop">
|
||||||
{showMedia ? (
|
{showMedia ? (
|
||||||
|
@ -119,22 +136,7 @@ function StatusPage(params) {
|
||||||
statusID={mediaStatusID || id}
|
statusID={mediaStatusID || id}
|
||||||
instance={instance}
|
instance={instance}
|
||||||
index={mediaIndex - 1}
|
index={mediaIndex - 1}
|
||||||
onClose={() => {
|
onClose={handleMediaClose}
|
||||||
if (
|
|
||||||
!window.matchMedia('(min-width: calc(40em + 350px))').matches &&
|
|
||||||
snapStates.prevLocation
|
|
||||||
) {
|
|
||||||
history.back();
|
|
||||||
} else {
|
|
||||||
if (showMediaOnly) {
|
|
||||||
location.hash = closeLink;
|
|
||||||
} else {
|
|
||||||
searchParams.delete('media');
|
|
||||||
searchParams.delete('mediaStatusID');
|
|
||||||
setSearchParams(searchParams);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div class="media-modal-container loading">
|
<div class="media-modal-container loading">
|
||||||
|
|
Loading…
Reference in a new issue