diff options
author | JeffB42 <10328858+JeffB42@users.noreply.github.com> | 2021-03-30 08:55:39 +0300 |
---|---|---|
committer | JeffB42 <10328858+JeffB42@users.noreply.github.com> | 2021-03-30 08:55:39 +0300 |
commit | 5092ddea7512cf6121a5b4df1a5618d129709efe (patch) | |
tree | d091b0605e8654be20c52b027e625c98e8c4eff3 | |
parent | 2fad643c00efc35d0c8c086bac522974c6d3e547 (diff) |
changed order in which loadSettings() is called
-rwxr-xr-x | ui/ui.go | 53 |
1 files changed, 27 insertions, 26 deletions
@@ -171,6 +171,10 @@ func (this *UI) verifyConnection() { this.ConnectionState = connectionResponse.Current.State newUIState, splashMessage = this.getUiStateAndMessageFromConnectionResponse(connectionResponse, newUIState, splashMessage) + + if this.Settings == nil { + this.loadSettings() + } } else { logger.LogError("ui.verifyConnection()", "Broke into the else condition because Do(ConnectionRequest) returned an error", err) newUIState, splashMessage = this.getUiStateAndMessageFromError(err, newUIState, splashMessage) @@ -341,6 +345,12 @@ func (this *UI) checkNotification() { func (this *UI) loadSettings() { logger.TraceEnter("ui.loadSettings()") + if this.Settings != nil { + logger.Error("ui.loadSettings() - this.Settings has already been set") + logger.TraceLeave("ui.loadSettings()") + return + } + settingsResponse, err := (&octoprintApis.OctoScreenSettingsRequest{}).Do(this.Client, this.UIState) if err != nil { text := err.Error() @@ -355,19 +365,26 @@ func (this *UI) loadSettings() { } this.OctoPrintPluginIsAvailable = false - - logger.TraceLeave("ui.loadSettings()") - return + // Use default settings + this.Settings = &dataModels.OctoScreenSettingsResponse { + FilamentInLength: 100, + FilamentOutLength: 100, + ToolChanger: false, + XAxisInverted: false, + YAxisInverted: false, + ZAxisInverted: false, + MenuStructure: nil, + } } else { logger.Info("The call to GetSettings succeeded and the OctoPrint plug-in is available") this.OctoPrintPluginIsAvailable = true - } - if !this.validateMenuItems(settingsResponse.MenuStructure, "", true) { - settingsResponse.MenuStructure = nil - } + if !this.validateMenuItems(settingsResponse.MenuStructure, "", true) { + settingsResponse.MenuStructure = nil + } - this.Settings = settingsResponse + this.Settings = settingsResponse + } logger.TraceLeave("ui.loadSettings()") } @@ -425,7 +442,7 @@ func (this *UI) update() { logger.TraceEnter("ui.update()") this.sdNotify(daemon.SdNotifyWatchdog) - + if this.connectionAttempts > 8 { logger.Info("ui.update() - this.connectionAttempts > 8") this.splashPanel.putOnHold() @@ -442,28 +459,12 @@ func (this *UI) update() { this.connectionAttempts = 0 } - if this.Settings == nil { - this.loadSettings() - - if this.Settings == nil { - this.Settings = &dataModels.OctoScreenSettingsResponse { - FilamentInLength: 100, - FilamentOutLength: 100, - ToolChanger: false, - XAxisInverted: false, - YAxisInverted: false, - ZAxisInverted: false, - MenuStructure: nil, - } - } - } + this.verifyConnection() if this.OctoPrintPluginIsAvailable { this.checkNotification() } - this.verifyConnection() - logger.TraceLeave("ui.update()") } |