pleroma-fe/src/stores/media_viewer.js
Yonle 38444f3165
attachment: fix over reliance on fileType()
Signed-off-by: Yonle <yonle@proton.me>
2026-02-27 14:09:45 +07:00

28 lines
659 B
JavaScript

import { defineStore } from 'pinia'
const supportedTypes = new Set(['image', 'video', 'audio', 'flash'])
export const useMediaViewerStore = defineStore('mediaViewer', {
state: () => ({
media: [],
currentIndex: 0,
activated: false,
}),
actions: {
setMedia(attachments) {
const media = attachments.filter((attachment) => {
return supportedTypes.has(attachment.type)
})
this.media = media
},
setCurrentMedia(current) {
const index = this.media.indexOf(current)
this.activated = true
this.currentIndex = index
},
closeMediaViewer() {
this.activated = false
},
},
})