diff --git a/spec/renderer/integration/store/Preferences/Appearance.spec.ts b/spec/renderer/integration/store/Preferences/Appearance.spec.ts index 1408879a..e0436656 100644 --- a/spec/renderer/integration/store/Preferences/Appearance.spec.ts +++ b/spec/renderer/integration/store/Preferences/Appearance.spec.ts @@ -1,3 +1,4 @@ +import { Event } from 'electron' import { createLocalVue } from '@vue/test-utils' import Vuex from 'vuex' import Theme from '~/src/constants/theme' @@ -52,14 +53,14 @@ describe('Preferences/Appearance', () => { App: App } }) - ipcMain.once('update-preferences', (event: any, config: any) => { + ipcMain.once('update-preferences', (event: Event, config: any) => { event.sender.send('response-update-preferences', config) }) }) describe('load', () => { it('loadAppearance', async () => { - ipcMain.once('get-preferences', (event: any, _) => { + ipcMain.once('get-preferences', (event: Event, _) => { event.sender.send('response-get-preferences', { appearance: { theme: Theme.Dark.key, @@ -72,7 +73,7 @@ describe('Preferences/Appearance', () => { expect(store.state.Preferences.appearance.fontSize).toEqual(15) }) it('loadFonts', async () => { - ipcMain.once('list-fonts', (event, _) => { + ipcMain.once('list-fonts', (event: Event, _) => { event.sender.send('response-list-fonts', ['my-font']) }) await store.dispatch('Preferences/loadFonts') diff --git a/src/renderer/store/Preferences/Appearance.ts b/src/renderer/store/Preferences/Appearance.ts index f3ac7d02..fee91293 100644 --- a/src/renderer/store/Preferences/Appearance.ts +++ b/src/renderer/store/Preferences/Appearance.ts @@ -44,7 +44,6 @@ const mutations: MutationTree = { const actions: ActionTree = { loadAppearance: ({ commit }) => { return new Promise((resolve, reject) => { - ipcRenderer.send('get-preferences') ipcRenderer.once('error-get-preferences', (_, err: Error) => { ipcRenderer.removeAllListeners('response-get-preferences') reject(err) @@ -54,11 +53,11 @@ const actions: ActionTree = { commit(MUTATION_TYPES.UPDATE_APPEARANCE, conf.appearance) resolve(conf) }) + ipcRenderer.send('get-preferences') }) }, loadFonts: ({ commit }) => { return new Promise((resolve, reject) => { - ipcRenderer.send('list-fonts') ipcRenderer.once('error-list-fonts', (_, err: Error) => { ipcRenderer.removeAllListeners('response-list-fonts') reject(err) @@ -68,6 +67,7 @@ const actions: ActionTree = { commit(MUTATION_TYPES.UPDATE_FONTS, [DefaultFonts[0]].concat(fonts)) resolve(fonts) }) + ipcRenderer.send('list-fonts') }) }, updateTheme: ({ dispatch, commit, state }, themeKey: string) => { @@ -78,7 +78,6 @@ const actions: ActionTree = { appearance: newAppearance } return new Promise((resolve, reject) => { - ipcRenderer.send('update-preferences', config) ipcRenderer.once('error-update-preferences', (_, err: Error) => { ipcRenderer.removeAllListeners('response-update-preferences') reject(err) @@ -89,6 +88,7 @@ const actions: ActionTree = { dispatch('App/loadPreferences', null, { root: true }) resolve(conf.appearance) }) + ipcRenderer.send('update-preferences', config) }) }, updateFontSize: ({ dispatch, commit, state }, fontSize: number) => { @@ -99,7 +99,6 @@ const actions: ActionTree = { appearance: newAppearance } return new Promise((resolve, reject) => { - ipcRenderer.send('update-preferences', config) ipcRenderer.once('error-update-preferences', (_, err: Error) => { ipcRenderer.removeAllListeners('response-update-preferences') reject(err) @@ -110,6 +109,7 @@ const actions: ActionTree = { dispatch('App/loadPreferences', null, { root: true }) resolve(conf.appearance) }) + ipcRenderer.send('update-preferences', config) }) }, updateDisplayNameStyle: ({ dispatch, commit, state }, value: number) => { @@ -120,7 +120,6 @@ const actions: ActionTree = { appearance: newAppearance } return new Promise((resolve, reject) => { - ipcRenderer.send('update-preferences', config) ipcRenderer.once('error-update-preferences', (_, err: Error) => { ipcRenderer.removeAllListeners('response-update-preferences') reject(err) @@ -131,6 +130,7 @@ const actions: ActionTree = { commit(MUTATION_TYPES.UPDATE_APPEARANCE, conf.appearance) resolve(conf.appearance) }) + ipcRenderer.send('update-preferences', config) }) }, updateTimeFormat: ({ dispatch, commit, state }, value: number) => { @@ -141,7 +141,6 @@ const actions: ActionTree = { appearance: newAppearance } return new Promise((resolve, reject) => { - ipcRenderer.send('update-preferences', config) ipcRenderer.once('error-update-preferences', (_, err: Error) => { ipcRenderer.removeAllListeners('response-update-preferences') reject(err) @@ -152,6 +151,7 @@ const actions: ActionTree = { commit(MUTATION_TYPES.UPDATE_APPEARANCE, conf.appearance) resolve(conf.appearance) }) + ipcRenderer.send('update-preferences', config) }) }, updateCustomThemeColor: ({ dispatch, state, commit }, value: object) => { @@ -163,7 +163,6 @@ const actions: ActionTree = { appearance: newAppearance } return new Promise((resolve, reject) => { - ipcRenderer.send('update-preferences', config) ipcRenderer.once('error-update-preferences', (_, err: Error) => { ipcRenderer.removeAllListeners('response-update-preferences') reject(err) @@ -174,6 +173,7 @@ const actions: ActionTree = { dispatch('App/loadPreferences', null, { root: true }) resolve(conf.appearance) }) + ipcRenderer.send('update-preferences', config) }) }, updateFont: ({ dispatch, state, commit }, value: string) => { @@ -184,7 +184,6 @@ const actions: ActionTree = { appearance: newAppearance } return new Promise((resolve, reject) => { - ipcRenderer.send('update-preferences', config) ipcRenderer.once('error-update-preferences', (_, err: Error) => { ipcRenderer.removeAllListeners('response-update-preferences') reject(err) @@ -195,6 +194,7 @@ const actions: ActionTree = { dispatch('App/loadPreferences', null, { root: true }) resolve(conf.appearance) }) + ipcRenderer.send('update-preferences', config) }) }, updateTootPadding: ({ dispatch, state, commit }, value: number) => { @@ -205,7 +205,6 @@ const actions: ActionTree = { appearance: newAppearance } return new Promise((resolve, reject) => { - ipcRenderer.send('update-preferences', config) ipcRenderer.once('error-update-preferences', (_, err: Error) => { ipcRenderer.removeAllListeners('response-update-preferences') reject(err) @@ -216,6 +215,7 @@ const actions: ActionTree = { dispatch('App/loadPreferences', null, { root: true }) resolve(conf.appearance) }) + ipcRenderer.send('update-preferences', config) }) } }