feat: setting to enable beta updates (future use)

This commit is contained in:
Fabio Di Stasio 2021-02-27 17:28:01 +01:00
parent 39ca1974bc
commit b1ea32b680
5 changed files with 37 additions and 12 deletions

View File

@ -1,8 +1,10 @@
import { ipcMain } from 'electron'; import { ipcMain } from 'electron';
import { autoUpdater } from 'electron-updater'; import { autoUpdater } from 'electron-updater';
import Store from 'electron-store';
const persistentStore = new Store({ name: 'settings' });
let mainWindow; let mainWindow;
autoUpdater.allowPrerelease = true; autoUpdater.allowPrerelease = persistentStore.get('allow_prerelease', true);
export default () => { export default () => {
ipcMain.on('check-for-updates', event => { ipcMain.on('check-for-updates', event => {

View File

@ -36,11 +36,17 @@
{{ $t('message.restartToInstall') }} {{ $t('message.restartToInstall') }}
</button> </button>
</div> </div>
<div class="form-group mt-4">
<label class="form-switch d-inline-block disabled" @click.prevent="toggleAllowPrerelease">
<input type="checkbox" :checked="allowPrerelease">
<i class="form-icon" /> {{ $t('message.includeBetaUpdates') }}
</label>
</div>
</div> </div>
</template> </template>
<script> <script>
import { mapGetters } from 'vuex'; import { mapGetters, mapActions } from 'vuex';
import { ipcRenderer } from 'electron'; import { ipcRenderer } from 'electron';
export default { export default {
@ -48,7 +54,8 @@ export default {
computed: { computed: {
...mapGetters({ ...mapGetters({
updateStatus: 'application/getUpdateStatus', updateStatus: 'application/getUpdateStatus',
downloadPercentage: 'application/getDownloadProgress' downloadPercentage: 'application/getDownloadProgress',
allowPrerelease: 'settings/getAllowPrerelease'
}), }),
updateMessage () { updateMessage () {
switch (this.updateStatus) { switch (this.updateStatus) {
@ -70,11 +77,17 @@ export default {
} }
}, },
methods: { methods: {
...mapActions({
changeAllowPrerelease: 'settings/changeAllowPrerelease'
}),
checkForUpdates () { checkForUpdates () {
ipcRenderer.send('check-for-updates'); ipcRenderer.send('check-for-updates');
}, },
restartToUpdate () { restartToUpdate () {
ipcRenderer.send('restart-to-update'); ipcRenderer.send('restart-to-update');
},
toggleAllowPrerelease () {
this.changeAllowPrerelease(!this.allowPrerelease);
} }
} }
}; };

View File

@ -191,7 +191,8 @@ module.exports = {
fakeDataLanguage: 'Fake data language', fakeDataLanguage: 'Fake data language',
searchForElements: 'Search for elements', searchForElements: 'Search for elements',
selectAll: 'Select all', selectAll: 'Select all',
queryDuration: 'Query duration' queryDuration: 'Query duration',
includeBetaUpdates: 'Include beta updates'
}, },
faker: { faker: {
address: 'Address', address: 'Address',

View File

@ -12,7 +12,7 @@ export default {
namespaced: true, namespaced: true,
strict: true, strict: true,
state: { state: {
connections: persistentStore.get('connections') || [] connections: persistentStore.get('connections', [])
}, },
getters: { getters: {
getConnections: state => state.connections, getConnections: state => state.connections,

View File

@ -7,16 +7,18 @@ export default {
namespaced: true, namespaced: true,
strict: true, strict: true,
state: { state: {
locale: persistentStore.get('locale') || 'en-US', locale: persistentStore.get('locale', 'en-US'),
explorebar_size: persistentStore.get('explorebar_size') || null, allow_prerelease: persistentStore.get('allow_prerelease', true),
notifications_timeout: persistentStore.get('notifications_timeout') || 5, explorebar_size: persistentStore.get('explorebar_size', null),
auto_complete: persistentStore.get('auto_complete') || true, notifications_timeout: persistentStore.get('notifications_timeout', 5),
line_wrap: persistentStore.get('line_wrap') || true, auto_complete: persistentStore.get('auto_complete', true),
application_theme: persistentStore.get('application_theme') || 'dark', line_wrap: persistentStore.get('line_wrap', true),
editor_theme: persistentStore.get('editor_theme') || 'twilight' application_theme: persistentStore.get('application_theme', 'dark'),
editor_theme: persistentStore.get('editor_theme', 'twilight')
}, },
getters: { getters: {
getLocale: state => state.locale, getLocale: state => state.locale,
getAllowPrerelease: state => state.allow_prerelease,
getExplorebarSize: state => state.explorebar_size, getExplorebarSize: state => state.explorebar_size,
getNotificationsTimeout: state => state.notifications_timeout, getNotificationsTimeout: state => state.notifications_timeout,
getAutoComplete: state => state.auto_complete, getAutoComplete: state => state.auto_complete,
@ -30,6 +32,10 @@ export default {
i18n.locale = locale; i18n.locale = locale;
persistentStore.set('locale', state.locale); persistentStore.set('locale', state.locale);
}, },
SET_ALLOW_PRERELEASE (state, allow) {
state.allow_prerelease = allow;
persistentStore.set('allow_prerelease', state.allow_prerelease);
},
SET_NOTIFICATIONS_TIMEOUT (state, timeout) { SET_NOTIFICATIONS_TIMEOUT (state, timeout) {
state.notifications_timeout = timeout; state.notifications_timeout = timeout;
persistentStore.set('notifications_timeout', state.notifications_timeout); persistentStore.set('notifications_timeout', state.notifications_timeout);
@ -54,6 +60,9 @@ export default {
changeLocale ({ commit }, locale) { changeLocale ({ commit }, locale) {
commit('SET_LOCALE', locale); commit('SET_LOCALE', locale);
}, },
changeAllowPrerelease ({ commit }, allow) {
commit('SET_ALLOW_PRERELEASE', allow);
},
updateNotificationsTimeout ({ commit }, timeout) { updateNotificationsTimeout ({ commit }, timeout) {
commit('SET_NOTIFICATIONS_TIMEOUT', timeout); commit('SET_NOTIFICATIONS_TIMEOUT', timeout);
}, },