diff --git a/src/renderer/store/Authorize.js b/src/renderer/store/Authorize.js deleted file mode 100644 index ecfa2466..00000000 --- a/src/renderer/store/Authorize.js +++ /dev/null @@ -1,24 +0,0 @@ -import { ipcRenderer } from 'electron' - -const Authorize = { - namespaced: true, - state: {}, - mutations: {}, - actions: { - submit (_, code) { - return new Promise((resolve, reject) => { - ipcRenderer.send('get-access-token', code) - ipcRenderer.once('response-get-access-token', (event, id) => { - ipcRenderer.removeAllListeners('error-get-access-token') - resolve(id) - }) - ipcRenderer.once('error-get-access-token', (event, err) => { - ipcRenderer.removeAllListeners('response-get-access-token') - reject(err) - }) - }) - } - } -} - -export default Authorize diff --git a/src/renderer/store/Authorize.ts b/src/renderer/store/Authorize.ts new file mode 100644 index 00000000..3dbd457c --- /dev/null +++ b/src/renderer/store/Authorize.ts @@ -0,0 +1,33 @@ +import { ipcRenderer } from 'electron' +import { Module, ActionTree } from 'vuex' + +export interface AuthorizeState {} + +const state = (): AuthorizeState => ({}) + +// TODO: use type of rootState +const actions: ActionTree = { + submit: (_, code: string) => { + return new Promise((resolve, reject) => { + ipcRenderer.send('get-access-token', code) + ipcRenderer.once('response-get-access-token', (_, id: string) => { + ipcRenderer.removeAllListeners('error-get-access-token') + resolve(id) + }) + ipcRenderer.once('error-get-access-token', (_, err: Error) => { + ipcRenderer.removeAllListeners('response-get-access-token') + reject(err) + }) + }) + } +} + +// TODO: use type of rootState +const Authorize: Module = { + namespaced: true, + state: state, + mutations: {}, + actions: actions +} + +export default Authorize