Whalebird-desktop-client-ma.../src/renderer/store/Authorize.ts

34 lines
822 B
TypeScript
Raw Normal View History

import { Module, ActionTree } from 'vuex'
2019-04-14 16:11:24 +02:00
import { RootState } from '@/store'
import { MyWindow } from '~/src/types/global'
2020-04-11 11:22:49 +02:00
const win = (window as any) as MyWindow
export type AuthorizeState = {}
const state = (): AuthorizeState => ({})
2019-04-14 16:11:24 +02:00
const actions: ActionTree<AuthorizeState, RootState> = {
submit: async (_, request: { code: string | null; sns: 'mastodon' | 'pleroma' | 'misskey' }): Promise<string> => {
let req = {
sns: request.sns
}
if (request.code) {
req = Object.assign(req, {
code: request.code.trim()
})
}
const id = await win.ipcRenderer.invoke('get-and-update-access-token', req)
return id
}
}
2019-04-14 16:11:24 +02:00
const Authorize: Module<AuthorizeState, RootState> = {
namespaced: true,
state: state,
mutations: {},
actions: actions
}
export default Authorize