diff --git a/spec/renderer/integration/store/Preferences/General.spec.ts b/spec/renderer/integration/store/Preferences/General.spec.ts index 8bdc50f2..04ea2481 100644 --- a/spec/renderer/integration/store/Preferences/General.spec.ts +++ b/spec/renderer/integration/store/Preferences/General.spec.ts @@ -19,7 +19,8 @@ const state = (): GeneralState => { hideAllAttachments: false }, other: { - launch: false + launch: false, + spellcheck: true } }, loading: false diff --git a/spec/renderer/unit/store/Preferences/General.spec.ts b/spec/renderer/unit/store/Preferences/General.spec.ts index d4db7079..4293a9f9 100644 --- a/spec/renderer/unit/store/Preferences/General.spec.ts +++ b/spec/renderer/unit/store/Preferences/General.spec.ts @@ -15,7 +15,8 @@ describe('Preferences/General', () => { hideAllAttachments: false }, other: { - launch: false + launch: false, + spellcheck: true } }, loading: false diff --git a/src/config/locales/en/translation.json b/src/config/locales/en/translation.json index 2e712b1b..b813cad4 100644 --- a/src/config/locales/en/translation.json +++ b/src/config/locales/en/translation.json @@ -135,7 +135,17 @@ }, "other": { "title": "Other options", - "launch": "Launch app on login" + "launch": "Launch app on login", + "spellcheck": { + "description": "Enable spellchecker", + "notice": "Requires relaunch", + "confirm": { + "title": "Warning", + "message": "You have to restart this application. Continue?", + "ok": "Restart Now", + "cancel": "Cancel" + } + } } }, "appearance": { diff --git a/src/main/index.ts b/src/main/index.ts index b1cdf5a9..4b9ca520 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -200,6 +200,16 @@ async function getLanguage() { } } +const getSpellChecker = async (): Promise => { + try { + const preferences = new Preferences(preferencesDBPath) + const conf = await preferences.load() + return conf.general.other.spellcheck + } catch (err) { + return true + } +} + const getMenuPreferences = async (): Promise => { const preferences = new Preferences(preferencesDBPath) const conf = await preferences.load() @@ -225,6 +235,11 @@ async function createWindow() { const language = await getLanguage() i18next.changeLanguage(language) + /** + * Get spellcheck + */ + const spellcheck = await getSpellChecker() + /** * Load system theme color for dark mode */ @@ -283,7 +298,7 @@ async function createWindow() { nodeIntegration: true, contextIsolation: false, preload: path.resolve(__dirname, './preload.js'), - spellcheck: true + spellcheck: spellcheck } } const config: Config = { @@ -907,7 +922,9 @@ ipcMain.handle('get-preferences', async (_: IpcMainInvokeEvent) => { await preferences .update({ general: { - other: enabled + other: { + launch: enabled + } } }) .catch(err => console.error(err)) diff --git a/src/main/preferences.ts b/src/main/preferences.ts index 1c8dd445..49747f34 100644 --- a/src/main/preferences.ts +++ b/src/main/preferences.ts @@ -27,7 +27,8 @@ const timeline: Timeline = { } const other: Other = { - launch: false + launch: false, + spellcheck: true } const general: General = { diff --git a/src/renderer/components/Preferences/General.vue b/src/renderer/components/Preferences/General.vue index 5ae5ba83..824ec667 100644 --- a/src/renderer/components/Preferences/General.vue +++ b/src/renderer/components/Preferences/General.vue @@ -29,6 +29,10 @@ + + +

{{ $t('preferences.general.other.spellcheck.notice') }}

+
@@ -105,6 +109,20 @@ export default { launch: value }) } + }, + other_spellcheck: { + get() { + return this.$store.state.Preferences.General.general.other.spellcheck + }, + set(value) { + this.$store + .dispatch('Preferences/General/updateOther', { + spellcheck: value + }) + .then(() => { + this.confirm() + }) + } } }, created() { @@ -114,6 +132,23 @@ export default { type: 'error' }) }) + }, + methods: { + confirm() { + this.$confirm( + this.$t('preferences.general.other.spellcheck.confirm.message'), + this.$t('preferences.general.other.spellcheck.confirm.title'), + { + confirmButtonText: this.$t('preferences.general.other.spellcheck.confirm.ok'), + cancelButtonText: this.$t('preferences.general.other.spellcheck.confirm.cancel'), + type: 'warning' + } + ) + .then(() => { + this.$store.dispatch('Preferences/General/relaunch') + }) + .catch(() => {}) + } } } @@ -140,5 +175,10 @@ export default { font-weight: 800; } } + + .notice { + color: #c0c4cc; + font-size: 12px; + } } diff --git a/src/renderer/store/Preferences/General.ts b/src/renderer/store/Preferences/General.ts index 639b63a6..a12f6e3e 100644 --- a/src/renderer/store/Preferences/General.ts +++ b/src/renderer/store/Preferences/General.ts @@ -24,7 +24,8 @@ const state = (): GeneralState => ({ hideAllAttachments: false }, other: { - launch: false + launch: false, + spellcheck: true } }, loading: false @@ -96,6 +97,9 @@ const actions: ActionTree = { commit(MUTATION_TYPES.UPDATE_GENERAL, conf.general as General) dispatch('App/loadPreferences', null, { root: true }) await win.ipcRenderer.invoke('change-auto-launch', newOther.launch) + }, + relaunch: () => { + win.ipcRenderer.send('relaunch') } } diff --git a/src/types/preference.ts b/src/types/preference.ts index cd3f3e81..a42bd30c 100644 --- a/src/types/preference.ts +++ b/src/types/preference.ts @@ -7,6 +7,7 @@ import { Proxy } from '~/src/types/proxy' export type Other = { launch: boolean + spellcheck: boolean } export type General = {