logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://anongit.hacktivis.me/git/pleroma-fe.git/

media_viewer.js (786B)


  1. import { defineStore } from 'pinia'
  2. import fileTypeService from '../services/file_type/file_type.service.js'
  3. const supportedTypes = new Set(['image', 'video', 'audio', 'flash'])
  4. export const useMediaViewerStore = defineStore('mediaViewer', {
  5. state: () => ({
  6. media: [],
  7. currentIndex: 0,
  8. activated: false
  9. }),
  10. actions: {
  11. setMedia (attachments) {
  12. const media = attachments.filter(attachment => {
  13. const type = fileTypeService.fileType(attachment.mimetype)
  14. return supportedTypes.has(type)
  15. })
  16. this.media = media
  17. },
  18. setCurrentMedia (current) {
  19. const index = this.media.indexOf(current)
  20. this.activated = true
  21. this.currentIndex = index
  22. },
  23. closeMediaViewer () {
  24. this.activated = false
  25. }
  26. }
  27. })