aboutsummaryrefslogtreecommitdiffstats
path: root/stores/export.ts
blob: f0ff26080b82574fb659f5ae31e0820c112b993a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import { defineStore } from 'pinia';

export type ZipLoaderStatus = 'inactive' | 'preparing' | 'compressing' | 'ready' | 'failed';

export const useExportStore = defineStore('export', {
  state: () => ({
    zip: {
      status: 'inactive' as ZipLoaderStatus,
      contents: null as Blob | null,
    },
  }),
  getters: {
    getZipStatus: (state) => () => {
      return state.zip.status;
    },
    getZipContents: (state) => () => {
      return state.zip.contents;
    },
  },
  actions: {
    setZipStatus(status: ZipLoaderStatus) {
      this.zip.status = status;
      if (status === 'inactive' || status === 'preparing') {
        this.zip.contents = null;
      }
    },
    setZipContents(contents: Blob) {
      this.zip.contents = contents;
    },
  },
});