refs #948 Add other options in prefereces
This commit is contained in:
parent
b990229cc1
commit
337012c2ef
|
@ -14,6 +14,9 @@ const state = (): GeneralState => {
|
|||
cw: false,
|
||||
nfsw: false,
|
||||
hideAllAttachments: false
|
||||
},
|
||||
other: {
|
||||
launch: false
|
||||
}
|
||||
},
|
||||
loading: false
|
||||
|
|
|
@ -13,6 +13,9 @@ describe('Preferences/General', () => {
|
|||
cw: false,
|
||||
nfsw: false,
|
||||
hideAllAttachments: false
|
||||
},
|
||||
other: {
|
||||
launch: false
|
||||
}
|
||||
},
|
||||
loading: false
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -473,7 +473,6 @@ ipcMain.on('change-auto-launch', (event: Event, enable: boolean) => {
|
|||
launcher.disable()
|
||||
}
|
||||
event.sender.send('response-change-auto-launch', enable)
|
||||
return
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -5,43 +5,29 @@
|
|||
<h3>{{ $t('preferences.general.sounds.title') }}</h3>
|
||||
<p class="description">{{ $t('preferences.general.sounds.description') }}</p>
|
||||
<el-form-item for="fav_rb" :label="$t('preferences.general.sounds.fav_rb')">
|
||||
<el-switch
|
||||
id="fav_rb"
|
||||
v-model="sound_fav_rb"
|
||||
active-color="#13ce66">
|
||||
</el-switch>
|
||||
<el-switch id="fav_rb" v-model="sound_fav_rb" active-color="#13ce66"> </el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item for="sound_toot" :label="$t('preferences.general.sounds.toot')">
|
||||
<el-switch
|
||||
id="sound_toot"
|
||||
v-model="sound_toot"
|
||||
active-color="#13ce66">
|
||||
</el-switch>
|
||||
<el-switch id="sound_toot" v-model="sound_toot" active-color="#13ce66"> </el-switch>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-form class="timeline section" label-potision="right" label-width="250px" size="samll">
|
||||
<h3>{{ $t('preferences.general.timeline.title') }}</h3>
|
||||
<p class="description">{{ $t('preferences.general.timeline.description') }}</p>
|
||||
<el-form-item for="cw" :label="$t('preferences.general.timeline.cw')">
|
||||
<el-switch
|
||||
id="cw"
|
||||
v-model="timeline_cw"
|
||||
active-color="#13ce66">
|
||||
</el-switch>
|
||||
<el-switch id="cw" v-model="timeline_cw" active-color="#13ce66"> </el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item for="nfsw" :label="$t('preferences.general.timeline.nfsw')">
|
||||
<el-switch
|
||||
id="nfsw"
|
||||
v-model="timeline_nfsw"
|
||||
active-color="#13ce66">
|
||||
</el-switch>
|
||||
<el-switch id="nfsw" v-model="timeline_nfsw" active-color="#13ce66"> </el-switch>
|
||||
</el-form-item>
|
||||
<el-form-item for="hideAllAttachments" :label="$t('preferences.general.timeline.hideAllAttachments')">
|
||||
<el-switch
|
||||
id="hideAllAttachments"
|
||||
v-model="timeline_hide_attachments"
|
||||
active-color="#13ce66">
|
||||
</el-switch>
|
||||
<el-switch id="hideAllAttachments" v-model="timeline_hide_attachments" active-color="#13ce66"> </el-switch>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-form class="other section" label-position="right" label-width="250px" size="small">
|
||||
<h3>{{ $t('preferences.general.other.title') }}</h3>
|
||||
<el-form-item for="launch" :label="$t('preferences.general.other.launch')">
|
||||
<el-switch id="launch" v-model="other_launch" active-color="#13ce66"> </el-switch>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
@ -105,11 +91,20 @@ export default {
|
|||
hideAllAttachments: value
|
||||
})
|
||||
}
|
||||
},
|
||||
other_launch: {
|
||||
get() {
|
||||
return this.$store.state.Preferences.General.general.other.launch
|
||||
},
|
||||
set(value) {
|
||||
this.$store.dispatch('Preferences/General/updateOther', {
|
||||
launch: value
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.$store.dispatch('Preferences/General/loadGeneral')
|
||||
.catch(() => {
|
||||
this.$store.dispatch('Preferences/General/loadGeneral').catch(() => {
|
||||
this.$message({
|
||||
message: this.$t('message.preferences_load_error'),
|
||||
type: 'error'
|
||||
|
|
|
@ -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<GeneralState, RootState> = {
|
|||
})
|
||||
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)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
Loading…
Reference in New Issue