From 0e33b465a117a5838e0f097e7d5e82e8cbf20685 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Thu, 4 Apr 2019 22:35:08 +0900
Subject: [PATCH] refs #850 Replace Authorize with typescript
---
src/renderer/store/Authorize.js | 24 ------------------------
src/renderer/store/Authorize.ts | 33 +++++++++++++++++++++++++++++++++
2 files changed, 33 insertions(+), 24 deletions(-)
delete mode 100644 src/renderer/store/Authorize.js
create mode 100644 src/renderer/store/Authorize.ts
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