import { LocalTag } from '~/src/types/localTag' ; import { Module , MutationTree , ActionTree } from 'vuex' ; import { RootState } from '@/store' ; import { MyWindow } from '~/src/types/global' ; const win = ( window as any ) as MyWindow ; export type ListState = { tags : Array < LocalTag > ; } ; const state = ( ) : ListState => ( { tags : [ ] } ) ; export const MUTATION_TYPES = { UPDATE_TAGS : 'updateTags' } ; const mutations = { [ MUTATION_TYPES . UPDATE_TAGS ] : ( state , tags ) => { state . tags = tags ; } } ; const actions = { listTags : async ( { commit } ) => { const tags = await win . ipcRenderer . invoke ( 'list-hashtags' ) ; commit ( MUTATION_TYPES . UPDATE_TAGS , tags ) ; return tags ; } , removeTag : async ( { dispatch } , tag ) => { await win . ipcRenderer . invoke ( 'remove-hashtag' , tag ) ; dispatch ( 'listTags' ) ; dispatch ( 'TimelineSpace/SideMenu/listTags' , { } , { root : true } ) ; return 'deleted' ; } } ; const List = { namespaced : true , state : state , mutations : mutations , actions : actions } ; export default List ;