Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(ui): add toggle for disable automatic updates #173

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/electron/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const requests = require('./request')
const db = require('./db')
const helpers = require('./helpers')
const TaskQueue = require('./task-queue')
require('update-electron-app')()
const updateElectronApp = require('update-electron-app')

Object.assign(console, log.functions)

Expand Down Expand Up @@ -201,6 +201,11 @@ app.whenReady().then(async() => {

ipcMain.handle('readFile', (_, ...args) => helpers.readFile(...args))

ipcMain.handle('updateElectronApp', (_) => {
console.log('ipcMain: updateElectronApp')
updateElectronApp()
})

createWindow()
})

Expand Down
1 change: 1 addition & 0 deletions packages/electron/src/preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const ipcFunctions = [
'openFolderSelectionDialog',
'openFolder',
'readFile',
'updateElectronApp',
]

const electronIPC = ipcFunctions.reduce((acc, funcName) => {
Expand Down
13 changes: 13 additions & 0 deletions packages/ui/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export default {
const savedDisableSSLVerification = localStorage.getItem(constants.LOCAL_STORAGE_KEY.DISABLE_SSL_VERIFICATION)
const savedElectronSwitchToChromiumFetch = localStorage.getItem(constants.LOCAL_STORAGE_KEY.ELECTRON_SWITCH_TO_CHROMIUM_FETCH)
const savedDisableIframeSandbox = localStorage.getItem(constants.LOCAL_STORAGE_KEY.DISABLE_IFRAME_SANDBOX)
const savedDisableAutoUpdate = localStorage.getItem(constants.LOCAL_STORAGE_KEY.DISABLE_AUTO_UPDATE)

if(savedTheme) {
this.$store.state.theme = savedTheme
Expand Down Expand Up @@ -385,9 +386,21 @@ export default {
}
}

if(savedDisableAutoUpdate) {
try {
this.$store.state.flags.disableAutoUpdate = JSON.parse(savedDisableAutoUpdate)
} catch(e) {
this.$store.state.flags.disableAutoUpdate = false
}
}

emitter.on('error', this.handleError)

if(import.meta.env.MODE === 'desktop-electron') {
if (!this.$store.state.flags.disableAutoUpdate) {
console.log('invoke updateElectronApp')
window.electronIPC.updateElectronApp()
}
const refreshWorkspace = debounce(() => {
this.$store.dispatch('refreshWorkspace')
this.$store.commit('loadWorkspacePlugins')
Expand Down
24 changes: 24 additions & 0 deletions packages/ui/src/components/modals/SettingsModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
<div style="margin-left: 1.3rem; margin-top: 0.3rem;">Ticking this will disable SSL verification for all requests made from the application. This is useful when you are working with self signed certificates.</div>
</div>
<div style="padding-top: 1rem"></div>
<div>
<label style="display: flex;">
<input type="checkbox" v-model="disableAutoUpdate"> <div style="margin-left: 0.5rem;">Disable Automatic Updates</div> <div style="margin-left: 0.5rem;"></div>
</label>
<div style="margin-left: 1.3rem; margin-top: 0.3rem;">Ticking this will disable automatic updates</div>
</div>
<div style="padding-top: 1rem"></div>
<div>
<label style="display: flex;">
<input type="checkbox" v-model="electronSwitchToChromiumFetch"> <div style="margin-left: 0.5rem;">Switch to Chromium Fetch</div> <div style="margin-left: 0.5rem;"></div>
Expand Down Expand Up @@ -79,6 +86,7 @@ export default {
disableSSLVerification: false,
electronSwitchToChromiumFetch: false,
disableIframeSandbox: false,
disableAutoUpdate: false,
}
},
computed: {
Expand Down Expand Up @@ -118,6 +126,10 @@ export default {
disableIframeSandbox() {
localStorage.setItem(constants.LOCAL_STORAGE_KEY.DISABLE_IFRAME_SANDBOX, this.disableIframeSandbox)
this.$store.state.flags.disableIframeSandbox = this.disableIframeSandbox
},
disableAutoUpdate() {
localStorage.setItem(constants.LOCAL_STORAGE_KEY.DISABLE_AUTO_UPDATE, this.disableAutoUpdate)
this.$store.state.flags.disableAutoUpdate = this.disableAutoUpdate
}
},
methods: {
Expand All @@ -141,6 +153,9 @@ export default {
resetDisableIframeSandbox() {
localStorage.removeItem(constants.LOCAL_STORAGE_KEY.DISABLE_IFRAME_SANDBOX)
},
resetDisableAutoUpdate() {
localStorage.removeItem(constants.LOCAL_STORAGE_KEY.DISABLE_AUTO_UPDATE)
},
resetSettings(target = null) {
if(target) {
if(target === 'widths') {
Expand All @@ -158,6 +173,7 @@ export default {
this.resetDisableSSLVerification()
this.resetElectronSwitchToChromiumFetch()
this.resetDisableIframeSandbox()
this.resetDisableAutoUpdate()

document.location.reload()
},
Expand All @@ -169,6 +185,7 @@ export default {
const savedDisableSSLVerification = localStorage.getItem(constants.LOCAL_STORAGE_KEY.DISABLE_SSL_VERIFICATION)
const savedElectronSwitchToChromiumFetch = localStorage.getItem(constants.LOCAL_STORAGE_KEY.ELECTRON_SWITCH_TO_CHROMIUM_FETCH)
const savedDisableIframeSandbox = localStorage.getItem(constants.LOCAL_STORAGE_KEY.DISABLE_IFRAME_SANDBOX)
const savedDisableAutoUpdate = localStorage.getItem(constants.LOCAL_STORAGE_KEY.DISABLE_AUTO_UPDATE)

if(savedSidebarWidth) {
this.sidebarWidth = savedSidebarWidth
Expand Down Expand Up @@ -212,6 +229,13 @@ export default {
this.disableIframeSandbox = false
}
}
if(savedDisableAutoUpdate) {
try {
this.disableAutoUpdate = JSON.parse(savedDisableAutoUpdate)
} catch (e) {
this.disableAutoUpdate = false
}
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export default {
DISABLE_PAGE_VIEW_ANALYTICS_TRACKING: 'Restfox-DisablePageViewAnalyticsTracking',
DISABLE_SSL_VERIFICATION: 'Restfox-DisableSSLVerification',
DISABLE_IFRAME_SANDBOX: 'Restfox-DisableIframeSandbox',
DISABLE_AUTO_UPDATE: 'Restfox-DisableAutoUpdate',
ELECTRON_SWITCH_TO_CHROMIUM_FETCH: 'Restfox-ElectronSwitchToChromiumFetch',
GENERATE_CODE_LANGUAGE: 'Restfox-GenerateCodeLanguage',
GENERATE_CODE_CLIENT: 'Restfox-GenerateCodeClient',
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ const store = createStore<State>({
disableSSLVerification: false,
electronSwitchToChromiumFetch: false,
disableIframeSandbox : false,
disableAutoUpdate : false,
},
openContextMenuElement: null,
sockets: {},
Expand Down
Loading