mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-22 13:49:23 +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,16 +110,7 @@ function StatusPage(params) {
|
||||||
? mediaStatus?.mediaAttachments
|
? mediaStatus?.mediaAttachments
|
||||||
: heroStatus?.mediaAttachments;
|
: heroStatus?.mediaAttachments;
|
||||||
|
|
||||||
return (
|
const handleMediaClose = useCallback(() => {
|
||||||
<div class="deck-backdrop">
|
|
||||||
{showMedia ? (
|
|
||||||
mediaAttachments?.length ? (
|
|
||||||
<MediaModal
|
|
||||||
mediaAttachments={mediaAttachments}
|
|
||||||
statusID={mediaStatusID || id}
|
|
||||||
instance={instance}
|
|
||||||
index={mediaIndex - 1}
|
|
||||||
onClose={() => {
|
|
||||||
if (
|
if (
|
||||||
!window.matchMedia('(min-width: calc(40em + 350px))').matches &&
|
!window.matchMedia('(min-width: calc(40em + 350px))').matches &&
|
||||||
snapStates.prevLocation
|
snapStates.prevLocation
|
||||||
|
@ -134,7 +125,18 @@ function StatusPage(params) {
|
||||||
setSearchParams(searchParams);
|
setSearchParams(searchParams);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}}
|
}, [showMediaOnly, closeLink, snapStates.prevLocation]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div class="deck-backdrop">
|
||||||
|
{showMedia ? (
|
||||||
|
mediaAttachments?.length ? (
|
||||||
|
<MediaModal
|
||||||
|
mediaAttachments={mediaAttachments}
|
||||||
|
statusID={mediaStatusID || id}
|
||||||
|
instance={instance}
|
||||||
|
index={mediaIndex - 1}
|
||||||
|
onClose={handleMediaClose}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<div class="media-modal-container loading">
|
<div class="media-modal-container loading">
|
||||||
|
|
Loading…
Reference in a new issue