Skip to content

Commit

Permalink
fix: media unloading errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AlejandroAkbal committed Mar 15, 2024
1 parent 6550fd9 commit 0405e9c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions components/pages/posts/post/PostMedia.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@
onBeforeUnmount(() => {
let finalMediaElement = mediaElement.value
if (finalMediaElement == null) {
return
}
// If its a Vue component, get the actual element
if (finalMediaElement?.$el) {
finalMediaElement = finalMediaElement.$el
if ('$el' in finalMediaElement) {
finalMediaElement = finalMediaElement.$el as HTMLElement
}
// If its a picture, get the img element
Expand All @@ -44,10 +48,10 @@
}
// Cancel any pending media requests - https://stackoverflow.com/a/28060352
finalMediaElement?.removeAttribute('src')
finalMediaElement.removeAttribute('src')
if (isVideo.value) {
finalMediaElement?.load()
finalMediaElement.load()
}
})
Expand Down

0 comments on commit 0405e9c

Please sign in to comment.