refs #850 Use rootState for all stores
This commit is contained in:
parent
4bd517a07b
commit
baf6dc3084
|
@ -7,6 +7,7 @@ import Theme from '~/src/constants/theme'
|
||||||
import TimeFormat from '~/src/constants/timeFormat'
|
import TimeFormat from '~/src/constants/timeFormat'
|
||||||
import Language from '~/src/constants/language'
|
import Language from '~/src/constants/language'
|
||||||
import DefaultFonts from '@/utils/fonts'
|
import DefaultFonts from '@/utils/fonts'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface Notify {
|
export interface Notify {
|
||||||
reply: boolean,
|
reply: boolean,
|
||||||
|
@ -93,8 +94,7 @@ const mutations: MutationTree<AppState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<AppState, RootState> = {
|
||||||
const actions: ActionTree<AppState, any> = {
|
|
||||||
watchShortcutsEvents: () => {
|
watchShortcutsEvents: () => {
|
||||||
ipcRenderer.on('open-preferences', () => {
|
ipcRenderer.on('open-preferences', () => {
|
||||||
router.push('/preferences/general')
|
router.push('/preferences/general')
|
||||||
|
@ -154,8 +154,7 @@ const actions: ActionTree<AppState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const App: Module<AppState, RootState> = {
|
||||||
const App: Module<AppState, any> = {
|
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
import { Module, ActionTree } from 'vuex'
|
import { Module, ActionTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface AuthorizeState {}
|
export interface AuthorizeState {}
|
||||||
|
|
||||||
const state = (): AuthorizeState => ({})
|
const state = (): AuthorizeState => ({})
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<AuthorizeState, RootState> = {
|
||||||
const actions: ActionTree<AuthorizeState, any> = {
|
|
||||||
submit: (_, code: string) => {
|
submit: (_, code: string) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ipcRenderer.send('get-access-token', code)
|
ipcRenderer.send('get-access-token', code)
|
||||||
|
@ -22,8 +22,7 @@ const actions: ActionTree<AuthorizeState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const Authorize: Module<AuthorizeState, RootState> = {
|
||||||
const Authorize: Module<AuthorizeState, any> = {
|
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: {},
|
mutations: {},
|
||||||
|
|
|
@ -2,6 +2,7 @@ import { ipcRenderer } from 'electron'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import Account from '~/src/types/account'
|
import Account from '~/src/types/account'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface GlobalHeaderState {
|
export interface GlobalHeaderState {
|
||||||
accounts: Array<Account>,
|
accounts: Array<Account>,
|
||||||
|
@ -33,8 +34,7 @@ const mutations: MutationTree<GlobalHeaderState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<GlobalHeaderState, RootState> = {
|
||||||
const actions: ActionTree<GlobalHeaderState, any> = {
|
|
||||||
listAccounts: ({ dispatch, commit }): Promise<Array<Account>> => {
|
listAccounts: ({ dispatch, commit }): Promise<Array<Account>> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ipcRenderer.send('list-accounts', 'list')
|
ipcRenderer.send('list-accounts', 'list')
|
||||||
|
@ -107,8 +107,7 @@ const actions: ActionTree<GlobalHeaderState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const GlobalHeader: Module<GlobalHeaderState, RootState> = {
|
||||||
const GlobalHeader: Module<GlobalHeaderState, any> = {
|
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface LoginState {
|
export interface LoginState {
|
||||||
selectedInstance: string | null,
|
selectedInstance: string | null,
|
||||||
|
@ -26,8 +27,7 @@ const mutations: MutationTree<LoginState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<LoginState, RootState> = {
|
||||||
const actions: ActionTree<LoginState, any> = {
|
|
||||||
fetchLogin: (_, instance: string) => {
|
fetchLogin: (_, instance: string) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ipcRenderer.send('get-auth-url', instance)
|
ipcRenderer.send('get-auth-url', instance)
|
||||||
|
@ -55,8 +55,7 @@ const actions: ActionTree<LoginState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const Login: Module<LoginState, RootState> = {
|
||||||
const Login: Module<LoginState, any> = {
|
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -4,6 +4,7 @@ import Language, { LanguageState } from './Preferences/Language'
|
||||||
import Appearance, { AppearanceState } from './Preferences/Appearance'
|
import Appearance, { AppearanceState } from './Preferences/Appearance'
|
||||||
import Notification, { NotificationState } from './Preferences/Notification'
|
import Notification, { NotificationState } from './Preferences/Notification'
|
||||||
import { Module } from 'vuex'
|
import { Module } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface PreferencesState {}
|
export interface PreferencesState {}
|
||||||
|
|
||||||
|
@ -17,8 +18,7 @@ export interface PreferencesModuleState extends PreferencesState {
|
||||||
Appearance: AppearanceState
|
Appearance: AppearanceState
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const Preferences: Module<PreferencesState, RootState> = {
|
||||||
const Preferences: Module<PreferencesState, any> = {
|
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
modules: {
|
modules: {
|
||||||
General,
|
General,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
import Account from '~/src/types/account'
|
import Account from '~/src/types/account'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface AccountState {
|
export interface AccountState {
|
||||||
accounts: Array<Account>,
|
accounts: Array<Account>,
|
||||||
|
@ -26,8 +27,7 @@ const mutations: MutationTree<AccountState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<AccountState, RootState> = {
|
||||||
const actions: ActionTree<AccountState, any> = {
|
|
||||||
loadAccounts: ({ commit }): Promise<Array<Account>> => {
|
loadAccounts: ({ commit }): Promise<Array<Account>> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ipcRenderer.send('list-accounts', 'list')
|
ipcRenderer.send('list-accounts', 'list')
|
||||||
|
@ -96,8 +96,7 @@ const actions: ActionTree<AccountState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const account: Module<AccountState, RootState> = {
|
||||||
const account: Module<AccountState, any> = {
|
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -5,6 +5,7 @@ import TimeFormat from '~/src/constants/timeFormat'
|
||||||
import { LightTheme } from '@/utils/theme'
|
import { LightTheme } from '@/utils/theme'
|
||||||
import DefaultFonts from '@/utils/fonts'
|
import DefaultFonts from '@/utils/fonts'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
interface ColorThemeSet {
|
interface ColorThemeSet {
|
||||||
background_color: string,
|
background_color: string,
|
||||||
|
@ -59,8 +60,7 @@ const mutations: MutationTree<AppearanceState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<AppearanceState, RootState> = {
|
||||||
const actions: ActionTree<AppearanceState, any> = {
|
|
||||||
loadAppearance: ({ commit }) => {
|
loadAppearance: ({ commit }) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ipcRenderer.send('get-preferences')
|
ipcRenderer.send('get-preferences')
|
||||||
|
@ -218,8 +218,7 @@ const actions: ActionTree<AppearanceState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const Appearance: Module<AppearanceState, RootState> = {
|
||||||
const Appearance: Module<AppearanceState, any> = {
|
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
interface Sound {
|
interface Sound {
|
||||||
fav_rb: boolean,
|
fav_rb: boolean,
|
||||||
|
@ -50,8 +51,7 @@ const mutations: MutationTree<GeneralState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<GeneralState, RootState> = {
|
||||||
const actions: ActionTree<GeneralState, any> = {
|
|
||||||
loadGeneral: ({ commit }) => {
|
loadGeneral: ({ commit }) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
commit(MUTATION_TYPES.CHANGE_LOADING, true)
|
commit(MUTATION_TYPES.CHANGE_LOADING, true)
|
||||||
|
@ -119,7 +119,7 @@ const actions: ActionTree<GeneralState, any> = {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const General: Module<GeneralState, any> = {
|
const General: Module<GeneralState, RootState> = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
import Language from '~/src/constants/language'
|
import Language from '~/src/constants/language'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
interface LanguageSet {
|
interface LanguageSet {
|
||||||
language: string
|
language: string
|
||||||
|
@ -30,8 +31,7 @@ const mutations: MutationTree<LanguageState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<LanguageState, RootState> = {
|
||||||
const actions: ActionTree<LanguageState, any> = {
|
|
||||||
loadLanguage: ({ commit }) => {
|
loadLanguage: ({ commit }) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ipcRenderer.send('get-preferences')
|
ipcRenderer.send('get-preferences')
|
||||||
|
@ -60,10 +60,9 @@ const actions: ActionTree<LanguageState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
|
||||||
export default {
|
export default {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
actions: actions
|
actions: actions
|
||||||
} as Module<LanguageState, any>
|
} as Module<LanguageState, RootState>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
interface Notify {
|
interface Notify {
|
||||||
reply: boolean,
|
reply: boolean,
|
||||||
|
@ -37,8 +38,7 @@ const mutations: MutationTree<NotificationState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<NotificationState, RootState> = {
|
||||||
const actions: ActionTree<NotificationState, any> = {
|
|
||||||
loadNotification: ({ commit }) => {
|
loadNotification: ({ commit }) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
ipcRenderer.send('get-preferences')
|
ipcRenderer.send('get-preferences')
|
||||||
|
@ -72,10 +72,9 @@ const actions: ActionTree<NotificationState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
|
||||||
export default {
|
export default {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
actions: actions
|
actions: actions
|
||||||
} as Module<NotificationState, any>
|
} as Module<NotificationState, RootState>
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import General, { GeneralState } from './Settings/General'
|
import General, { GeneralState } from './Settings/General'
|
||||||
import Timeline, { TimelineState } from './Settings/Timeline'
|
import Timeline, { TimelineState } from './Settings/Timeline'
|
||||||
import { Module, MutationTree } from 'vuex'
|
import { Module, MutationTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface SettingsState {
|
export interface SettingsState {
|
||||||
accountID: number | null
|
accountID: number | null
|
||||||
|
@ -25,8 +26,7 @@ export interface SettingsModuleState extends SettingsState {
|
||||||
Timeline: TimelineState,
|
Timeline: TimelineState,
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const Settings: Module<SettingsState, RootState> = {
|
||||||
const Settings: Module<SettingsState, any> = {
|
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
modules: {
|
modules: {
|
||||||
General,
|
General,
|
||||||
|
|
|
@ -2,6 +2,7 @@ import Mastodon, { Account } from 'megalodon'
|
||||||
import Visibilities from '~/src/constants/visibility'
|
import Visibilities from '~/src/constants/visibility'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
import Visibility from '~/src/types/visibility'
|
import Visibility from '~/src/types/visibility'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface GeneralState {
|
export interface GeneralState {
|
||||||
visibility: number,
|
visibility: number,
|
||||||
|
@ -27,11 +28,10 @@ const mutations: MutationTree<GeneralState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<GeneralState, RootState> = {
|
||||||
const actions: ActionTree<GeneralState, any> = {
|
|
||||||
fetchSettings: async ({ commit, rootState }): Promise<Account> => {
|
fetchSettings: async ({ commit, rootState }): Promise<Account> => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
const res = await client.get<Account>('/accounts/verify_credentials')
|
const res = await client.get<Account>('/accounts/verify_credentials')
|
||||||
|
@ -44,7 +44,7 @@ const actions: ActionTree<GeneralState, any> = {
|
||||||
},
|
},
|
||||||
setVisibility: async ({ commit, rootState }, value: number) => {
|
setVisibility: async ({ commit, rootState }, value: number) => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
const visibility = Object.values(Visibilities as Array<Visibility>).find((v) => {
|
const visibility = Object.values(Visibilities as Array<Visibility>).find((v) => {
|
||||||
|
@ -60,7 +60,7 @@ const actions: ActionTree<GeneralState, any> = {
|
||||||
},
|
},
|
||||||
setSensitive: async ({ commit, rootState }, value: boolean) => {
|
setSensitive: async ({ commit, rootState }, value: boolean) => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
const res = await client.patch<Account>('/accounts/update_credentials', {
|
const res = await client.patch<Account>('/accounts/update_credentials', {
|
||||||
|
@ -73,8 +73,7 @@ const actions: ActionTree<GeneralState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const General: Module<GeneralState, RootState> = {
|
||||||
const General: Module<GeneralState, any> = {
|
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
import unreadSettings from '~/src/constants/unreadNotification'
|
import unreadSettings from '~/src/constants/unreadNotification'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
interface UnreadNotification {
|
interface UnreadNotification {
|
||||||
direct: boolean,
|
direct: boolean,
|
||||||
|
@ -30,8 +31,7 @@ const mutations: MutationTree<TimelineState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<TimelineState, RootState> = {
|
||||||
const actions: ActionTree<TimelineState, any> = {
|
|
||||||
loadUnreadNotification: ({ commit, rootState }): Promise<boolean> => {
|
loadUnreadNotification: ({ commit, rootState }): Promise<boolean> => {
|
||||||
return new Promise(resolve => {
|
return new Promise(resolve => {
|
||||||
ipcRenderer.once('response-get-unread-notification', (_, settings: UnreadNotification) => {
|
ipcRenderer.once('response-get-unread-notification', (_, settings: UnreadNotification) => {
|
||||||
|
@ -71,8 +71,7 @@ const actions: ActionTree<TimelineState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Todo: use type of rootState
|
const Timeline: Module<TimelineState, RootState> = {
|
||||||
const Timeline: Module<TimelineState, any> = {
|
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -10,6 +10,7 @@ import unreadSettings from '~/src/constants/unreadNotification'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
import AccountType from '~/src/types/account'
|
import AccountType from '~/src/types/account'
|
||||||
import { Notify } from './App'
|
import { Notify } from './App'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
declare var Notification: any
|
declare var Notification: any
|
||||||
|
|
||||||
|
@ -105,7 +106,7 @@ const mutations: MutationTree<TimelineSpaceState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const actions: ActionTree<TimelineSpaceState, any> = {
|
const actions: ActionTree<TimelineSpaceState, RootState> = {
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
// Accounts
|
// Accounts
|
||||||
// -------------------------------------------------
|
// -------------------------------------------------
|
||||||
|
@ -423,7 +424,7 @@ export interface TimelineSpaceModuleState extends TimelineSpaceState {
|
||||||
Contents: ContentsModuleState
|
Contents: ContentsModuleState
|
||||||
}
|
}
|
||||||
|
|
||||||
const TimelineSpace: Module<TimelineSpaceState, any> = {
|
const TimelineSpace: Module<TimelineSpaceState, RootState> = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
modules: {
|
modules: {
|
||||||
SideMenu,
|
SideMenu,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Mastodon, { List, Response } from 'megalodon'
|
import Mastodon, { List, Response } from 'megalodon'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface HeaderMenuState {
|
export interface HeaderMenuState {
|
||||||
title: string,
|
title: string,
|
||||||
|
@ -25,11 +26,10 @@ const mutations: MutationTree<HeaderMenuState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<HeaderMenuState, RootState> = {
|
||||||
const actions: ActionTree<HeaderMenuState, any> = {
|
|
||||||
fetchList: async ({ commit, rootState }, listID: number): Promise<List> => {
|
fetchList: async ({ commit, rootState }, listID: number): Promise<List> => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
const res: Response<List> = await client.get<List>(`/lists/${listID}`)
|
const res: Response<List> = await client.get<List>(`/lists/${listID}`)
|
||||||
|
@ -38,7 +38,7 @@ const actions: ActionTree<HeaderMenuState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const HeaderMenu: Module<HeaderMenuState, any> = {
|
const HeaderMenu: Module<HeaderMenuState, RootState> = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import Mastodon, { Account, Response } from 'megalodon'
|
import Mastodon, { Account, Response } from 'megalodon'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface AddListMemberState {
|
export interface AddListMemberState {
|
||||||
modalOpen: boolean,
|
modalOpen: boolean,
|
||||||
|
@ -31,14 +32,13 @@ const mutations: MutationTree<AddListMemberState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<AddListMemberState, RootState> = {
|
||||||
const actions: ActionTree<AddListMemberState, any> = {
|
|
||||||
changeModal: ({ commit }, value: boolean) => {
|
changeModal: ({ commit }, value: boolean) => {
|
||||||
commit(MUTATION_TYPES.CHANGE_MODAL, value)
|
commit(MUTATION_TYPES.CHANGE_MODAL, value)
|
||||||
},
|
},
|
||||||
search: async ({ commit, rootState }, name: string): Promise<Array<Account>> => {
|
search: async ({ commit, rootState }, name: string): Promise<Array<Account>> => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
const res: Response<Array<Account>> = await client.get<Array<Account>>('/accounts/search', {
|
const res: Response<Array<Account>> = await client.get<Array<Account>>('/accounts/search', {
|
||||||
|
@ -50,7 +50,7 @@ const actions: ActionTree<AddListMemberState, any> = {
|
||||||
},
|
},
|
||||||
add: async ({ state, rootState }, account: Account): Promise<{}> => {
|
add: async ({ state, rootState }, account: Account): Promise<{}> => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
const res: Response<{}> = await client.post<{}>(`/lists/${state.targetListId}/accounts`, {
|
const res: Response<{}> = await client.post<{}>(`/lists/${state.targetListId}/accounts`, {
|
||||||
|
@ -60,7 +60,7 @@ const actions: ActionTree<AddListMemberState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const AddListMember: Module<AddListMemberState, any> = {
|
const AddListMember: Module<AddListMemberState, RootState> = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -3,6 +3,7 @@ import i18n from '~/src/config/i18n'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
import { List } from 'megalodon'
|
import { List } from 'megalodon'
|
||||||
import Hashtag from '~/src/types/hashtag'
|
import Hashtag from '~/src/types/hashtag'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface Channel {
|
export interface Channel {
|
||||||
name: string,
|
name: string,
|
||||||
|
@ -105,8 +106,7 @@ const mutations: MutationTree<JumpState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<JumpState, RootState> = {
|
||||||
const actions: ActionTree<JumpState, any> = {
|
|
||||||
jumpCurrentSelected: ({ state, commit, rootState }) => {
|
jumpCurrentSelected: ({ state, commit, rootState }) => {
|
||||||
commit(MUTATION_TYPES.CHANGE_MODAL, false)
|
commit(MUTATION_TYPES.CHANGE_MODAL, false)
|
||||||
router.push({ path: `/${rootState.TimelineSpace.account._id}/${state.selectedChannel.path}` })
|
router.push({ path: `/${rootState.TimelineSpace.account._id}/${state.selectedChannel.path}` })
|
||||||
|
@ -123,7 +123,7 @@ const actions: ActionTree<JumpState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Jump: Module<JumpState, any> = {
|
const Jump: Module<JumpState, RootState> = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -3,6 +3,7 @@ import { ipcRenderer } from 'electron'
|
||||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||||
import Hashtag from '~/src/types/hashtag'
|
import Hashtag from '~/src/types/hashtag'
|
||||||
import Account from '~/src/types/account'
|
import Account from '~/src/types/account'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface SideMenuState {
|
export interface SideMenuState {
|
||||||
unreadHomeTimeline: boolean,
|
unreadHomeTimeline: boolean,
|
||||||
|
@ -70,8 +71,7 @@ const mutations: MutationTree<SideMenuState> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use type of rootState
|
const actions: ActionTree<SideMenuState, RootState> = {
|
||||||
const actions: ActionTree<SideMenuState, any> = {
|
|
||||||
fetchLists: async ({ commit, rootState }, account: Account | null = null): Promise<Array<List>> => {
|
fetchLists: async ({ commit, rootState }, account: Account | null = null): Promise<Array<List>> => {
|
||||||
if (account === null) account = rootState.TimelineSpace.account
|
if (account === null) account = rootState.TimelineSpace.account
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
|
@ -119,7 +119,7 @@ const actions: ActionTree<SideMenuState, any> = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const SideMenu: Module<SideMenuState, any> = {
|
const SideMenu: Module<SideMenuState, RootState> = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
mutations: mutations,
|
mutations: mutations,
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import Vue from 'vue'
|
import Vue from 'vue'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import createLogger from 'vuex/dist/logger'
|
import createLogger from 'vuex/dist/logger'
|
||||||
|
import { Route } from 'vue-router'
|
||||||
|
|
||||||
import App, { AppState } from './App'
|
import App, { AppState } from './App'
|
||||||
import GlobalHeader, { GlobalHeaderState } from './GlobalHeader'
|
import GlobalHeader, { GlobalHeaderState } from './GlobalHeader'
|
||||||
|
@ -21,7 +22,8 @@ export interface RootState {
|
||||||
TimelineSpace: TimelineSpaceModuleState,
|
TimelineSpace: TimelineSpaceModuleState,
|
||||||
Preferences: PreferencesModuleState,
|
Preferences: PreferencesModuleState,
|
||||||
Settings: SettingsModuleState,
|
Settings: SettingsModuleState,
|
||||||
molecules: MoleculesModuleState
|
molecules: MoleculesModuleState,
|
||||||
|
route: Route
|
||||||
}
|
}
|
||||||
|
|
||||||
export default new Vuex.Store({
|
export default new Vuex.Store({
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import Toot from './molecules/Toot'
|
import Toot, { TootState } from './molecules/Toot'
|
||||||
|
|
||||||
export interface MoleculesModuleState {
|
export interface MoleculesModuleState {
|
||||||
|
Toot: TootState
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
import Mastodon, { Response, Status, Account } from 'megalodon'
|
import Mastodon, { Response, Status, Account } from 'megalodon'
|
||||||
import { ipcRenderer } from 'electron'
|
import { ipcRenderer } from 'electron'
|
||||||
import { Module, ActionTree } from 'vuex'
|
import { Module, ActionTree } from 'vuex'
|
||||||
|
import { RootState } from '@/store'
|
||||||
|
|
||||||
export interface TootState {}
|
export interface TootState {}
|
||||||
|
|
||||||
const state = (): TootState => ({})
|
const state = (): TootState => ({})
|
||||||
|
|
||||||
const actions: ActionTree<TootState, any> = {
|
const actions: ActionTree<TootState, RootState> = {
|
||||||
reblog: async ({ rootState }, message: Status) => {
|
reblog: async ({ rootState }, message: Status) => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
const res: Response<Status> = await client.post<Status>(`/statuses/${message.id}/reblog`)
|
const res: Response<Status> = await client.post<Status>(`/statuses/${message.id}/reblog`)
|
||||||
|
@ -21,7 +22,7 @@ const actions: ActionTree<TootState, any> = {
|
||||||
},
|
},
|
||||||
unreblog: async ({ rootState }, message: Status) => {
|
unreblog: async ({ rootState }, message: Status) => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
const res: Response<Status> = await client.post<Status>(`/statuses/${message.id}/unreblog`)
|
const res: Response<Status> = await client.post<Status>(`/statuses/${message.id}/unreblog`)
|
||||||
|
@ -29,7 +30,7 @@ const actions: ActionTree<TootState, any> = {
|
||||||
},
|
},
|
||||||
addFavourite: async ({ rootState }, message: Status) => {
|
addFavourite: async ({ rootState }, message: Status) => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
const res: Response<Status> = await client.post<Status>(`/statuses/${message.id}/favourite`)
|
const res: Response<Status> = await client.post<Status>(`/statuses/${message.id}/favourite`)
|
||||||
|
@ -38,7 +39,7 @@ const actions: ActionTree<TootState, any> = {
|
||||||
},
|
},
|
||||||
removeFavourite: async ({ rootState }, message: Status) => {
|
removeFavourite: async ({ rootState }, message: Status) => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
const res: Response<Status> = await client.post<Status>(`/statuses/${message.id}/unfavourite`)
|
const res: Response<Status> = await client.post<Status>(`/statuses/${message.id}/unfavourite`)
|
||||||
|
@ -46,7 +47,7 @@ const actions: ActionTree<TootState, any> = {
|
||||||
},
|
},
|
||||||
deleteToot: async ({ rootState }, message: Status) => {
|
deleteToot: async ({ rootState }, message: Status) => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
await client.del(`/statuses/${message.id}`)
|
await client.del(`/statuses/${message.id}`)
|
||||||
|
@ -54,14 +55,14 @@ const actions: ActionTree<TootState, any> = {
|
||||||
},
|
},
|
||||||
block: async ({ rootState }, account: Account) => {
|
block: async ({ rootState }, account: Account) => {
|
||||||
const client = new Mastodon(
|
const client = new Mastodon(
|
||||||
rootState.TimelineSpace.account.accessToken,
|
rootState.TimelineSpace.account.accessToken!,
|
||||||
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
rootState.TimelineSpace.account.baseURL + '/api/v1'
|
||||||
)
|
)
|
||||||
return client.post(`/accounts/${account.id}/block`)
|
return client.post(`/accounts/${account.id}/block`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const Toot: Module<TootState, any> = {
|
const Toot: Module<TootState, RootState> = {
|
||||||
namespaced: true,
|
namespaced: true,
|
||||||
state: state,
|
state: state,
|
||||||
actions: actions
|
actions: actions
|
||||||
|
|
Loading…
Reference in New Issue