Skip to content

Commit

Permalink
fix: ignore wrong default.json file while resetting moonraker db (#1829)
Browse files Browse the repository at this point in the history
  • Loading branch information
meteyou authored Apr 27, 2024
1 parent 3582161 commit 9895452
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class LogfilesPanelRolloverDialog extends Mixins(BaseMixin) {
selectedRolloverLogs: string[] = []
get loadingRolloverLogs() {
return this.loadings.filter((log) => log.startsWith('rolloverLog_')).length > 0
return this.loadings.filter((log) => log?.startsWith('rolloverLog_')).length > 0
}
@Watch('loadingRolloverLogs')
Expand Down
21 changes: 11 additions & 10 deletions src/components/settings/General/GeneralReset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,18 @@ export default class SettingsGeneralTabResetDatabase extends Mixins(BaseMixin, S
async loadResetableNamespaces() {
this.resetableNamespaces = await this.loadBackupableNamespaces()
if (this.moonrakerComponents.includes('history')) {
this.resetableNamespaces.push({
value: 'history_jobs',
label: this.$t('Settings.GeneralTab.DbHistoryJobs'),
})
// stop if history is not enabled
if (!this.moonrakerComponents.includes('history')) return
this.resetableNamespaces.push({
value: 'history_totals',
label: this.$t('Settings.GeneralTab.DbHistoryTotals'),
})
}
this.resetableNamespaces.push({
value: 'history_jobs',
label: this.$t('Settings.GeneralTab.DbHistoryJobs'),
})
this.resetableNamespaces.push({
value: 'history_totals',
label: this.$t('Settings.GeneralTab.DbHistoryTotals'),
})
}
closeDialog() {
Expand Down
10 changes: 6 additions & 4 deletions src/store/gui/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,13 @@ export const actions: ActionTree<GuiState, RootState> = {

const urlDefault =
rootGetters['socket/getUrl'] + '/server/files/config/' + themeDir + '/default.json?time=' + Date.now()
const responseDefault = await fetch(urlDefault)

let defaults: any = {}
if (responseDefault) {
defaults = await responseDefault.json()
if (defaults.error?.code === 404) defaults = {}
try {
defaults = await fetch(urlDefault).then((result) => result.json())
} catch (error) {
window.console.error('Error while fetching/parsing default.json', error)
defaults = {}
}

for (const key of payload) {
Expand Down

0 comments on commit 9895452

Please sign in to comment.