diff --git a/spec/renderer/integration/store/Preferences/General.spec.ts b/spec/renderer/integration/store/Preferences/General.spec.ts index 9c73abeb..65d164fe 100644 --- a/spec/renderer/integration/store/Preferences/General.spec.ts +++ b/spec/renderer/integration/store/Preferences/General.spec.ts @@ -14,6 +14,9 @@ const state = (): GeneralState => { cw: false, nfsw: false, hideAllAttachments: false + }, + other: { + launch: false } }, loading: false @@ -31,7 +34,7 @@ const initStore = () => { const app = { namespaced: true, actions: { - loadPreferences (_) { + loadPreferences(_) { return true } } diff --git a/spec/renderer/unit/store/Preferences/General.spec.ts b/spec/renderer/unit/store/Preferences/General.spec.ts index 15d25632..5f624385 100644 --- a/spec/renderer/unit/store/Preferences/General.spec.ts +++ b/spec/renderer/unit/store/Preferences/General.spec.ts @@ -13,6 +13,9 @@ describe('Preferences/General', () => { cw: false, nfsw: false, hideAllAttachments: false + }, + other: { + launch: false } }, loading: false diff --git a/src/config/locales/en/translation.json b/src/config/locales/en/translation.json index 7fa0aad2..1eedd4cd 100644 --- a/src/config/locales/en/translation.json +++ b/src/config/locales/en/translation.json @@ -127,6 +127,10 @@ "cw": "Always ignore contents warnings", "nfsw": "Always ignore NFSW of medias", "hideAllAttachments": "Hide all medias" + }, + "other": { + "title": "Other options", + "launch": "Launch app on login" } }, "appearance": { diff --git a/src/main/index.ts b/src/main/index.ts index 4f681f87..8abd2f47 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -473,7 +473,6 @@ ipcMain.on('change-auto-launch', (event: Event, enable: boolean) => { launcher.disable() } event.sender.send('response-change-auto-launch', enable) - return }) }) diff --git a/src/main/preferences.ts b/src/main/preferences.ts index 7f76dd0c..57a34753 100644 --- a/src/main/preferences.ts +++ b/src/main/preferences.ts @@ -11,7 +11,7 @@ import { Timeline } from '~/src/types/timeline' import { Notify } from '~/src/types/notify' import { Appearance } from '~/src/types/appearance' import { Language as LanguageSet } from '~/src/types/language' -import { General, State, Notification, BaseConfig } from '~/src/types/preference' +import { General, State, Notification, BaseConfig, Other } from '~/src/types/preference' const sound: Sound = { fav_rb: true, @@ -24,9 +24,14 @@ const timeline: Timeline = { hideAllAttachments: false } +const other: Other = { + launch: false +} + const general: General = { sound: sound, - timeline: timeline + timeline: timeline, + other: other } const state: State = { diff --git a/src/renderer/components/Preferences/General.vue b/src/renderer/components/Preferences/General.vue index 5d854baa..4918da89 100644 --- a/src/renderer/components/Preferences/General.vue +++ b/src/renderer/components/Preferences/General.vue @@ -1,50 +1,36 @@ diff --git a/src/renderer/store/Preferences/General.ts b/src/renderer/store/Preferences/General.ts index 721e4a5d..6aaf3244 100644 --- a/src/renderer/store/Preferences/General.ts +++ b/src/renderer/store/Preferences/General.ts @@ -3,7 +3,7 @@ import { Module, MutationTree, ActionTree } from 'vuex' import { RootState } from '@/store' import { Sound } from '~/src/types/sound' import { Timeline } from '~/src/types/timeline' -import { BaseConfig, General } from '~/src/types/preference' +import { BaseConfig, General, Other } from '~/src/types/preference' export type GeneralState = { general: General @@ -20,6 +20,9 @@ const state = (): GeneralState => ({ cw: false, nfsw: false, hideAllAttachments: false + }, + other: { + launch: false } }, loading: false @@ -105,6 +108,32 @@ const actions: ActionTree = { }) ipcRenderer.send('update-preferences', config) }) + }, + updateOther: ({ commit, state, dispatch }, other: {}) => { + commit(MUTATION_TYPES.CHANGE_LOADING, true) + const newOther: Other = Object.assign({}, state.general.other, other) + const newGeneral: General = Object.assign({}, state.general, { + other: newOther + }) + const config = { + general: newGeneral + } + return new Promise((resolve, reject) => { + // TODO: call change settings + ipcRenderer.once('error-update-preferences', (_, err: Error) => { + ipcRenderer.removeAllListeners('response-update-preferences') + commit(MUTATION_TYPES.CHANGE_LOADING, false) + reject(err) + }) + ipcRenderer.once('response-update-preferences', (_, conf: BaseConfig) => { + ipcRenderer.removeAllListeners('error-update-preferences') + commit(MUTATION_TYPES.UPDATE_GENERAL, conf.general as General) + commit(MUTATION_TYPES.CHANGE_LOADING, false) + dispatch('App/loadPreferences', null, { root: true }) + resolve(conf) + }) + ipcRenderer.send('update-preferences', config) + }) } } diff --git a/src/types/preference.ts b/src/types/preference.ts index 3ed1b8fc..218c7703 100644 --- a/src/types/preference.ts +++ b/src/types/preference.ts @@ -4,9 +4,14 @@ import { Notify } from '~/src/types/notify' import { Appearance } from '~/src/types/appearance' import { Language } from '~/src/types/language' +export type Other = { + launch: boolean +} + export type General = { sound: Sound timeline: Timeline + other: Other } export type State = {