From 94e3f57065898cefaff14bdc3782e765307b4a90 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Tue, 9 Apr 2019 22:49:20 +0900
Subject: [PATCH] refs #850 Replace Contents and Modals with typescript
---
.../{Contents.js => Contents.ts} | 0
src/renderer/store/TimelineSpace/Modals.js | 37 ---------------
src/renderer/store/TimelineSpace/Modals.ts | 46 +++++++++++++++++++
3 files changed, 46 insertions(+), 37 deletions(-)
rename src/renderer/store/TimelineSpace/{Contents.js => Contents.ts} (100%)
delete mode 100644 src/renderer/store/TimelineSpace/Modals.js
create mode 100644 src/renderer/store/TimelineSpace/Modals.ts
diff --git a/src/renderer/store/TimelineSpace/Contents.js b/src/renderer/store/TimelineSpace/Contents.ts
similarity index 100%
rename from src/renderer/store/TimelineSpace/Contents.js
rename to src/renderer/store/TimelineSpace/Contents.ts
diff --git a/src/renderer/store/TimelineSpace/Modals.js b/src/renderer/store/TimelineSpace/Modals.js
deleted file mode 100644
index 9afe0d2e..00000000
--- a/src/renderer/store/TimelineSpace/Modals.js
+++ /dev/null
@@ -1,37 +0,0 @@
-import NewToot from './Modals/NewToot'
-import ImageViewer from './Modals/ImageViewer'
-import Jump from './Modals/Jump'
-import ListMembership from './Modals/ListMembership'
-import AddListMember from './Modals/AddListMember'
-import MuteConfirm from './Modals/MuteConfirm'
-import Shortcut from './Modals/Shortcut'
-import Report from './Modals/Report'
-
-const Modals = {
- namespaced: true,
- modules: {
- ImageViewer,
- NewToot,
- Jump,
- ListMembership,
- AddListMember,
- MuteConfirm,
- Shortcut,
- Report
- },
- getters: {
- modalOpened: (state, getters, rootState) => {
- const imageViewer = rootState.TimelineSpace.Modals.ImageViewer.modalOpen
- const newToot = rootState.TimelineSpace.Modals.NewToot.modalOpen
- const jump = rootState.TimelineSpace.Modals.Jump.modalOpen
- const listMembership = rootState.TimelineSpace.Modals.ListMembership.modalOpen
- const addListMember = rootState.TimelineSpace.Modals.AddListMember.modalOpen
- const shortcut = rootState.TimelineSpace.Modals.Shortcut.modalOpen
- const muteConfirm = rootState.TimelineSpace.Modals.MuteConfirm.modalOpen
- const report = rootState.TimelineSpace.Modals.Report.modalOpen
- return imageViewer || newToot || jump || listMembership || addListMember || shortcut || muteConfirm || report
- }
- }
-}
-
-export default Modals
diff --git a/src/renderer/store/TimelineSpace/Modals.ts b/src/renderer/store/TimelineSpace/Modals.ts
new file mode 100644
index 00000000..6bfb4685
--- /dev/null
+++ b/src/renderer/store/TimelineSpace/Modals.ts
@@ -0,0 +1,46 @@
+import NewToot from './Modals/NewToot'
+import ImageViewer from './Modals/ImageViewer'
+import Jump from './Modals/Jump'
+import ListMembership from './Modals/ListMembership'
+import AddListMember from './Modals/AddListMember'
+import MuteConfirm from './Modals/MuteConfirm'
+import Shortcut from './Modals/Shortcut'
+import Report from './Modals/Report'
+import { Module, GetterTree } from 'vuex'
+
+export interface ModalsState {}
+
+const state = (): ModalsState => ({})
+
+// TODO: use type of rootState
+const getters: GetterTree = {
+ modalOpened: (_state, _getters, rootState) => {
+ const imageViewer = rootState.TimelineSpace.Modals.ImageViewer.modalOpen
+ const newToot = rootState.TimelineSpace.Modals.NewToot.modalOpen
+ const jump = rootState.TimelineSpace.Modals.Jump.modalOpen
+ const listMembership = rootState.TimelineSpace.Modals.ListMembership.modalOpen
+ const addListMember = rootState.TimelineSpace.Modals.AddListMember.modalOpen
+ const shortcut = rootState.TimelineSpace.Modals.Shortcut.modalOpen
+ const muteConfirm = rootState.TimelineSpace.Modals.MuteConfirm.modalOpen
+ const report = rootState.TimelineSpace.Modals.Report.modalOpen
+ return imageViewer || newToot || jump || listMembership || addListMember || shortcut || muteConfirm || report
+ }
+}
+
+const Modals: Module = {
+ namespaced: true,
+ modules: {
+ ImageViewer,
+ NewToot,
+ Jump,
+ ListMembership,
+ AddListMember,
+ MuteConfirm,
+ Shortcut,
+ Report
+ },
+ state: state,
+ getters: getters
+}
+
+export default Modals