import generator , { Entity } from 'megalodon' ; import { Module , MutationTree , ActionTree } from 'vuex' ; import { RootState } from '@/store' ; export type MuteConfirmState = { modalOpen : boolean ; account : Entity . Account | null ; } ; const state = ( ) : MuteConfirmState => ( { modalOpen : false , account : null } ) ; export const MUTATION_TYPES = { CHANGE_MODAL : 'changeModal' , CHANGE_ACCOUNT : 'changeAccount' } ; const mutations = { [ MUTATION_TYPES . CHANGE_MODAL ] : ( state , value ) => { state . modalOpen = value ; } , [ MUTATION_TYPES . CHANGE_ACCOUNT ] : ( state , account ) => { state . account = account ; } } ; const actions = { changeModal : ( { commit } , value ) => { commit ( MUTATION_TYPES . CHANGE_MODAL , value ) ; } , changeAccount : ( { commit } , account ) => { commit ( MUTATION_TYPES . CHANGE_ACCOUNT , account ) ; } , submit : async ( { state , rootState , dispatch } , notify ) => { const client = generator ( rootState . TimelineSpace . sns , rootState . TimelineSpace . account . baseURL , rootState . TimelineSpace . account . accessToken , rootState . App . userAgent ) ; const res = await client . muteAccount ( state . account ! . id , notify ) ; dispatch ( 'TimelineSpace/Contents/SideBar/AccountProfile/fetchRelationship' , state . account , { root : true } ) ; return res . data ; } } ; const MuteConfirm = { namespaced : true , state : state , mutations : mutations , actions : actions } ; export default MuteConfirm ;