2022-12-31 14:45:14 +01:00
|
|
|
import generator, { Entity } from 'megalodon'
|
2019-04-10 13:58:11 +02:00
|
|
|
import SideMenu, { SideMenuState } from './TimelineSpace/SideMenu'
|
|
|
|
import HeaderMenu, { HeaderMenuState } from './TimelineSpace/HeaderMenu'
|
|
|
|
import Modals, { ModalsModuleState } from './TimelineSpace/Modals'
|
2019-04-11 15:54:23 +02:00
|
|
|
import Contents, { ContentsModuleState } from './TimelineSpace/Contents'
|
2019-04-07 15:48:37 +02:00
|
|
|
import { Module, MutationTree, ActionTree } from 'vuex'
|
2019-06-06 16:44:50 +02:00
|
|
|
import { LocalAccount } from '~/src/types/localAccount'
|
2019-04-14 16:11:24 +02:00
|
|
|
import { RootState } from '@/store'
|
2019-05-16 16:02:05 +02:00
|
|
|
import { AccountLoadError } from '@/errors/load'
|
|
|
|
import { TimelineFetchError } from '@/errors/fetch'
|
2019-12-04 15:03:34 +01:00
|
|
|
import { MyWindow } from '~/src/types/global'
|
2022-01-01 10:39:33 +01:00
|
|
|
import { Timeline, Setting } from '~src/types/setting'
|
2022-01-01 14:41:28 +01:00
|
|
|
import { DefaultSetting } from '~/src/constants/initializer/setting'
|
2022-12-31 14:45:14 +01:00
|
|
|
import { LocalServer } from '~src/types/localServer'
|
2019-12-04 15:03:34 +01:00
|
|
|
|
2022-12-31 14:45:14 +01:00
|
|
|
const win = (window as any) as MyWindow
|
2019-04-07 15:48:37 +02:00
|
|
|
|
2019-06-06 16:44:50 +02:00
|
|
|
export type TimelineSpaceState = {
|
2022-12-31 14:45:14 +01:00
|
|
|
account: LocalAccount | null
|
|
|
|
server: LocalServer | null
|
2019-05-16 16:02:05 +02:00
|
|
|
loading: boolean
|
2020-03-15 09:47:56 +01:00
|
|
|
emojis: Array<Entity.Emoji>
|
2019-05-16 16:02:05 +02:00
|
|
|
tootMax: number
|
2022-01-01 10:39:33 +01:00
|
|
|
timelineSetting: Timeline
|
2021-05-21 18:43:27 +02:00
|
|
|
filters: Array<Entity.Filter>
|
2019-04-07 15:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const state = (): TimelineSpaceState => ({
|
2022-12-31 14:45:14 +01:00
|
|
|
account: null,
|
|
|
|
server: null,
|
2019-04-07 15:48:37 +02:00
|
|
|
loading: false,
|
|
|
|
emojis: [],
|
|
|
|
tootMax: 500,
|
2022-01-01 14:41:28 +01:00
|
|
|
timelineSetting: DefaultSetting.timeline,
|
2021-05-21 18:43:27 +02:00
|
|
|
filters: []
|
2019-04-07 15:48:37 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
export const MUTATION_TYPES = {
|
|
|
|
UPDATE_ACCOUNT: 'updateAccount',
|
2022-12-31 14:45:14 +01:00
|
|
|
UPDATE_SERVER: 'updateServer',
|
2019-04-07 15:48:37 +02:00
|
|
|
CHANGE_LOADING: 'changeLoading',
|
|
|
|
UPDATE_EMOJIS: 'updateEmojis',
|
|
|
|
UPDATE_TOOT_MAX: 'updateTootMax',
|
2022-01-01 10:39:33 +01:00
|
|
|
UPDATE_TIMELINE_SETTING: 'updateTimelineSetting',
|
2021-05-21 18:43:27 +02:00
|
|
|
UPDATE_FILTERS: 'updateFilters'
|
2019-04-07 15:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const mutations: MutationTree<TimelineSpaceState> = {
|
2019-04-14 16:21:08 +02:00
|
|
|
[MUTATION_TYPES.UPDATE_ACCOUNT]: (state, account: LocalAccount) => {
|
2019-04-07 15:48:37 +02:00
|
|
|
state.account = account
|
|
|
|
},
|
2022-12-31 14:45:14 +01:00
|
|
|
[MUTATION_TYPES.UPDATE_SERVER]: (state, server: LocalServer) => {
|
|
|
|
state.server = server
|
2019-06-26 16:32:06 +02:00
|
|
|
},
|
2019-04-07 15:48:37 +02:00
|
|
|
[MUTATION_TYPES.CHANGE_LOADING]: (state, value: boolean) => {
|
|
|
|
state.loading = value
|
|
|
|
},
|
2020-03-15 09:47:56 +01:00
|
|
|
[MUTATION_TYPES.UPDATE_EMOJIS]: (state, emojis: Array<Entity.Emoji>) => {
|
2019-08-07 16:02:37 +02:00
|
|
|
state.emojis = emojis
|
2019-04-07 15:48:37 +02:00
|
|
|
},
|
|
|
|
[MUTATION_TYPES.UPDATE_TOOT_MAX]: (state, value: number | null) => {
|
|
|
|
if (value) {
|
|
|
|
state.tootMax = value
|
|
|
|
} else {
|
|
|
|
state.tootMax = 500
|
|
|
|
}
|
|
|
|
},
|
2022-01-01 10:39:33 +01:00
|
|
|
[MUTATION_TYPES.UPDATE_TIMELINE_SETTING]: (state, setting: Timeline) => {
|
|
|
|
state.timelineSetting = setting
|
2019-04-07 15:48:37 +02:00
|
|
|
},
|
2021-05-21 18:43:27 +02:00
|
|
|
[MUTATION_TYPES.UPDATE_FILTERS]: (state, filters: Array<Entity.Filter>) => {
|
|
|
|
state.filters = filters
|
2019-04-07 15:48:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-05-28 06:31:33 +02:00
|
|
|
export const ACTION_TYPES = {
|
|
|
|
INIT_LOAD: 'initLoad',
|
|
|
|
PREPARE_SPACE: 'prepareSpace',
|
|
|
|
LOCAL_ACCOUNT: 'localAccount',
|
|
|
|
CLEAR_ACCOUNT: 'clearAccount',
|
|
|
|
WATCH_SHORTCUT_EVENTS: 'watchShortcutEvents',
|
|
|
|
REMOVE_SHORTCUT_EVENTS: 'removeShortcutEvents',
|
|
|
|
CLEAR_UNREAD: 'clearUnread',
|
|
|
|
FETCH_EMOJIS: 'fetchEmojis',
|
|
|
|
FETCH_FILTERS: 'fetchFilters',
|
|
|
|
FETCH_INSTANCE: 'fetchInstance',
|
|
|
|
LOAD_TIMELINE_SETTING: 'loadTimelineSetting',
|
|
|
|
FETCH_CONTENTS_TIMELINES: 'fetchContentsTimelines',
|
|
|
|
CLEAR_CONTENTS_TIMELINES: 'clearContentsTimelines',
|
|
|
|
BIND_STREAMINGS: 'bindStreamings',
|
|
|
|
BIND_USER_STREAMING: 'bindUserStreaming',
|
|
|
|
BIND_LOCAL_STREAMING: 'bindLocalStreaming',
|
|
|
|
BIND_PUBLIC_STREAMING: 'bindPublicStreaming',
|
|
|
|
BIND_DIRECT_MESSAGES_STREAMING: 'bindDirectMessagesStreaming',
|
2022-12-31 14:45:14 +01:00
|
|
|
UPDATE_TOOT_FOR_ALL_TIMELINES: 'updateTootForAllTimelines'
|
2022-05-28 06:31:33 +02:00
|
|
|
}
|
|
|
|
|
2019-04-14 16:11:24 +02:00
|
|
|
const actions: ActionTree<TimelineSpaceState, RootState> = {
|
2022-12-31 14:45:14 +01:00
|
|
|
[ACTION_TYPES.INIT_LOAD]: async ({ dispatch, commit }, accountId: string): Promise<[LocalAccount, LocalServer]> => {
|
2019-05-16 16:02:05 +02:00
|
|
|
commit(MUTATION_TYPES.CHANGE_LOADING, true)
|
2022-12-31 14:45:14 +01:00
|
|
|
dispatch(ACTION_TYPES.WATCH_SHORTCUT_EVENTS)
|
|
|
|
const account: [LocalAccount, LocalServer] = await dispatch(ACTION_TYPES.LOCAL_ACCOUNT, accountId).catch(_ => {
|
2019-05-16 16:02:05 +02:00
|
|
|
commit(MUTATION_TYPES.CHANGE_LOADING, false)
|
|
|
|
throw new AccountLoadError()
|
|
|
|
})
|
|
|
|
|
2022-12-31 14:45:14 +01:00
|
|
|
dispatch('TimelineSpace/SideMenu/fetchLists', null, { root: true })
|
|
|
|
dispatch('TimelineSpace/SideMenu/fetchFollowRequests', null, { root: true })
|
|
|
|
dispatch('TimelineSpace/SideMenu/confirmTimelines', null, { root: true })
|
|
|
|
await dispatch(ACTION_TYPES.LOAD_TIMELINE_SETTING, accountId)
|
|
|
|
await dispatch(ACTION_TYPES.FETCH_FILTERS)
|
2019-05-16 16:02:05 +02:00
|
|
|
commit(MUTATION_TYPES.CHANGE_LOADING, false)
|
2022-12-31 14:45:14 +01:00
|
|
|
await dispatch(ACTION_TYPES.FETCH_CONTENTS_TIMELINES).catch(_ => {
|
2019-05-16 16:02:05 +02:00
|
|
|
throw new TimelineFetchError()
|
|
|
|
})
|
2019-06-26 16:32:06 +02:00
|
|
|
return account
|
|
|
|
},
|
2022-12-31 14:45:14 +01:00
|
|
|
[ACTION_TYPES.PREPARE_SPACE]: async ({ dispatch }) => {
|
|
|
|
await dispatch(ACTION_TYPES.BIND_STREAMINGS)
|
|
|
|
await dispatch(ACTION_TYPES.FETCH_EMOJIS)
|
|
|
|
await dispatch(ACTION_TYPES.FETCH_INSTANCE)
|
2019-05-16 16:02:05 +02:00
|
|
|
},
|
2019-04-07 15:48:37 +02:00
|
|
|
// -------------------------------------------------
|
|
|
|
// Accounts
|
|
|
|
// -------------------------------------------------
|
2022-12-31 14:45:14 +01:00
|
|
|
[ACTION_TYPES.LOCAL_ACCOUNT]: async ({ commit }, id: number): Promise<[LocalAccount, LocalServer]> => {
|
|
|
|
const account: [LocalAccount, LocalServer] = await win.ipcRenderer.invoke('get-local-account', id)
|
|
|
|
commit(MUTATION_TYPES.UPDATE_ACCOUNT, account[0])
|
|
|
|
commit(MUTATION_TYPES.UPDATE_SERVER, account[1])
|
|
|
|
return account
|
2019-04-07 15:48:37 +02:00
|
|
|
},
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.CLEAR_ACCOUNT]: async ({ commit }) => {
|
2022-12-31 14:45:14 +01:00
|
|
|
commit(MUTATION_TYPES.UPDATE_ACCOUNT, null)
|
2019-04-07 15:48:37 +02:00
|
|
|
return true
|
|
|
|
},
|
|
|
|
// -----------------------------------------------
|
|
|
|
// Shortcuts
|
|
|
|
// -----------------------------------------------
|
2022-07-10 04:50:32 +02:00
|
|
|
[ACTION_TYPES.WATCH_SHORTCUT_EVENTS]: ({ commit, dispatch, rootGetters }) => {
|
2019-12-04 15:03:34 +01:00
|
|
|
win.ipcRenderer.on('CmdOrCtrl+N', () => {
|
2019-04-07 15:48:37 +02:00
|
|
|
dispatch('TimelineSpace/Modals/NewToot/openModal', {}, { root: true })
|
|
|
|
})
|
2019-12-04 15:03:34 +01:00
|
|
|
win.ipcRenderer.on('CmdOrCtrl+K', () => {
|
2019-04-07 15:48:37 +02:00
|
|
|
commit('TimelineSpace/Modals/Jump/changeModal', true, { root: true })
|
|
|
|
})
|
2022-04-27 12:53:52 +02:00
|
|
|
win.ipcRenderer.on('open-shortcuts-list', () => {
|
2022-07-10 04:50:32 +02:00
|
|
|
const modalOpened = rootGetters['TimelineSpace/Modals/modalOpened']
|
|
|
|
if (!modalOpened) {
|
|
|
|
commit('TimelineSpace/Modals/Shortcut/changeModal', true, { root: true })
|
|
|
|
}
|
2022-04-27 12:53:52 +02:00
|
|
|
})
|
2019-04-07 15:48:37 +02:00
|
|
|
},
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.REMOVE_SHORTCUT_EVENTS]: async () => {
|
2019-12-04 15:03:34 +01:00
|
|
|
win.ipcRenderer.removeAllListeners('CmdOrCtrl+N')
|
|
|
|
win.ipcRenderer.removeAllListeners('CmdOrCtrl+K')
|
2019-04-07 15:48:37 +02:00
|
|
|
return true
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* clearUnread
|
|
|
|
*/
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.CLEAR_UNREAD]: async ({ dispatch }) => {
|
2019-04-07 15:48:37 +02:00
|
|
|
dispatch('TimelineSpace/SideMenu/clearUnread', {}, { root: true })
|
|
|
|
},
|
|
|
|
/**
|
|
|
|
* fetchEmojis
|
|
|
|
*/
|
2022-12-31 14:45:14 +01:00
|
|
|
[ACTION_TYPES.FETCH_EMOJIS]: async ({ commit, state }): Promise<Array<Entity.Emoji>> => {
|
|
|
|
const client = generator(state.server!.sns, state.server!.baseURL, null, 'Whalebird')
|
2020-03-15 09:47:56 +01:00
|
|
|
const res = await client.getInstanceCustomEmojis()
|
2019-04-07 15:48:37 +02:00
|
|
|
commit(MUTATION_TYPES.UPDATE_EMOJIS, res.data)
|
|
|
|
return res.data
|
|
|
|
},
|
2021-05-21 18:43:27 +02:00
|
|
|
/**
|
|
|
|
* fetchFilters
|
|
|
|
*/
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.FETCH_FILTERS]: async ({ commit, state, rootState }): Promise<Array<Entity.Filter>> => {
|
2021-05-24 14:42:07 +02:00
|
|
|
try {
|
2022-12-31 14:45:14 +01:00
|
|
|
const client = generator(state.server!.sns, state.server!.baseURL, state.account!.accessToken, rootState.App.userAgent)
|
2021-05-24 14:42:07 +02:00
|
|
|
const res = await client.getFilters()
|
|
|
|
commit(MUTATION_TYPES.UPDATE_FILTERS, res.data)
|
|
|
|
return res.data
|
|
|
|
} catch {
|
|
|
|
return []
|
|
|
|
}
|
2021-05-21 18:43:27 +02:00
|
|
|
},
|
2019-04-07 15:48:37 +02:00
|
|
|
/**
|
|
|
|
* fetchInstance
|
|
|
|
*/
|
2022-12-31 14:45:14 +01:00
|
|
|
[ACTION_TYPES.FETCH_INSTANCE]: async ({ commit, state }) => {
|
|
|
|
const client = generator(state.server!.sns, state.server!.baseURL, null, 'Whalebird')
|
2020-03-15 09:47:56 +01:00
|
|
|
const res = await client.getInstance()
|
2022-08-12 18:32:45 +02:00
|
|
|
if (res.data.max_toot_chars) {
|
|
|
|
commit(MUTATION_TYPES.UPDATE_TOOT_MAX, res.data.max_toot_chars)
|
|
|
|
}
|
|
|
|
if (res.data.configuration) {
|
|
|
|
commit(MUTATION_TYPES.UPDATE_TOOT_MAX, res.data.configuration.statuses.max_characters)
|
|
|
|
}
|
2019-04-07 15:48:37 +02:00
|
|
|
return true
|
|
|
|
},
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.LOAD_TIMELINE_SETTING]: async ({ commit }, accountID: string) => {
|
2022-01-01 10:39:33 +01:00
|
|
|
const setting: Setting = await win.ipcRenderer.invoke('get-account-setting', accountID)
|
|
|
|
commit(MUTATION_TYPES.UPDATE_TIMELINE_SETTING, setting.timeline)
|
2019-04-07 15:48:37 +02:00
|
|
|
},
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.FETCH_CONTENTS_TIMELINES]: async ({ dispatch, state }) => {
|
2019-05-16 16:02:05 +02:00
|
|
|
dispatch('TimelineSpace/Contents/changeLoading', true, { root: true })
|
|
|
|
await dispatch('TimelineSpace/Contents/Home/fetchTimeline', {}, { root: true }).finally(() => {
|
|
|
|
dispatch('TimelineSpace/Contents/changeLoading', false, { root: true })
|
|
|
|
})
|
|
|
|
|
2019-04-07 15:48:37 +02:00
|
|
|
await dispatch('TimelineSpace/Contents/Notifications/fetchNotifications', {}, { root: true })
|
|
|
|
await dispatch('TimelineSpace/Contents/Mentions/fetchMentions', {}, { root: true })
|
2022-01-01 10:39:33 +01:00
|
|
|
if (state.timelineSetting.unreadNotification.direct) {
|
2019-04-07 15:48:37 +02:00
|
|
|
await dispatch('TimelineSpace/Contents/DirectMessages/fetchTimeline', {}, { root: true })
|
|
|
|
}
|
2022-01-01 10:39:33 +01:00
|
|
|
if (state.timelineSetting.unreadNotification.local) {
|
2019-04-07 15:48:37 +02:00
|
|
|
await dispatch('TimelineSpace/Contents/Local/fetchLocalTimeline', {}, { root: true })
|
|
|
|
}
|
2022-01-01 10:39:33 +01:00
|
|
|
if (state.timelineSetting.unreadNotification.public) {
|
2019-04-07 15:48:37 +02:00
|
|
|
await dispatch('TimelineSpace/Contents/Public/fetchPublicTimeline', {}, { root: true })
|
|
|
|
}
|
|
|
|
},
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.CLEAR_CONTENTS_TIMELINES]: ({ commit }) => {
|
2019-04-07 15:48:37 +02:00
|
|
|
commit('TimelineSpace/Contents/Home/clearTimeline', {}, { root: true })
|
|
|
|
commit('TimelineSpace/Contents/Local/clearTimeline', {}, { root: true })
|
|
|
|
commit('TimelineSpace/Contents/DirectMessages/clearTimeline', {}, { root: true })
|
|
|
|
commit('TimelineSpace/Contents/Notifications/clearNotifications', {}, { root: true })
|
|
|
|
commit('TimelineSpace/Contents/Public/clearTimeline', {}, { root: true })
|
|
|
|
commit('TimelineSpace/Contents/Mentions/clearMentions', {}, { root: true })
|
|
|
|
},
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.BIND_STREAMINGS]: ({ dispatch, state }) => {
|
2019-06-27 16:03:30 +02:00
|
|
|
dispatch('bindUserStreaming')
|
2022-01-01 10:39:33 +01:00
|
|
|
if (state.timelineSetting.unreadNotification.direct) {
|
2019-04-07 15:48:37 +02:00
|
|
|
dispatch('bindDirectMessagesStreaming')
|
|
|
|
}
|
2022-01-01 10:39:33 +01:00
|
|
|
if (state.timelineSetting.unreadNotification.local) {
|
2019-04-07 15:48:37 +02:00
|
|
|
dispatch('bindLocalStreaming')
|
|
|
|
}
|
2022-01-01 10:39:33 +01:00
|
|
|
if (state.timelineSetting.unreadNotification.public) {
|
2019-04-07 15:48:37 +02:00
|
|
|
dispatch('bindPublicStreaming')
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// ------------------------------------------------
|
|
|
|
// Each streaming methods
|
|
|
|
// ------------------------------------------------
|
2022-12-31 14:45:14 +01:00
|
|
|
[ACTION_TYPES.BIND_USER_STREAMING]: async ({ commit, state, rootState }) => {
|
|
|
|
if (!state.account) {
|
2019-06-26 16:32:06 +02:00
|
|
|
throw new Error('Account is not set')
|
|
|
|
}
|
2019-07-01 15:47:01 +02:00
|
|
|
|
2022-12-31 14:45:14 +01:00
|
|
|
win.ipcRenderer.on(`update-start-all-user-streamings-${state.account!.id}`, (_, update: Entity.Status) => {
|
2019-04-07 15:48:37 +02:00
|
|
|
commit('TimelineSpace/Contents/Home/appendTimeline', update, { root: true })
|
|
|
|
// Sometimes archive old statuses
|
|
|
|
if (rootState.TimelineSpace.Contents.Home.heading && Math.random() > 0.8) {
|
|
|
|
commit('TimelineSpace/Contents/Home/archiveTimeline', null, { root: true })
|
|
|
|
}
|
|
|
|
commit('TimelineSpace/SideMenu/changeUnreadHomeTimeline', true, { root: true })
|
|
|
|
})
|
2022-12-31 14:45:14 +01:00
|
|
|
win.ipcRenderer.on(`notification-start-all-user-streamings-${state.account!.id}`, (_, notification: Entity.Notification) => {
|
2019-04-07 15:48:37 +02:00
|
|
|
commit('TimelineSpace/Contents/Notifications/appendNotifications', notification, { root: true })
|
|
|
|
if (rootState.TimelineSpace.Contents.Notifications.heading && Math.random() > 0.8) {
|
|
|
|
commit('TimelineSpace/Contents/Notifications/archiveNotifications', null, { root: true })
|
|
|
|
}
|
|
|
|
commit('TimelineSpace/SideMenu/changeUnreadNotifications', true, { root: true })
|
|
|
|
})
|
2022-12-31 14:45:14 +01:00
|
|
|
win.ipcRenderer.on(`mention-start-all-user-streamings-${state.account!.id}`, (_, mention: Entity.Notification) => {
|
2019-04-07 15:48:37 +02:00
|
|
|
commit('TimelineSpace/Contents/Mentions/appendMentions', mention, { root: true })
|
|
|
|
if (rootState.TimelineSpace.Contents.Mentions.heading && Math.random() > 0.8) {
|
|
|
|
commit('TimelineSpace/Contents/Mentions/archiveMentions', null, { root: true })
|
|
|
|
}
|
|
|
|
commit('TimelineSpace/SideMenu/changeUnreadMentions', true, { root: true })
|
|
|
|
})
|
2022-12-31 14:45:14 +01:00
|
|
|
win.ipcRenderer.on(`delete-start-all-user-streamings-${state.account!.id}`, (_, id: string) => {
|
2019-05-29 16:32:16 +02:00
|
|
|
commit('TimelineSpace/Contents/Home/deleteToot', id, { root: true })
|
|
|
|
commit('TimelineSpace/Contents/Notifications/deleteToot', id, { root: true })
|
|
|
|
commit('TimelineSpace/Contents/Mentions/deleteToot', id, { root: true })
|
|
|
|
})
|
2019-04-07 15:48:37 +02:00
|
|
|
},
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.BIND_LOCAL_STREAMING]: ({ commit, rootState }) => {
|
2020-03-15 09:47:56 +01:00
|
|
|
win.ipcRenderer.on('update-start-local-streaming', (_, update: Entity.Status) => {
|
2019-04-07 15:48:37 +02:00
|
|
|
commit('TimelineSpace/Contents/Local/appendTimeline', update, { root: true })
|
|
|
|
if (rootState.TimelineSpace.Contents.Local.heading && Math.random() > 0.8) {
|
|
|
|
commit('TimelineSpace/Contents/Local/archiveTimeline', {}, { root: true })
|
|
|
|
}
|
|
|
|
commit('TimelineSpace/SideMenu/changeUnreadLocalTimeline', true, { root: true })
|
|
|
|
})
|
2019-12-04 15:03:34 +01:00
|
|
|
win.ipcRenderer.on('delete-start-local-streaming', (_, id: string) => {
|
2019-05-29 16:53:16 +02:00
|
|
|
commit('TimelineSpace/Contents/Local/deleteToot', id, { root: true })
|
|
|
|
})
|
2019-04-07 15:48:37 +02:00
|
|
|
},
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.BIND_PUBLIC_STREAMING]: ({ commit, rootState }) => {
|
2020-03-15 09:47:56 +01:00
|
|
|
win.ipcRenderer.on('update-start-public-streaming', (_, update: Entity.Status) => {
|
2019-04-07 15:48:37 +02:00
|
|
|
commit('TimelineSpace/Contents/Public/appendTimeline', update, { root: true })
|
|
|
|
if (rootState.TimelineSpace.Contents.Public.heading && Math.random() > 0.8) {
|
|
|
|
commit('TimelineSpace/Contents/Public/archiveTimeline', {}, { root: true })
|
|
|
|
}
|
|
|
|
commit('TimelineSpace/SideMenu/changeUnreadPublicTimeline', true, { root: true })
|
|
|
|
})
|
2019-12-04 15:03:34 +01:00
|
|
|
win.ipcRenderer.on('delete-start-public-streaming', (_, id: string) => {
|
2019-05-29 16:59:09 +02:00
|
|
|
commit('TimelineSpace/Contents/Public/deleteToot', id, { root: true })
|
|
|
|
})
|
2019-04-07 15:48:37 +02:00
|
|
|
},
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.BIND_DIRECT_MESSAGES_STREAMING]: ({ commit, rootState }) => {
|
2020-03-15 09:47:56 +01:00
|
|
|
win.ipcRenderer.on('update-start-directmessages-streaming', (_, update: Entity.Status) => {
|
2019-04-07 15:48:37 +02:00
|
|
|
commit('TimelineSpace/Contents/DirectMessages/appendTimeline', update, { root: true })
|
|
|
|
if (rootState.TimelineSpace.Contents.DirectMessages.heading && Math.random() > 0.8) {
|
|
|
|
commit('TimelineSpace/Contents/DirectMessages/archiveTimeline', {}, { root: true })
|
|
|
|
}
|
|
|
|
commit('TimelineSpace/SideMenu/changeUnreadDirectMessagesTimeline', true, { root: true })
|
2019-05-29 16:44:43 +02:00
|
|
|
})
|
2019-12-04 15:03:34 +01:00
|
|
|
win.ipcRenderer.on('delete-start-directmessages-streaming', (_, id: string) => {
|
2019-05-29 16:44:43 +02:00
|
|
|
commit('TimelineSpace/Contents/DirectMessages/deleteToot', id, { root: true })
|
2019-04-07 15:48:37 +02:00
|
|
|
})
|
|
|
|
},
|
2022-12-31 14:45:14 +01:00
|
|
|
|
2022-05-28 06:31:33 +02:00
|
|
|
[ACTION_TYPES.UPDATE_TOOT_FOR_ALL_TIMELINES]: ({ commit, state }, status: Entity.Status): boolean => {
|
2019-05-18 15:28:53 +02:00
|
|
|
commit('TimelineSpace/Contents/Home/updateToot', status, { root: true })
|
|
|
|
commit('TimelineSpace/Contents/Notifications/updateToot', status, { root: true })
|
|
|
|
commit('TimelineSpace/Contents/Mentions/updateToot', status, { root: true })
|
2022-01-01 10:39:33 +01:00
|
|
|
if (state.timelineSetting.unreadNotification.direct) {
|
2019-05-18 15:28:53 +02:00
|
|
|
commit('TimelineSpace/Contents/DirectMessages/updateToot', status, { root: true })
|
|
|
|
}
|
2022-01-01 10:39:33 +01:00
|
|
|
if (state.timelineSetting.unreadNotification.local) {
|
2019-05-19 16:17:56 +02:00
|
|
|
commit('TimelineSpace/Contents/Local/updateToot', status, { root: true })
|
2019-05-18 15:28:53 +02:00
|
|
|
}
|
2022-01-01 10:39:33 +01:00
|
|
|
if (state.timelineSetting.unreadNotification.public) {
|
2019-05-19 16:17:56 +02:00
|
|
|
commit('TimelineSpace/Contents/Public/updateToot', status, { root: true })
|
2019-05-18 15:28:53 +02:00
|
|
|
}
|
|
|
|
return true
|
2019-04-07 15:48:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-06 16:44:50 +02:00
|
|
|
type TimelineSpaceModule = {
|
2019-05-16 16:02:05 +02:00
|
|
|
SideMenu: SideMenuState
|
|
|
|
HeaderMenu: HeaderMenuState
|
|
|
|
Modals: ModalsModuleState
|
2019-04-11 15:54:23 +02:00
|
|
|
Contents: ContentsModuleState
|
2019-04-10 13:58:11 +02:00
|
|
|
}
|
|
|
|
|
2019-06-06 16:44:50 +02:00
|
|
|
export type TimelineSpaceModuleState = TimelineSpaceModule & TimelineSpaceState
|
|
|
|
|
2019-04-14 16:11:24 +02:00
|
|
|
const TimelineSpace: Module<TimelineSpaceState, RootState> = {
|
2019-04-07 15:48:37 +02:00
|
|
|
namespaced: true,
|
|
|
|
modules: {
|
|
|
|
SideMenu,
|
|
|
|
HeaderMenu,
|
|
|
|
Modals,
|
|
|
|
Contents
|
|
|
|
},
|
|
|
|
state: state,
|
|
|
|
mutations: mutations,
|
|
|
|
actions: actions
|
|
|
|
}
|
|
|
|
|
|
|
|
export default TimelineSpace
|