Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Sharkey
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
1673 esurio
Sharkey
Commits
71b016b2
Unverified
Commit
71b016b2
authored
1 year ago
by
kabo2468
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
fix: PhotoSwipeによるクライアントのメモリリークの解消 (#11395)
* Destroy PhotoSwipe on unmounted * Update CHANGELOG.md
parent
090253c2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
packages/frontend/src/components/MkMediaList.vue
+17
-9
17 additions, 9 deletions
packages/frontend/src/components/MkMediaList.vue
with
18 additions
and
9 deletions
CHANGELOG.md
+
1
−
0
View file @
71b016b2
...
...
@@ -19,6 +19,7 @@
-
Fix: モバイル表示のときページ下部がナビゲーションバーに隠れる問題を修正
-
Fix: 一部モーダルダイアログでスクロールできない問題を修正
-
Fix: Selecting all emojis in Custom emoji is impossible
-
Fix: PhotoSwipeによるメモリリークの修正
### Server
-
Fix: APIのオフセットが壊れていたせいで「もっと見る」でもっと見れない問題を修正
...
...
This diff is collapsed.
Click to expand it.
packages/frontend/src/components/MkMediaList.vue
+
17
−
9
View file @
71b016b2
...
...
@@ -58,7 +58,7 @@ async function getClientWidthWithCache(targetEl: HTMLElement, containerEl: HTMLE
</
script
>
<
script
lang=
"ts"
setup
>
import
{
onMounted
,
shallowRef
}
from
'
vue
'
;
import
{
onMounted
,
onUnmounted
,
shallowRef
}
from
'
vue
'
;
import
*
as
misskey
from
'
misskey-js
'
;
import
PhotoSwipeLightbox
from
'
photoswipe/lightbox
'
;
import
PhotoSwipe
from
'
photoswipe
'
;
...
...
@@ -82,12 +82,19 @@ const gallery = shallowRef<HTMLDivElement>();
const
pswpZIndex
=
os
.
claimZIndex
(
'
middle
'
);
document
.
documentElement
.
style
.
setProperty
(
'
--mk-pswp-root-z-index
'
,
pswpZIndex
.
toString
());
const
count
=
$computed
(()
=>
props
.
mediaList
.
filter
(
media
=>
previewable
(
media
)).
length
);
let
lightbox
:
PhotoSwipeLightbox
|
null
;
const
popstateHandler
=
():
void
=>
{
if
(
lightbox
.
pswp
&&
lightbox
.
pswp
.
isOpen
===
true
)
{
lightbox
.
pswp
.
close
();
}
};
/**
* アスペクト比をmediaListWithOneImageAppearanceに基づいていい感じに調整する
* aspect-ratioではなくheightを使う
*/
async
function
calcAspectRatio
()
{
async
function
calcAspectRatio
()
{
if
(
!
gallery
.
value
||
!
root
.
value
)
return
;
let
img
=
props
.
mediaList
[
0
];
...
...
@@ -137,7 +144,7 @@ const count = $computed(() => props.mediaList.filter(media => previewable(media)
onMounted
(()
=>
{
calcAspectRatio
();
const
lightbox
=
new
PhotoSwipeLightbox
({
lightbox
=
new
PhotoSwipeLightbox
({
dataSource
:
props
.
mediaList
.
filter
(
media
=>
{
if
(
media
.
type
===
'
image/svg+xml
'
)
return
true
;
// svgのwebpublicはpngなのでtrue
...
...
@@ -221,12 +228,7 @@ onMounted(() => {
lightbox
.
init
();
window
.
addEventListener
(
'
popstate
'
,
()
=>
{
if
(
lightbox
.
pswp
&&
lightbox
.
pswp
.
isOpen
===
true
)
{
lightbox
.
pswp
.
close
();
return
;
}
});
window
.
addEventListener
(
'
popstate
'
,
popstateHandler
);
lightbox
.
on
(
'
beforeOpen
'
,
()
=>
{
history
.
pushState
(
null
,
''
,
'
#pswp
'
);
...
...
@@ -239,6 +241,12 @@ onMounted(() => {
});
});
onUnmounted
(()
=>
{
window
.
removeEventListener
(
'
popstate
'
,
popstateHandler
);
lightbox
?.
destroy
();
lightbox
=
null
;
});
const
previewable
=
(
file
:
misskey
.
entities
.
DriveFile
):
boolean
=>
{
if
(
file
.
type
===
'
image/svg+xml
'
)
return
true
;
// svgのwebpublic/thumbnailはpngなのでtrue
// FILE_TYPE_BROWSERSAFEに適合しないものはブラウザで表示するのに不適切
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment