From ab8c74b481d13eb8ced6f125b7b7b6abfe5f6084 Mon Sep 17 00:00:00 2001
From: AkiraFukushima
Date: Thu, 6 Jun 2019 23:44:50 +0900
Subject: [PATCH] refactor: Use type instead of interface
---
.../store/Preferences/Account.spec.ts | 37 ++++++++-----------
.../store/TimelineSpace/SideMenu.spec.ts | 2 +-
.../unit/store/Preferences/Account.spec.ts | 2 +-
.../store/TimelineSpace/Modals/Jump.spec.ts | 2 +-
src/constants/displayStyle/index.d.ts | 10 ++---
src/constants/visibility/index.d.ts | 14 +++----
src/main/account.ts | 2 +-
src/main/auth.ts | 2 +-
src/main/hashtags.ts | 12 +++---
src/main/index.ts | 4 +-
src/main/streaming.ts | 2 +-
src/main/streamingManager.ts | 2 +-
src/main/websocket.ts | 2 +-
src/renderer/store/Authorize.ts | 2 +-
src/renderer/store/GlobalHeader.ts | 10 ++---
src/renderer/store/Login.ts | 11 +++---
src/renderer/store/Preferences.ts | 14 ++++---
src/renderer/store/Preferences/Account.ts | 6 +--
src/renderer/store/Preferences/General.ts | 2 +-
src/renderer/store/Preferences/Language.ts | 2 +-
.../store/Preferences/Notification.ts | 2 +-
src/renderer/store/Settings.ts | 6 ++-
src/renderer/store/Settings/General.ts | 23 ++++--------
src/renderer/store/Settings/Timeline.ts | 2 +-
src/renderer/store/TimelineSpace.ts | 10 +++--
src/renderer/store/TimelineSpace/Contents.ts | 6 ++-
.../TimelineSpace/Contents/DirectMessages.ts | 2 +-
.../TimelineSpace/Contents/Favourites.ts | 4 +-
.../TimelineSpace/Contents/FollowRequests.ts | 2 +-
.../store/TimelineSpace/Contents/Hashtag.ts | 8 ++--
.../TimelineSpace/Contents/Hashtag/List.ts | 4 +-
.../TimelineSpace/Contents/Hashtag/Tag.ts | 2 +-
.../store/TimelineSpace/Contents/Home.ts | 2 +-
.../store/TimelineSpace/Contents/Lists.ts | 10 +++--
.../TimelineSpace/Contents/Lists/Edit.ts | 2 +-
.../TimelineSpace/Contents/Lists/Index.ts | 12 ++----
.../TimelineSpace/Contents/Lists/Show.ts | 2 +-
.../store/TimelineSpace/Contents/Local.ts | 2 +-
.../store/TimelineSpace/Contents/Mentions.ts | 2 +-
.../TimelineSpace/Contents/Notifications.ts | 2 +-
.../store/TimelineSpace/Contents/Public.ts | 2 +-
.../store/TimelineSpace/Contents/Search.ts | 6 ++-
.../TimelineSpace/Contents/Search/Account.ts | 2 +-
.../TimelineSpace/Contents/Search/Tag.ts | 2 +-
.../TimelineSpace/Contents/Search/Toots.ts | 2 +-
.../store/TimelineSpace/Contents/SideBar.ts | 10 +++--
.../Contents/SideBar/AccountProfile.ts | 6 ++-
.../SideBar/AccountProfile/Followers.ts | 14 ++-----
.../SideBar/AccountProfile/Follows.ts | 14 ++-----
.../SideBar/AccountProfile/Timeline.ts | 27 ++++++--------
.../Contents/SideBar/TootDetail.ts | 19 ++++------
.../store/TimelineSpace/HeaderMenu.ts | 2 +-
src/renderer/store/TimelineSpace/Modals.ts | 20 +++++-----
.../TimelineSpace/Modals/AddListMember.ts | 2 +-
.../store/TimelineSpace/Modals/ImageViewer.ts | 24 ++++++------
.../store/TimelineSpace/Modals/Jump.ts | 20 +++++-----
.../TimelineSpace/Modals/ListMembership.ts | 23 ++++--------
.../store/TimelineSpace/Modals/MuteConfirm.ts | 9 ++---
.../store/TimelineSpace/Modals/NewToot.ts | 6 ++-
.../TimelineSpace/Modals/NewToot/Status.ts | 2 +-
.../store/TimelineSpace/Modals/Report.ts | 9 ++---
.../store/TimelineSpace/Modals/Shortcut.ts | 2 +-
src/renderer/store/TimelineSpace/SideMenu.ts | 6 +--
src/renderer/store/index.ts | 22 +++++------
src/renderer/store/molecules.ts | 2 +-
src/renderer/store/molecules/Toot.ts | 2 +-
src/renderer/types/loadPosition.ts | 8 ++--
src/renderer/types/removeAccountFromList.ts | 2 +-
src/types/localAccount.ts | 2 +-
src/types/localTag.ts | 4 +-
70 files changed, 241 insertions(+), 275 deletions(-)
diff --git a/spec/renderer/integration/store/Preferences/Account.spec.ts b/spec/renderer/integration/store/Preferences/Account.spec.ts
index 8c7f3c7c..ee0962d8 100644
--- a/spec/renderer/integration/store/Preferences/Account.spec.ts
+++ b/spec/renderer/integration/store/Preferences/Account.spec.ts
@@ -2,7 +2,7 @@ import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import { ipcMain } from '~/spec/mock/electron'
import Account, { AccountState } from '@/store/Preferences/Account'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalAccount } from '~/src/types/localAccount'
const account: LocalAccount = {
_id: 'sample',
@@ -54,10 +54,9 @@ describe('Account', () => {
event.sender.send('error-list-accounts', new Error())
})
- await store.dispatch('Account/loadAccounts')
- .catch((err: Error) => {
- expect(err instanceof Error).toEqual(true)
- })
+ await store.dispatch('Account/loadAccounts').catch((err: Error) => {
+ expect(err instanceof Error).toEqual(true)
+ })
})
it('success', async () => {
ipcMain.once('list-accounts', (event: any, _) => {
@@ -73,10 +72,9 @@ describe('Account', () => {
ipcMain.once('remove-account', (event: any, _) => {
event.sender.send('error-remove-account', new Error())
})
- await store.dispatch('Account/removeAccount', account)
- .catch((err: Error) => {
- expect(err instanceof Error).toEqual(true)
- })
+ await store.dispatch('Account/removeAccount', account).catch((err: Error) => {
+ expect(err instanceof Error).toEqual(true)
+ })
})
it('success', async () => {
ipcMain.once('remove-account', (event: any, _) => {
@@ -92,10 +90,9 @@ describe('Account', () => {
ipcMain.once('forward-account', (event: any, _) => {
event.sender.send('error-forward-account', new Error())
})
- await store.dispatch('Account/forwardAccount', account)
- .catch((err: Error) => {
- expect(err instanceof Error).toEqual(true)
- })
+ await store.dispatch('Account/forwardAccount', account).catch((err: Error) => {
+ expect(err instanceof Error).toEqual(true)
+ })
})
it('success', async () => {
ipcMain.once('forward-account', (event: any, _) => {
@@ -111,10 +108,9 @@ describe('Account', () => {
ipcMain.once('backward-account', (event: any, _) => {
event.sender.send('error-backward-account', new Error())
})
- await store.dispatch('Account/backwardAccount', account)
- .catch((err: Error) => {
- expect(err instanceof Error).toEqual(true)
- })
+ await store.dispatch('Account/backwardAccount', account).catch((err: Error) => {
+ expect(err instanceof Error).toEqual(true)
+ })
})
it('success', async () => {
ipcMain.once('backward-account', (event: any, _) => {
@@ -130,10 +126,9 @@ describe('Account', () => {
ipcMain.once('remove-all-accounts', (event: any, _) => {
event.sender.send('error-remove-all-accounts', new Error())
})
- await store.dispatch('Account/removeAllAccounts', account)
- .catch((err: Error) => {
- expect(err instanceof Error).toEqual(true)
- })
+ await store.dispatch('Account/removeAllAccounts', account).catch((err: Error) => {
+ expect(err instanceof Error).toEqual(true)
+ })
})
it('success', async () => {
ipcMain.once('remove-all-accounts', (event: any, _) => {
diff --git a/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts b/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts
index 08dc9137..f4346b8d 100644
--- a/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts
+++ b/spec/renderer/integration/store/TimelineSpace/SideMenu.spec.ts
@@ -4,7 +4,7 @@ import { createLocalVue } from '@vue/test-utils'
import Vuex from 'vuex'
import { ipcMain } from '~/spec/mock/electron'
import SideMenu, { SideMenuState } from '~/src/renderer/store/TimelineSpace/SideMenu'
-import LocalTag from '~/src/types/localTag'
+import { LocalTag } from '~/src/types/localTag'
jest.mock('megalodon')
diff --git a/spec/renderer/unit/store/Preferences/Account.spec.ts b/spec/renderer/unit/store/Preferences/Account.spec.ts
index ba1e225a..9fc23fe1 100644
--- a/spec/renderer/unit/store/Preferences/Account.spec.ts
+++ b/spec/renderer/unit/store/Preferences/Account.spec.ts
@@ -1,5 +1,5 @@
import Account, { AccountState, MUTATION_TYPES } from '@/store/Preferences/Account'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalAccount } from '~/src/types/localAccount'
const account: LocalAccount = {
_id: 'sample',
diff --git a/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts b/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts
index b5560458..b594a5a5 100644
--- a/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts
+++ b/spec/renderer/unit/store/TimelineSpace/Modals/Jump.spec.ts
@@ -1,6 +1,6 @@
import i18n from '~/src/config/i18n'
import Jump, { JumpState, MUTATION_TYPES, Channel } from '@/store/TimelineSpace/Modals/Jump'
-import LocalTag from '~/src/types/localTag'
+import { LocalTag } from '~/src/types/localTag'
import { List } from 'megalodon'
describe('TimelineSpace/Modals/Jump', () => {
diff --git a/src/constants/displayStyle/index.d.ts b/src/constants/displayStyle/index.d.ts
index e8139aee..b00a23d1 100644
--- a/src/constants/displayStyle/index.d.ts
+++ b/src/constants/displayStyle/index.d.ts
@@ -1,11 +1,11 @@
-export interface DisplayStyleType {
- name: string,
+export type DisplayStyleType = {
+ name: string
value: number
}
-export interface DisplayStyleList {
- DisplayNameAndUsername: DisplayStyleType,
- DisplayName: DisplayStyleType,
+export type DisplayStyleList = {
+ DisplayNameAndUsername: DisplayStyleType
+ DisplayName: DisplayStyleType
Username: DisplayStyleType
}
diff --git a/src/constants/visibility/index.d.ts b/src/constants/visibility/index.d.ts
index 588c9642..f1a063a0 100644
--- a/src/constants/visibility/index.d.ts
+++ b/src/constants/visibility/index.d.ts
@@ -1,13 +1,13 @@
-export interface VisibilityType {
- name: string,
- value: number,
+export type VisibilityType = {
+ name: string
+ value: number
key: string
}
-export interface VisibilityList {
- Public: VisibilityType,
- Unlisted: VisibilityType,
- Private: VisibilityType,
+export type VisibilityList = {
+ Public: VisibilityType
+ Unlisted: VisibilityType
+ Private: VisibilityType
Direct: VisibilityType
}
diff --git a/src/main/account.ts b/src/main/account.ts
index 3fe49397..86ddfc1a 100644
--- a/src/main/account.ts
+++ b/src/main/account.ts
@@ -2,7 +2,7 @@ import { isEmpty } from 'lodash'
import Mastodon, { Account as RemoteAccount } from 'megalodon'
import Datastore from 'nedb'
import log from 'electron-log'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalAccount } from '~/src/types/localAccount'
export default class Account {
private db: Datastore
diff --git a/src/main/auth.ts b/src/main/auth.ts
index a72004bb..9fcbb64b 100644
--- a/src/main/auth.ts
+++ b/src/main/auth.ts
@@ -1,6 +1,6 @@
import Mastodon, { OAuth } from 'megalodon'
import Account from './account'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalAccount } from '~/src/types/localAccount'
const appName = 'Whalebird'
const appURL = 'https://whalebird.org'
diff --git a/src/main/hashtags.ts b/src/main/hashtags.ts
index 9e50dfde..38e60790 100644
--- a/src/main/hashtags.ts
+++ b/src/main/hashtags.ts
@@ -1,15 +1,15 @@
import Datastore from 'nedb'
-import LocalTag from '~/src/types/localTag'
+import { LocalTag } from '~/src/types/localTag'
export default class Hashtags {
private db: Datastore
- constructor (db: Datastore) {
+ constructor(db: Datastore) {
this.db = db
- this.db.ensureIndex({ fieldName: 'tagName', unique: true }, (_) => {})
+ this.db.ensureIndex({ fieldName: 'tagName', unique: true }, _ => {})
}
- listTags (): Promise> {
+ listTags(): Promise> {
return new Promise((resolve, reject) => {
this.db.find({}, (err, docs) => {
if (err) return reject(err)
@@ -18,7 +18,7 @@ export default class Hashtags {
})
}
- insertTag (tag: string): Promise {
+ insertTag(tag: string): Promise {
return new Promise((resolve, reject) => {
this.db.insert({ tagName: tag }, (err, doc) => {
if (err) return reject(err)
@@ -27,7 +27,7 @@ export default class Hashtags {
})
}
- removeTag (localTag: LocalTag): Promise {
+ removeTag(localTag: LocalTag): Promise {
return new Promise((resolve, reject) => {
this.db.remove(
{
diff --git a/src/main/index.ts b/src/main/index.ts
index 55e5ef74..5ad18f9c 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -31,8 +31,8 @@ import Hashtags from './hashtags'
import UnreadNotification from './unreadNotification'
import i18n from '../config/i18n'
import Language from '../constants/language'
-import LocalAccount from '~/src/types/localAccount'
-import LocalTag from '~/src/types/localTag'
+import { LocalAccount } from '~/src/types/localAccount'
+import { LocalTag } from '~/src/types/localTag'
import { UnreadNotification as UnreadNotificationConfig } from '~/src/types/unreadNotification'
/**
diff --git a/src/main/streaming.ts b/src/main/streaming.ts
index 80d8c0ef..832a488f 100644
--- a/src/main/streaming.ts
+++ b/src/main/streaming.ts
@@ -1,6 +1,6 @@
import Mastodon, { StreamListener, Status, Notification } from 'megalodon'
import log from 'electron-log'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalAccount } from '~/src/types/localAccount'
export default class Streaming {
private client: Mastodon
diff --git a/src/main/streamingManager.ts b/src/main/streamingManager.ts
index 9a7dd513..6ea5943c 100644
--- a/src/main/streamingManager.ts
+++ b/src/main/streamingManager.ts
@@ -1,6 +1,6 @@
import Streaming from './streaming'
import WebSocket from './websocket'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalAccount } from '~/src/types/localAccount'
export default class StreamingManager {
private streaming: Streaming
diff --git a/src/main/websocket.ts b/src/main/websocket.ts
index dc73cf07..15b0683a 100644
--- a/src/main/websocket.ts
+++ b/src/main/websocket.ts
@@ -1,6 +1,6 @@
import Mastodon, { WebSocket as SocketListener, Status, Notification } from 'megalodon'
import log from 'electron-log'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalAccount } from '~/src/types/localAccount'
export default class WebSocket {
private client: Mastodon
diff --git a/src/renderer/store/Authorize.ts b/src/renderer/store/Authorize.ts
index ac8fded1..9a64fee5 100644
--- a/src/renderer/store/Authorize.ts
+++ b/src/renderer/store/Authorize.ts
@@ -2,7 +2,7 @@ import { ipcRenderer } from 'electron'
import { Module, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface AuthorizeState {}
+export type AuthorizeState = {}
const state = (): AuthorizeState => ({})
diff --git a/src/renderer/store/GlobalHeader.ts b/src/renderer/store/GlobalHeader.ts
index cbc4e587..09a0db4d 100644
--- a/src/renderer/store/GlobalHeader.ts
+++ b/src/renderer/store/GlobalHeader.ts
@@ -1,12 +1,12 @@
import { ipcRenderer } from 'electron'
import router from '@/router'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalAccount } from '~/src/types/localAccount'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface GlobalHeaderState {
- accounts: Array,
- changing: boolean,
+export type GlobalHeaderState = {
+ accounts: Array
+ changing: boolean
hide: boolean
}
@@ -70,7 +70,7 @@ const actions: ActionTree = {
if (state.changing) {
return null
}
- if (rootState.route.params.id as string === account._id!) {
+ if ((rootState.route.params.id as string) === account._id!) {
return null
}
// When the modal window is active, don't change account
diff --git a/src/renderer/store/Login.ts b/src/renderer/store/Login.ts
index afb5e71b..6ce8ee0d 100644
--- a/src/renderer/store/Login.ts
+++ b/src/renderer/store/Login.ts
@@ -3,8 +3,8 @@ import axios from 'axios'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface LoginState {
- selectedInstance: string | null,
+export type LoginState = {
+ selectedInstance: string | null
searching: boolean
}
@@ -46,10 +46,9 @@ const actions: ActionTree = {
},
confirmInstance: async ({ commit }, domain: string): Promise => {
commit(MUTATION_TYPES.CHANGE_SEARCHING, true)
- await axios.get(`https://${domain}/api/v1/instance`)
- .finally(() => {
- commit(MUTATION_TYPES.CHANGE_SEARCHING, false)
- })
+ await axios.get(`https://${domain}/api/v1/instance`).finally(() => {
+ commit(MUTATION_TYPES.CHANGE_SEARCHING, false)
+ })
commit(MUTATION_TYPES.CHANGE_INSTANCE, domain)
return true
}
diff --git a/src/renderer/store/Preferences.ts b/src/renderer/store/Preferences.ts
index 0c8491e0..1f7a1d04 100644
--- a/src/renderer/store/Preferences.ts
+++ b/src/renderer/store/Preferences.ts
@@ -6,18 +6,20 @@ import Notification, { NotificationState } from './Preferences/Notification'
import { Module } from 'vuex'
import { RootState } from '@/store'
-export interface PreferencesState {}
+export type PreferencesState = {}
const state = (): PreferencesState => ({})
-export interface PreferencesModuleState extends PreferencesState {
- General: GeneralState,
- Account: AccountState,
- Language: LanguageState,
- Notification: NotificationState,
+type PreferencesModule = {
+ General: GeneralState
+ Account: AccountState
+ Language: LanguageState
+ Notification: NotificationState
Appearance: AppearanceState
}
+export type PreferencesModuleState = PreferencesState & PreferencesModule
+
const Preferences: Module = {
namespaced: true,
modules: {
diff --git a/src/renderer/store/Preferences/Account.ts b/src/renderer/store/Preferences/Account.ts
index 4f5ce455..5b47ce75 100644
--- a/src/renderer/store/Preferences/Account.ts
+++ b/src/renderer/store/Preferences/Account.ts
@@ -1,10 +1,10 @@
import { ipcRenderer } from 'electron'
import { Module, MutationTree, ActionTree } from 'vuex'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalAccount } from '~/src/types/localAccount'
import { RootState } from '@/store'
-export interface AccountState {
- accounts: Array,
+export type AccountState = {
+ accounts: Array
accountLoading: boolean
}
diff --git a/src/renderer/store/Preferences/General.ts b/src/renderer/store/Preferences/General.ts
index 1aad8e6a..721e4a5d 100644
--- a/src/renderer/store/Preferences/General.ts
+++ b/src/renderer/store/Preferences/General.ts
@@ -5,7 +5,7 @@ import { Sound } from '~/src/types/sound'
import { Timeline } from '~/src/types/timeline'
import { BaseConfig, General } from '~/src/types/preference'
-export interface GeneralState {
+export type GeneralState = {
general: General
loading: boolean
}
diff --git a/src/renderer/store/Preferences/Language.ts b/src/renderer/store/Preferences/Language.ts
index 8f95d035..0d32dc38 100644
--- a/src/renderer/store/Preferences/Language.ts
+++ b/src/renderer/store/Preferences/Language.ts
@@ -5,7 +5,7 @@ import { RootState } from '@/store'
import { Language as LanguageSet } from '~/src/types/language'
import { BaseConfig } from '~/src/types/preference'
-export interface LanguageState {
+export type LanguageState = {
language: LanguageSet
}
diff --git a/src/renderer/store/Preferences/Notification.ts b/src/renderer/store/Preferences/Notification.ts
index 5260db49..2a487633 100644
--- a/src/renderer/store/Preferences/Notification.ts
+++ b/src/renderer/store/Preferences/Notification.ts
@@ -4,7 +4,7 @@ import { RootState } from '@/store'
import { Notify } from '~/src/types/notify'
import { BaseConfig, Notification } from '~/src/types/preference'
-export interface NotificationState {
+export type NotificationState = {
notification: Notification
}
diff --git a/src/renderer/store/Settings.ts b/src/renderer/store/Settings.ts
index b511ac10..a9015a1b 100644
--- a/src/renderer/store/Settings.ts
+++ b/src/renderer/store/Settings.ts
@@ -3,7 +3,7 @@ import Timeline, { TimelineState } from './Settings/Timeline'
import { Module, MutationTree } from 'vuex'
import { RootState } from '@/store'
-export interface SettingsState {
+export type SettingsState = {
accountID: string | null
}
@@ -21,11 +21,13 @@ const mutations: MutationTree = {
}
}
-export interface SettingsModuleState extends SettingsState {
+type SettingsModule = {
General: GeneralState
Timeline: TimelineState
}
+export type SettingsModuleState = SettingsModule & SettingsState
+
const Settings: Module = {
namespaced: true,
modules: {
diff --git a/src/renderer/store/Settings/General.ts b/src/renderer/store/Settings/General.ts
index d545efd1..d14cc21c 100644
--- a/src/renderer/store/Settings/General.ts
+++ b/src/renderer/store/Settings/General.ts
@@ -3,8 +3,8 @@ import { Module, MutationTree, ActionTree } from 'vuex'
import Visibility, { VisibilityType } from '~/src/constants/visibility'
import { RootState } from '@/store'
-export interface GeneralState {
- visibility: number,
+export type GeneralState = {
+ visibility: number
sensitive: boolean
}
@@ -29,12 +29,9 @@ const mutations: MutationTree = {
const actions: ActionTree = {
fetchSettings: async ({ commit, rootState }): Promise => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res = await client.get('/accounts/verify_credentials')
- const visibility: VisibilityType | undefined = (Object.values(Visibility) as Array).find((v) => {
+ const visibility: VisibilityType | undefined = (Object.values(Visibility) as Array).find(v => {
return v.key === res.data.source!.privacy
})
commit(MUTATION_TYPES.CHANGE_VISIBILITY, visibility!.value)
@@ -42,11 +39,8 @@ const actions: ActionTree = {
return res.data
},
setVisibility: async ({ commit, rootState }, value: number) => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
- const visibility: VisibilityType | undefined = (Object.values(Visibility) as Array).find((v) => {
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
+ const visibility: VisibilityType | undefined = (Object.values(Visibility) as Array).find(v => {
return v.value === value
})
const res = await client.patch('/accounts/update_credentials', {
@@ -58,10 +52,7 @@ const actions: ActionTree = {
return res.data
},
setSensitive: async ({ commit, rootState }, value: boolean) => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res = await client.patch('/accounts/update_credentials', {
source: {
sensitive: value
diff --git a/src/renderer/store/Settings/Timeline.ts b/src/renderer/store/Settings/Timeline.ts
index 6e91efee..301601e7 100644
--- a/src/renderer/store/Settings/Timeline.ts
+++ b/src/renderer/store/Settings/Timeline.ts
@@ -4,7 +4,7 @@ import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
import { UnreadNotification } from '~/src/types/unreadNotification'
-export interface TimelineState {
+export type TimelineState = {
unreadNotification: UnreadNotification
}
diff --git a/src/renderer/store/TimelineSpace.ts b/src/renderer/store/TimelineSpace.ts
index 01edf8b1..49b353cc 100644
--- a/src/renderer/store/TimelineSpace.ts
+++ b/src/renderer/store/TimelineSpace.ts
@@ -8,7 +8,7 @@ import Contents, { ContentsModuleState } from './TimelineSpace/Contents'
import router from '@/router'
import unreadSettings from '~/src/constants/unreadNotification'
import { Module, MutationTree, ActionTree } from 'vuex'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalAccount } from '~/src/types/localAccount'
import { Notify } from '~/src/types/notify'
import { RootState } from '@/store'
import { UnreadNotification } from '~/src/types/unreadNotification'
@@ -17,12 +17,12 @@ import { TimelineFetchError } from '@/errors/fetch'
declare var Notification: any
-interface MyEmoji {
+type MyEmoji = {
name: string
image: string
}
-export interface TimelineSpaceState {
+export type TimelineSpaceState = {
account: LocalAccount
loading: boolean
emojis: Array
@@ -479,13 +479,15 @@ const actions: ActionTree = {
}
}
-export interface TimelineSpaceModuleState extends TimelineSpaceState {
+type TimelineSpaceModule = {
SideMenu: SideMenuState
HeaderMenu: HeaderMenuState
Modals: ModalsModuleState
Contents: ContentsModuleState
}
+export type TimelineSpaceModuleState = TimelineSpaceModule & TimelineSpaceState
+
const TimelineSpace: Module = {
namespaced: true,
modules: {
diff --git a/src/renderer/store/TimelineSpace/Contents.ts b/src/renderer/store/TimelineSpace/Contents.ts
index 5f492331..3d44456d 100644
--- a/src/renderer/store/TimelineSpace/Contents.ts
+++ b/src/renderer/store/TimelineSpace/Contents.ts
@@ -13,11 +13,11 @@ import Mentions, { MentionsState } from './Contents/Mentions'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface ContentsState {
+export type ContentsState = {
loading: boolean
}
-export interface ContentsModuleState extends ContentsState {
+type ContentsModule = {
SideBar: SideBarModuleState
Home: HomeState
Notifications: NotificationsState
@@ -31,6 +31,8 @@ export interface ContentsModuleState extends ContentsState {
FollowRequests: FollowRequestsState
}
+export type ContentsModuleState = ContentsModule & ContentsState
+
const state = (): ContentsState => ({
loading: false
})
diff --git a/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts b/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts
index 7ff7a96d..b6518624 100644
--- a/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts
+++ b/src/renderer/store/TimelineSpace/Contents/DirectMessages.ts
@@ -2,7 +2,7 @@ import Mastodon, { Status, Response } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface DirectMessagesState {
+export type DirectMessagesState = {
lazyLoading: boolean
heading: boolean
timeline: Array
diff --git a/src/renderer/store/TimelineSpace/Contents/Favourites.ts b/src/renderer/store/TimelineSpace/Contents/Favourites.ts
index c2be32b3..3c8a8a14 100644
--- a/src/renderer/store/TimelineSpace/Contents/Favourites.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Favourites.ts
@@ -2,9 +2,9 @@ import Mastodon, { Status, Response } from 'megalodon'
import parse from 'parse-link-header'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalAccount } from '~/src/types/localAccount'
-export interface FavouritesState {
+export type FavouritesState = {
favourites: Array
lazyLoading: boolean
filter: string
diff --git a/src/renderer/store/TimelineSpace/Contents/FollowRequests.ts b/src/renderer/store/TimelineSpace/Contents/FollowRequests.ts
index 14d24964..9aab5f03 100644
--- a/src/renderer/store/TimelineSpace/Contents/FollowRequests.ts
+++ b/src/renderer/store/TimelineSpace/Contents/FollowRequests.ts
@@ -2,7 +2,7 @@ import Mastodon, { Account, Response } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface FollowRequestsState {
+export type FollowRequestsState = {
requests: Array
}
diff --git a/src/renderer/store/TimelineSpace/Contents/Hashtag.ts b/src/renderer/store/TimelineSpace/Contents/Hashtag.ts
index 281b9e5c..86e29fcf 100644
--- a/src/renderer/store/TimelineSpace/Contents/Hashtag.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Hashtag.ts
@@ -4,13 +4,15 @@ import Tag, { TagState } from './Hashtag/Tag'
import { Module, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface HashtagState {}
+export type HashtagState = {}
-export interface HashtagModuleState extends HashtagState {
- List: ListState,
+type HashtagModule = {
+ List: ListState
Tag: TagState
}
+export type HashtagModuleState = HashtagModule & HashtagState
+
const state = (): HashtagState => ({})
const actions: ActionTree = {
diff --git a/src/renderer/store/TimelineSpace/Contents/Hashtag/List.ts b/src/renderer/store/TimelineSpace/Contents/Hashtag/List.ts
index 4b814345..62d59284 100644
--- a/src/renderer/store/TimelineSpace/Contents/Hashtag/List.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Hashtag/List.ts
@@ -1,9 +1,9 @@
import { ipcRenderer } from 'electron'
-import LocalTag from '~/src/types/localTag'
+import { LocalTag } from '~/src/types/localTag'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface ListState {
+export type ListState = {
tags: Array
}
diff --git a/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts b/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts
index c7d46df3..a7b5e8fe 100644
--- a/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Hashtag/Tag.ts
@@ -4,7 +4,7 @@ import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
import { LoadPositionWithTag } from '@/types/loadPosition'
-export interface TagState {
+export type TagState = {
timeline: Array
unreadTimeline: Array
lazyLoading: boolean
diff --git a/src/renderer/store/TimelineSpace/Contents/Home.ts b/src/renderer/store/TimelineSpace/Contents/Home.ts
index 575f379d..501d2035 100644
--- a/src/renderer/store/TimelineSpace/Contents/Home.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Home.ts
@@ -2,7 +2,7 @@ import Mastodon, { Status, Response } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface HomeState {
+export type HomeState = {
lazyLoading: boolean
heading: boolean
showReblogs: boolean
diff --git a/src/renderer/store/TimelineSpace/Contents/Lists.ts b/src/renderer/store/TimelineSpace/Contents/Lists.ts
index e2589b3c..83afc4d4 100644
--- a/src/renderer/store/TimelineSpace/Contents/Lists.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Lists.ts
@@ -4,14 +4,16 @@ import Edit, { EditState } from './Lists/Edit'
import { Module } from 'vuex'
import { RootState } from '@/store'
-export interface ListsState {}
+export type ListsState = {}
-export interface ListsModuleState extends ListsState {
- Index: IndexState,
- Show: ShowState,
+type ListModule = {
+ Index: IndexState
+ Show: ShowState
Edit: EditState
}
+export type ListsModuleState = ListModule & ListsState
+
const state = (): ListsState => ({})
export default {
diff --git a/src/renderer/store/TimelineSpace/Contents/Lists/Edit.ts b/src/renderer/store/TimelineSpace/Contents/Lists/Edit.ts
index b7c4d63f..45ea199d 100644
--- a/src/renderer/store/TimelineSpace/Contents/Lists/Edit.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Lists/Edit.ts
@@ -3,7 +3,7 @@ import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
import { RemoveAccountFromList } from '@/types/removeAccountFromList'
-export interface EditState {
+export type EditState = {
members: Array
}
diff --git a/src/renderer/store/TimelineSpace/Contents/Lists/Index.ts b/src/renderer/store/TimelineSpace/Contents/Lists/Index.ts
index 7d9bdaf6..33a59955 100644
--- a/src/renderer/store/TimelineSpace/Contents/Lists/Index.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Lists/Index.ts
@@ -2,7 +2,7 @@ import Mastodon, { List, Response } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface IndexState {
+export type IndexState = {
lists: Array
}
@@ -22,19 +22,13 @@ const mutations: MutationTree = {
const actions: ActionTree = {
fetchLists: async ({ commit, rootState }): Promise> => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response> = await client.get>('/lists')
commit(MUTATION_TYPES.CHANGE_LISTS, res.data)
return res.data
},
createList: async ({ rootState }, title: string): Promise => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response = await client.post('/lists', {
title: title
})
diff --git a/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts b/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts
index 75002e65..9b5a36c0 100644
--- a/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Lists/Show.ts
@@ -4,7 +4,7 @@ import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
import { LoadPositionWithList } from '@/types/loadPosition'
-export interface ShowState {
+export type ShowState = {
timeline: Array
unreadTimeline: Array
lazyLoading: boolean
diff --git a/src/renderer/store/TimelineSpace/Contents/Local.ts b/src/renderer/store/TimelineSpace/Contents/Local.ts
index 74c7109d..a86e1b2b 100644
--- a/src/renderer/store/TimelineSpace/Contents/Local.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Local.ts
@@ -2,7 +2,7 @@ import Mastodon, { Status, Response } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface LocalState {
+export type LocalState = {
timeline: Array
unreadTimeline: Array
lazyLoading: boolean
diff --git a/src/renderer/store/TimelineSpace/Contents/Mentions.ts b/src/renderer/store/TimelineSpace/Contents/Mentions.ts
index 4adcd34b..07c4b8c2 100644
--- a/src/renderer/store/TimelineSpace/Contents/Mentions.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Mentions.ts
@@ -2,7 +2,7 @@ import Mastodon, { Notification, Response } from 'megalodon'
import { Module, MutationTree, ActionTree, GetterTree } from 'vuex'
import { RootState } from '@/store'
-export interface MentionsState {
+export type MentionsState = {
lazyLoading: boolean
heading: boolean
mentions: Array
diff --git a/src/renderer/store/TimelineSpace/Contents/Notifications.ts b/src/renderer/store/TimelineSpace/Contents/Notifications.ts
index 1ba45e80..edbdc308 100644
--- a/src/renderer/store/TimelineSpace/Contents/Notifications.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Notifications.ts
@@ -3,7 +3,7 @@ import Mastodon, { Notification, Status, Response } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface NotificationsState {
+export type NotificationsState = {
lazyLoading: boolean
heading: boolean
notifications: Array
diff --git a/src/renderer/store/TimelineSpace/Contents/Public.ts b/src/renderer/store/TimelineSpace/Contents/Public.ts
index 64370843..4e0d2834 100644
--- a/src/renderer/store/TimelineSpace/Contents/Public.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Public.ts
@@ -2,7 +2,7 @@ import Mastodon, { Status, Response } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface PublicState {
+export type PublicState = {
timeline: Array
unreadTimeline: Array
lazyLoading: boolean
diff --git a/src/renderer/store/TimelineSpace/Contents/Search.ts b/src/renderer/store/TimelineSpace/Contents/Search.ts
index 2e9581a6..d4e5dd87 100644
--- a/src/renderer/store/TimelineSpace/Contents/Search.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Search.ts
@@ -4,14 +4,16 @@ import Toots, { TootsState } from './Search/Toots'
import { Module } from 'vuex'
import { RootState } from '@/store'
-export interface SearchState {}
+export type SearchState = {}
-export interface SearchModuleState extends SearchState {
+type SearchModule = {
Account: AccountState
Tag: TagState
Toots: TootsState
}
+export type SearchModuleState = SearchModule & SearchState
+
const state = (): SearchState => ({})
const Search: Module = {
diff --git a/src/renderer/store/TimelineSpace/Contents/Search/Account.ts b/src/renderer/store/TimelineSpace/Contents/Search/Account.ts
index 3dd82db8..323256e0 100644
--- a/src/renderer/store/TimelineSpace/Contents/Search/Account.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Search/Account.ts
@@ -2,7 +2,7 @@ import Mastodon, { Account } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface AccountState {
+export type AccountState = {
results: Array
}
diff --git a/src/renderer/store/TimelineSpace/Contents/Search/Tag.ts b/src/renderer/store/TimelineSpace/Contents/Search/Tag.ts
index 64cdab5e..30d337ab 100644
--- a/src/renderer/store/TimelineSpace/Contents/Search/Tag.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Search/Tag.ts
@@ -2,7 +2,7 @@ import Mastodon, { Tag, Results } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface TagState {
+export type TagState = {
results: Array
}
diff --git a/src/renderer/store/TimelineSpace/Contents/Search/Toots.ts b/src/renderer/store/TimelineSpace/Contents/Search/Toots.ts
index c4bd421f..8ac271ca 100644
--- a/src/renderer/store/TimelineSpace/Contents/Search/Toots.ts
+++ b/src/renderer/store/TimelineSpace/Contents/Search/Toots.ts
@@ -2,7 +2,7 @@ import Mastodon, { Status, Results } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface TootsState {
+export type TootsState = {
results: Array
}
diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar.ts b/src/renderer/store/TimelineSpace/Contents/SideBar.ts
index 8b5c290e..9cfbb15e 100644
--- a/src/renderer/store/TimelineSpace/Contents/SideBar.ts
+++ b/src/renderer/store/TimelineSpace/Contents/SideBar.ts
@@ -3,19 +3,21 @@ import TootDetail, { TootDetailState } from './SideBar/TootDetail'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface SideBarState {
- openSideBar: boolean,
+export type SideBarState = {
+ openSideBar: boolean
// 0: blank
// 1: account-profile
// 2: toot-detail
component: number
}
-export interface SideBarModuleState extends SideBarState {
- TootDetail: TootDetailState,
+type SideBarModule = {
+ TootDetail: TootDetailState
AccountProfile: AccountProfileModuleState
}
+export type SideBarModuleState = SideBarModule & SideBarState
+
const state = (): SideBarState => ({
openSideBar: false,
component: 0
diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts
index c7c053a9..6836e526 100644
--- a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts
+++ b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile.ts
@@ -5,18 +5,20 @@ import Followers, { FollowersState } from './AccountProfile/Followers'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface AccountProfileState {
+export type AccountProfileState = {
account: Account | null
relationship: Relationship | null
loading: boolean
}
-export interface AccountProfileModuleState extends AccountProfileState {
+type AccountProfileModule = {
Followers: FollowersState
Follows: FollowsState
Timeline: TimelineState
}
+export type AccountProfileModuleState = AccountProfileModule & AccountProfileState
+
const state = (): AccountProfileState => ({
account: null,
relationship: null,
diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Followers.ts b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Followers.ts
index 693be910..3d76b226 100644
--- a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Followers.ts
+++ b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Followers.ts
@@ -2,8 +2,8 @@ import Mastodon, { Account, Relationship, Response } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface FollowersState {
- followers: Array,
+export type FollowersState = {
+ followers: Array
relationships: Array
}
@@ -28,20 +28,14 @@ const mutations: MutationTree = {
const actions: ActionTree = {
fetchFollowers: async ({ commit, rootState }, account: Account) => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response> = await client.get>(`/accounts/${account.id}/followers`, { limit: 80 })
commit(MUTATION_TYPES.UPDATE_FOLLOWERS, res.data)
return res.data
},
fetchRelationships: async ({ commit, rootState }, accounts: Array) => {
const ids = accounts.map(a => a.id)
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response> = await client.get>(`/accounts/relationships`, {
id: ids
})
diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Follows.ts b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Follows.ts
index 568b19a6..e793f64f 100644
--- a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Follows.ts
+++ b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Follows.ts
@@ -2,8 +2,8 @@ import Mastodon, { Account, Relationship, Response } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface FollowsState {
- follows: Array,
+export type FollowsState = {
+ follows: Array
relationships: Array
}
@@ -28,20 +28,14 @@ const mutations: MutationTree = {
const actions: ActionTree = {
fetchFollows: async ({ commit, rootState }, account: Account) => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response> = await client.get>(`/accounts/${account.id}/following`, { limit: 80 })
commit(MUTATION_TYPES.UPDATE_FOLLOWS, res.data)
return res.data
},
fetchRelationships: async ({ commit, rootState }, accounts: Array) => {
const ids = accounts.map(a => a.id)
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response> = await client.get>(`/accounts/relationships`, {
id: ids
})
diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Timeline.ts b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Timeline.ts
index 87d67325..26238d4e 100644
--- a/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Timeline.ts
+++ b/src/renderer/store/TimelineSpace/Contents/SideBar/AccountProfile/Timeline.ts
@@ -3,9 +3,9 @@ import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
import { LoadPositionWithAccount } from '@/types/loadPosition'
-export interface TimelineState {
- timeline: Array,
- pinnedToots: Array,
+export type TimelineState = {
+ timeline: Array
+ pinnedToots: Array
lazyLoading: boolean
}
@@ -39,7 +39,7 @@ const mutations: MutationTree = {
state.lazyLoading = value
},
[MUTATION_TYPES.UPDATE_PINNED_TOOT]: (state, message: Status) => {
- state.pinnedToots = state.pinnedToots.map((toot) => {
+ state.pinnedToots = state.pinnedToots.map(toot => {
if (toot.id === message.id) {
return message
} else if (toot.reblog !== null && toot.reblog.id === message.id) {
@@ -56,7 +56,7 @@ const mutations: MutationTree = {
},
[MUTATION_TYPES.UPDATE_TOOT]: (state, message: Status) => {
// Replace target message in timeline
- state.timeline = state.timeline.map((toot) => {
+ state.timeline = state.timeline.map(toot => {
if (toot.id === message.id) {
return message
} else if (toot.reblog !== null && toot.reblog.id === message.id) {
@@ -72,7 +72,7 @@ const mutations: MutationTree = {
})
},
[MUTATION_TYPES.DELETE_TOOT]: (state, message: Status) => {
- state.timeline = state.timeline.filter((toot) => {
+ state.timeline = state.timeline.filter(toot => {
if (toot.reblog !== null && toot.reblog.id === message.id) {
return false
} else {
@@ -85,10 +85,7 @@ const mutations: MutationTree = {
const actions: ActionTree = {
fetchTimeline: async ({ commit, rootState }, account: Account) => {
commit('TimelineSpace/Contents/SideBar/AccountProfile/changeLoading', true, { root: true })
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const pinned: Response> = await client.get>(`/accounts/${account.id}/statuses`, { limit: 10, pinned: true })
commit(MUTATION_TYPES.UPDATE_PINNED_TOOTS, pinned.data)
const res: Response> = await client.get>(`/accounts/${account.id}/statuses`, { limit: 40 })
@@ -101,12 +98,12 @@ const actions: ActionTree = {
return Promise.resolve(null)
}
commit(MUTATION_TYPES.CHANGE_LAZY_LOADING, true)
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
try {
- const res: Response> = await client.get>(`/accounts/${loadPosition.account.id}/statuses`, { max_id: loadPosition.status.id, limit: 40 })
+ const res: Response> = await client.get>(`/accounts/${loadPosition.account.id}/statuses`, {
+ max_id: loadPosition.status.id,
+ limit: 40
+ })
commit(MUTATION_TYPES.INSERT_TIMELINE, res.data)
} finally {
commit(MUTATION_TYPES.CHANGE_LAZY_LOADING, false)
diff --git a/src/renderer/store/TimelineSpace/Contents/SideBar/TootDetail.ts b/src/renderer/store/TimelineSpace/Contents/SideBar/TootDetail.ts
index e880a08f..738a3881 100644
--- a/src/renderer/store/TimelineSpace/Contents/SideBar/TootDetail.ts
+++ b/src/renderer/store/TimelineSpace/Contents/SideBar/TootDetail.ts
@@ -2,9 +2,9 @@ import Mastodon, { Status, Context, Response } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface TootDetailState {
- message: Status | null,
- ancestors: Array,
+export type TootDetailState = {
+ message: Status | null
+ ancestors: Array
descendants: Array
}
@@ -38,7 +38,7 @@ const mutations: MutationTree = {
},
[MUTATION_TYPES.UPDATE_ANCESTORS_TOOT]: (state, message: Status) => {
// Replace target message in ancestors
- state.ancestors = state.ancestors.map((toot) => {
+ state.ancestors = state.ancestors.map(toot => {
if (toot.id === message.id) {
return message
} else if (toot.reblog !== null && toot.reblog.id === message.id) {
@@ -54,7 +54,7 @@ const mutations: MutationTree = {
})
},
[MUTATION_TYPES.DELETE_ANCESTORS_TOOT]: (state, message: Status) => {
- state.ancestors = state.ancestors.filter((toot) => {
+ state.ancestors = state.ancestors.filter(toot => {
if (toot.reblog !== null && toot.reblog.id === message.id) {
return false
} else {
@@ -87,7 +87,7 @@ const mutations: MutationTree = {
},
[MUTATION_TYPES.UPDATE_DESCENDANTS_TOOT]: (state, message: Status) => {
// Replace target message in descendants
- state.descendants = state.descendants.map((toot) => {
+ state.descendants = state.descendants.map(toot => {
if (toot.id === message.id) {
return message
} else if (toot.reblog !== null && toot.reblog.id === message.id) {
@@ -103,7 +103,7 @@ const mutations: MutationTree = {
})
},
[MUTATION_TYPES.DELETE_DESCENDANTS_TOOT]: (state, message: Status) => {
- state.descendants = state.descendants.filter((toot) => {
+ state.descendants = state.descendants.filter(toot => {
if (toot.reblog !== null && toot.reblog.id === message.id) {
return false
} else {
@@ -120,10 +120,7 @@ const actions: ActionTree = {
commit(MUTATION_TYPES.CHANGE_TOOT, message)
},
fetchToot: async ({ commit, rootState }, message: Status) => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response = await client.get(`/statuses/${message.id}/context`, { limit: 40 })
commit(MUTATION_TYPES.UPDATE_ANCESTORS, res.data.ancestors)
diff --git a/src/renderer/store/TimelineSpace/HeaderMenu.ts b/src/renderer/store/TimelineSpace/HeaderMenu.ts
index d4a139a8..1bd4b3bc 100644
--- a/src/renderer/store/TimelineSpace/HeaderMenu.ts
+++ b/src/renderer/store/TimelineSpace/HeaderMenu.ts
@@ -3,7 +3,7 @@ import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
import AxiosLoading from '@/utils/axiosLoading'
-export interface HeaderMenuState {
+export type HeaderMenuState = {
title: string
reload: boolean
loading: boolean
diff --git a/src/renderer/store/TimelineSpace/Modals.ts b/src/renderer/store/TimelineSpace/Modals.ts
index 67ca9139..ce21bd81 100644
--- a/src/renderer/store/TimelineSpace/Modals.ts
+++ b/src/renderer/store/TimelineSpace/Modals.ts
@@ -9,19 +9,21 @@ import Report, { ReportState } from './Modals/Report'
import { Module, GetterTree } from 'vuex'
import { RootState } from '@/store/index'
-export interface ModalsState {}
+export type ModalsState = {}
-export interface ModalsModuleState extends ModalsState {
- Jump: JumpState,
- AddListMember: AddListMemberState,
- ImageViewer: ImageViewerState,
- ListMembership: ListMembershipState,
- MuteConfirm: MuteConfirmState,
- NewToot: NewTootModuleState,
- Report: ReportState,
+type ModalsModule = {
+ Jump: JumpState
+ AddListMember: AddListMemberState
+ ImageViewer: ImageViewerState
+ ListMembership: ListMembershipState
+ MuteConfirm: MuteConfirmState
+ NewToot: NewTootModuleState
+ Report: ReportState
Shortcut: ShortcutState
}
+export type ModalsModuleState = ModalsModule & ModalsState
+
const state = (): ModalsState => ({})
const getters: GetterTree = {
diff --git a/src/renderer/store/TimelineSpace/Modals/AddListMember.ts b/src/renderer/store/TimelineSpace/Modals/AddListMember.ts
index cc0d45da..14c7583a 100644
--- a/src/renderer/store/TimelineSpace/Modals/AddListMember.ts
+++ b/src/renderer/store/TimelineSpace/Modals/AddListMember.ts
@@ -2,7 +2,7 @@ import Mastodon, { Account, Response } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface AddListMemberState {
+export type AddListMemberState = {
modalOpen: boolean
accounts: Array
targetListId: string | null
diff --git a/src/renderer/store/TimelineSpace/Modals/ImageViewer.ts b/src/renderer/store/TimelineSpace/Modals/ImageViewer.ts
index 498cb2ae..99e24f70 100644
--- a/src/renderer/store/TimelineSpace/Modals/ImageViewer.ts
+++ b/src/renderer/store/TimelineSpace/Modals/ImageViewer.ts
@@ -2,10 +2,10 @@ import { Module, MutationTree, ActionTree, GetterTree } from 'vuex'
import { Attachment } from 'megalodon'
import { RootState } from '@/store'
-export interface ImageViewerState {
- modalOpen: boolean,
- currentIndex: number,
- mediaList: Array,
+export type ImageViewerState = {
+ modalOpen: boolean
+ currentIndex: number
+ mediaList: Array
loading: boolean
}
@@ -35,10 +35,10 @@ const mutations: MutationTree = {
[MUTATION_TYPES.CHANGE_MEDIA_LIST]: (state, mediaList: Array) => {
state.mediaList = mediaList
},
- [MUTATION_TYPES.INCREMENT_INDEX]: (state) => {
+ [MUTATION_TYPES.INCREMENT_INDEX]: state => {
state.currentIndex++
},
- [MUTATION_TYPES.DECREMENT_INDEX]: (state) => {
+ [MUTATION_TYPES.DECREMENT_INDEX]: state => {
state.currentIndex--
},
[MUTATION_TYPES.CHANGE_LOADING]: (state, value: boolean) => {
@@ -86,14 +86,14 @@ const getters: GetterTree = {
return null
},
showLeft: (state): boolean => {
- const notFirst = (state.currentIndex > 0)
- const isManyItem = (state.mediaList.length > 1)
- return (notFirst && isManyItem)
+ const notFirst = state.currentIndex > 0
+ const isManyItem = state.mediaList.length > 1
+ return notFirst && isManyItem
},
showRight: (state): boolean => {
- const notLast = (state.currentIndex < (state.mediaList.length - 1))
- const isManyItem = (state.mediaList.length > 1)
- return (notLast && isManyItem)
+ const notLast = state.currentIndex < state.mediaList.length - 1
+ const isManyItem = state.mediaList.length > 1
+ return notLast && isManyItem
}
}
diff --git a/src/renderer/store/TimelineSpace/Modals/Jump.ts b/src/renderer/store/TimelineSpace/Modals/Jump.ts
index 9944b205..a5f7aae6 100644
--- a/src/renderer/store/TimelineSpace/Modals/Jump.ts
+++ b/src/renderer/store/TimelineSpace/Modals/Jump.ts
@@ -2,20 +2,20 @@ import router from '@/router'
import i18n from '~/src/config/i18n'
import { Module, MutationTree, ActionTree } from 'vuex'
import { List } from 'megalodon'
-import LocalTag from '~/src/types/localTag'
+import { LocalTag } from '~/src/types/localTag'
import { RootState } from '@/store'
-export interface Channel {
- name: string,
+export type Channel = {
+ name: string
path: string
}
-export interface JumpState {
- modalOpen: boolean,
- channel: string,
- defaultChannelList: Array,
- listChannelList: Array,
- tagChannelList: Array,
+export type JumpState = {
+ modalOpen: boolean
+ channel: string
+ defaultChannelList: Array
+ listChannelList: Array
+ tagChannelList: Array
selectedChannel: Channel
}
@@ -87,7 +87,7 @@ const mutations: MutationTree = {
state.selectedChannel = channel
},
[MUTATION_TYPES.UPDATE_LIST_CHANNEL]: (state, lists: Array) => {
- state.listChannelList = lists.map((l) => {
+ state.listChannelList = lists.map(l => {
const channel: Channel = {
name: `#${l.title}`,
path: `lists/${l.id}`
diff --git a/src/renderer/store/TimelineSpace/Modals/ListMembership.ts b/src/renderer/store/TimelineSpace/Modals/ListMembership.ts
index 68d5e6df..319e3e2d 100644
--- a/src/renderer/store/TimelineSpace/Modals/ListMembership.ts
+++ b/src/renderer/store/TimelineSpace/Modals/ListMembership.ts
@@ -3,10 +3,10 @@ import lodash from 'lodash'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface ListMembershipState {
- modalOpen: boolean,
- account: Account | null,
- lists: Array,
+export type ListMembershipState = {
+ modalOpen: boolean
+ account: Account | null
+ lists: Array
belongToLists: Array
}
@@ -47,19 +47,13 @@ const actions: ActionTree = {
commit(MUTATION_TYPES.CHANGE_ACCOUNT, account)
},
fetchListMembership: async ({ commit, rootState }, account: Account) => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response> = await client.get>(`/accounts/${account.id}/lists`)
commit(MUTATION_TYPES.CHANGE_BELONG_TO_LISTS, res.data.map(l => l.id))
return res.data
},
fetchLists: async ({ commit, rootState }) => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response> = await client.get>('/lists')
commit(MUTATION_TYPES.CHANGE_LISTS, res.data)
return res.data
@@ -69,10 +63,7 @@ const actions: ActionTree = {
const removedLists = lodash.difference(state.belongToLists, belongToLists)
const addedLists = lodash.difference(belongToLists, state.belongToLists)
commit(MUTATION_TYPES.CHANGE_BELONG_TO_LISTS, belongToLists)
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const removedPromise = removedLists.map(id => {
return client.del<{}>(`/lists/${id}/accounts`, {
account_ids: [state.account!.id]
diff --git a/src/renderer/store/TimelineSpace/Modals/MuteConfirm.ts b/src/renderer/store/TimelineSpace/Modals/MuteConfirm.ts
index 3ef17944..dbca8df1 100644
--- a/src/renderer/store/TimelineSpace/Modals/MuteConfirm.ts
+++ b/src/renderer/store/TimelineSpace/Modals/MuteConfirm.ts
@@ -2,8 +2,8 @@ import Mastodon, { Account, Response, Relationship } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface MuteConfirmState {
- modalOpen: boolean,
+export type MuteConfirmState = {
+ modalOpen: boolean
account: Account | null
}
@@ -34,10 +34,7 @@ const actions: ActionTree = {
commit(MUTATION_TYPES.CHANGE_ACCOUNT, account)
},
submit: async ({ state, rootState, dispatch }, notify: boolean) => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
const res: Response = await client.post(`/accounts/${state.account!.id}/mute`, {
notifications: notify
})
diff --git a/src/renderer/store/TimelineSpace/Modals/NewToot.ts b/src/renderer/store/TimelineSpace/Modals/NewToot.ts
index 9e9ccc9c..f3275888 100644
--- a/src/renderer/store/TimelineSpace/Modals/NewToot.ts
+++ b/src/renderer/store/TimelineSpace/Modals/NewToot.ts
@@ -20,7 +20,7 @@ type MediaDescription = {
description: string
}
-export interface NewTootState {
+export type NewTootState = {
modalOpen: boolean
initialStatus: string
initialSpoiler: string
@@ -36,10 +36,12 @@ export interface NewTootState {
loading: boolean
}
-export interface NewTootModuleState extends NewTootState {
+type NewTootModule = {
Status: StatusState
}
+export type NewTootModuleState = NewTootModule & NewTootState
+
const state = (): NewTootState => ({
modalOpen: false,
initialStatus: '',
diff --git a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts
index 73915d7f..a1e20c3a 100644
--- a/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts
+++ b/src/renderer/store/TimelineSpace/Modals/NewToot/Status.ts
@@ -11,7 +11,7 @@ interface SuggestAccount extends Suggest {}
interface SuggestHashtag extends Suggest {}
-export interface StatusState {
+export type StatusState = {
filteredAccounts: Array
filteredHashtags: Array
}
diff --git a/src/renderer/store/TimelineSpace/Modals/Report.ts b/src/renderer/store/TimelineSpace/Modals/Report.ts
index 0fa77a50..933d4a9e 100644
--- a/src/renderer/store/TimelineSpace/Modals/Report.ts
+++ b/src/renderer/store/TimelineSpace/Modals/Report.ts
@@ -2,8 +2,8 @@ import Mastodon, { Status } from 'megalodon'
import { Module, MutationTree, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface ReportState {
- modalOpen: boolean,
+export type ReportState = {
+ modalOpen: boolean
message: Status | null
}
@@ -32,10 +32,7 @@ const actions: ActionTree = {
commit(MUTATION_TYPES.CHANGE_MODAL_OPEN, true)
},
submit: async ({ rootState }, { account_id, status_id, comment }) => {
- const client = new Mastodon(
- rootState.TimelineSpace.account.accessToken!,
- rootState.TimelineSpace.account.baseURL + '/api/v1'
- )
+ const client = new Mastodon(rootState.TimelineSpace.account.accessToken!, rootState.TimelineSpace.account.baseURL + '/api/v1')
return client.post<{}>(`/reports`, {
account_id: account_id,
status_ids: [status_id],
diff --git a/src/renderer/store/TimelineSpace/Modals/Shortcut.ts b/src/renderer/store/TimelineSpace/Modals/Shortcut.ts
index 7d19097f..48235342 100644
--- a/src/renderer/store/TimelineSpace/Modals/Shortcut.ts
+++ b/src/renderer/store/TimelineSpace/Modals/Shortcut.ts
@@ -1,7 +1,7 @@
import { Module, MutationTree } from 'vuex'
import { RootState } from '@/store'
-export interface ShortcutState {
+export type ShortcutState = {
modalOpen: boolean
}
diff --git a/src/renderer/store/TimelineSpace/SideMenu.ts b/src/renderer/store/TimelineSpace/SideMenu.ts
index a86eef55..2d8964ca 100644
--- a/src/renderer/store/TimelineSpace/SideMenu.ts
+++ b/src/renderer/store/TimelineSpace/SideMenu.ts
@@ -1,11 +1,11 @@
import Mastodon, { List, Response, Account } from 'megalodon'
import { ipcRenderer } from 'electron'
import { Module, MutationTree, ActionTree } from 'vuex'
-import LocalTag from '~/src/types/localTag'
-import LocalAccount from '~/src/types/localAccount'
+import { LocalTag } from '~/src/types/localTag'
+import { LocalAccount } from '~/src/types/localAccount'
import { RootState } from '@/store'
-export interface SideMenuState {
+export type SideMenuState = {
unreadHomeTimeline: boolean
unreadNotifications: boolean
unreadMentions: boolean
diff --git a/src/renderer/store/index.ts b/src/renderer/store/index.ts
index ac38876f..6a63be85 100644
--- a/src/renderer/store/index.ts
+++ b/src/renderer/store/index.ts
@@ -14,23 +14,21 @@ import molecules, { MoleculesModuleState } from './molecules'
Vue.use(Vuex)
-export interface RootState {
- App: AppState,
- GlobalHeader: GlobalHeaderState,
- Login: LoginState,
- Authorize: AuthorizeState,
- TimelineSpace: TimelineSpaceModuleState,
- Preferences: PreferencesModuleState,
- Settings: SettingsModuleState,
- molecules: MoleculesModuleState,
+export type RootState = {
+ App: AppState
+ GlobalHeader: GlobalHeaderState
+ Login: LoginState
+ Authorize: AuthorizeState
+ TimelineSpace: TimelineSpaceModuleState
+ Preferences: PreferencesModuleState
+ Settings: SettingsModuleState
+ molecules: MoleculesModuleState
route: Route
}
export default new Vuex.Store({
strict: process.env.NODE_ENV !== 'production',
- plugins: process.env.NODE_ENV !== 'production'
- ? [createLogger({})]
- : [],
+ plugins: process.env.NODE_ENV !== 'production' ? [createLogger({})] : [],
modules: {
App,
GlobalHeader,
diff --git a/src/renderer/store/molecules.ts b/src/renderer/store/molecules.ts
index 0899b724..fb62384a 100644
--- a/src/renderer/store/molecules.ts
+++ b/src/renderer/store/molecules.ts
@@ -1,6 +1,6 @@
import Toot, { TootState } from './molecules/Toot'
-export interface MoleculesModuleState {
+export type MoleculesModuleState = {
Toot: TootState
}
diff --git a/src/renderer/store/molecules/Toot.ts b/src/renderer/store/molecules/Toot.ts
index baa2e4d0..e1f3f322 100644
--- a/src/renderer/store/molecules/Toot.ts
+++ b/src/renderer/store/molecules/Toot.ts
@@ -3,7 +3,7 @@ import { ipcRenderer } from 'electron'
import { Module, ActionTree } from 'vuex'
import { RootState } from '@/store'
-export interface TootState {}
+export type TootState = {}
const state = (): TootState => ({})
diff --git a/src/renderer/types/loadPosition.ts b/src/renderer/types/loadPosition.ts
index 9d832395..c8c4895b 100644
--- a/src/renderer/types/loadPosition.ts
+++ b/src/renderer/types/loadPosition.ts
@@ -1,17 +1,17 @@
import { Status, Account } from 'megalodon'
-export interface LoadPosition {
+export type LoadPosition = {
status: Status
}
-export interface LoadPositionWithAccount extends LoadPosition {
+export type LoadPositionWithAccount = LoadPosition & {
account: Account
}
-export interface LoadPositionWithList extends LoadPosition {
+export type LoadPositionWithList = LoadPosition & {
list_id: string
}
-export interface LoadPositionWithTag extends LoadPosition {
+export type LoadPositionWithTag = LoadPosition & {
tag: string
}
diff --git a/src/renderer/types/removeAccountFromList.ts b/src/renderer/types/removeAccountFromList.ts
index 2530215f..98a29e3a 100644
--- a/src/renderer/types/removeAccountFromList.ts
+++ b/src/renderer/types/removeAccountFromList.ts
@@ -1,6 +1,6 @@
import { Account } from 'megalodon'
-export interface RemoveAccountFromList {
+export type RemoveAccountFromList = {
account: Account
listId: string
}
diff --git a/src/types/localAccount.ts b/src/types/localAccount.ts
index 71aa3a87..8615f143 100644
--- a/src/types/localAccount.ts
+++ b/src/types/localAccount.ts
@@ -1,4 +1,4 @@
-export default interface LocalAccount {
+export type LocalAccount = {
_id?: string
baseURL: string
domain: string
diff --git a/src/types/localTag.ts b/src/types/localTag.ts
index dbcf21cc..8c916fdd 100644
--- a/src/types/localTag.ts
+++ b/src/types/localTag.ts
@@ -1,4 +1,4 @@
-export default interface LocalTag {
- tagName: string,
+export type LocalTag = {
+ tagName: string
_id?: string
}