refs #850 Replace SideBar with typescript
This commit is contained in:
parent
1d168268b5
commit
ca76063a74
|
@ -4,7 +4,7 @@ import Mastodon, { Account, Emoji, Instance, Status, Notification as Notificatio
|
|||
import SideMenu, { SideMenuState } from './TimelineSpace/SideMenu'
|
||||
import HeaderMenu, { HeaderMenuState } from './TimelineSpace/HeaderMenu'
|
||||
import Modals, { ModalsModuleState } from './TimelineSpace/Modals'
|
||||
import Contents from './TimelineSpace/Contents'
|
||||
import Contents, { ContentsModuleState } from './TimelineSpace/Contents'
|
||||
import router from '@/router'
|
||||
import unreadSettings from '~/src/constants/unreadNotification'
|
||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
|
@ -419,8 +419,8 @@ const actions: ActionTree<TimelineSpaceState, any> = {
|
|||
export interface TimelineSpaceModuleState extends TimelineSpaceState {
|
||||
SideMenu: SideMenuState,
|
||||
HeaderMenu: HeaderMenuState,
|
||||
Modals: ModalsModuleState
|
||||
// TODO: Contents: ContentsState
|
||||
Modals: ModalsModuleState,
|
||||
Contents: ContentsModuleState
|
||||
}
|
||||
|
||||
const TimelineSpace: Module<TimelineSpaceState, any> = {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import SideBar from './Contents/SideBar'
|
||||
import SideBar, { SideBarModuleState } from './Contents/SideBar'
|
||||
import Home from './Contents/Home'
|
||||
import Notifications from './Contents/Notifications'
|
||||
import Favourites from './Contents/Favourites'
|
||||
|
@ -9,9 +9,20 @@ import Lists from './Contents/Lists'
|
|||
import Hashtag from './Contents/Hashtag'
|
||||
import DirectMessages from './Contents/DirectMessages'
|
||||
import Mentions from './Contents/Mentions'
|
||||
import { Module } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
const Contents = {
|
||||
export interface ContentsState {}
|
||||
|
||||
export interface ContentsModuleState extends ContentsState {
|
||||
SideBar: SideBarModuleState
|
||||
}
|
||||
|
||||
const state = (): ContentsState => ({})
|
||||
|
||||
const Contents: Module<ContentsState, RootState> = {
|
||||
namespaced: true,
|
||||
state: state,
|
||||
modules: {
|
||||
SideBar,
|
||||
Home,
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
import AccountProfile from './SideBar/AccountProfile'
|
||||
import TootDetail from './SideBar/TootDetail'
|
||||
|
||||
const SideBar = {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
AccountProfile,
|
||||
TootDetail
|
||||
},
|
||||
state: {
|
||||
openSideBar: false,
|
||||
// 0: blank
|
||||
// 1: account-profile
|
||||
// 2: toot-detail
|
||||
component: 0
|
||||
},
|
||||
mutations: {
|
||||
changeOpenSideBar (state, value) {
|
||||
state.openSideBar = value
|
||||
},
|
||||
changeComponent (state, value) {
|
||||
state.component = value
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
close ({ dispatch, commit }) {
|
||||
dispatch('TimelineSpace/Contents/SideBar/AccountProfile/close', {}, { root: true })
|
||||
commit('changeOpenSideBar', false)
|
||||
commit('changeComponent', 0)
|
||||
},
|
||||
openAccountComponent ({ commit }) {
|
||||
commit('changeComponent', 1)
|
||||
},
|
||||
openTootComponent ({ commit }) {
|
||||
commit('changeComponent', 2)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default SideBar
|
|
@ -0,0 +1,61 @@
|
|||
import AccountProfile from './SideBar/AccountProfile'
|
||||
import TootDetail from './SideBar/TootDetail'
|
||||
import { Module, MutationTree, ActionTree } from 'vuex'
|
||||
import { RootState } from '@/store'
|
||||
|
||||
export interface SideBarState {
|
||||
openSideBar: boolean,
|
||||
// 0: blank
|
||||
// 1: account-profile
|
||||
// 2: toot-detail
|
||||
component: number
|
||||
}
|
||||
|
||||
export interface SideBarModuleState extends SideBarState {
|
||||
}
|
||||
|
||||
const state = (): SideBarState => ({
|
||||
openSideBar: false,
|
||||
component: 0
|
||||
})
|
||||
|
||||
export const MUTATION_TYPES = {
|
||||
CHANGE_OPEN_SIDEBAR: 'changeOpenSideBar',
|
||||
CHANGE_COMPONENT: 'changeComponent'
|
||||
}
|
||||
|
||||
const mutations: MutationTree<SideBarState> = {
|
||||
[MUTATION_TYPES.CHANGE_OPEN_SIDEBAR]: (state, value: boolean) => {
|
||||
state.openSideBar = value
|
||||
},
|
||||
[MUTATION_TYPES.CHANGE_COMPONENT]: (state, value: number) => {
|
||||
state.component = value
|
||||
}
|
||||
}
|
||||
|
||||
const actions: ActionTree<SideBarState, RootState> = {
|
||||
close: ({ dispatch, commit }) => {
|
||||
dispatch('TimelineSpace/Contents/SideBar/AccountProfile/close', {}, { root: true })
|
||||
commit(MUTATION_TYPES.CHANGE_OPEN_SIDEBAR, false)
|
||||
commit(MUTATION_TYPES.CHANGE_COMPONENT, 0)
|
||||
},
|
||||
openAccountComponent: ({ commit }) => {
|
||||
commit(MUTATION_TYPES.CHANGE_COMPONENT, 1)
|
||||
},
|
||||
openTootComponent: ({ commit }) => {
|
||||
commit(MUTATION_TYPES.CHANGE_COMPONENT, 2)
|
||||
}
|
||||
}
|
||||
|
||||
const SideBar: Module<SideBarState, RootState> = {
|
||||
namespaced: true,
|
||||
modules: {
|
||||
AccountProfile,
|
||||
TootDetail
|
||||
},
|
||||
state: state,
|
||||
mutations: mutations,
|
||||
actions: actions
|
||||
}
|
||||
|
||||
export default SideBar
|
Loading…
Reference in New Issue