Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Z-Bolt/OctoScreen.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeffB42 <10328858+JeffB42@users.noreply.github.com>2021-03-30 08:55:39 +0300
committerJeffB42 <10328858+JeffB42@users.noreply.github.com>2021-03-30 08:55:39 +0300
commit5092ddea7512cf6121a5b4df1a5618d129709efe (patch)
treed091b0605e8654be20c52b027e625c98e8c4eff3
parent2fad643c00efc35d0c8c086bac522974c6d3e547 (diff)
changed order in which loadSettings() is called
-rwxr-xr-xui/ui.go53
1 files changed, 27 insertions, 26 deletions
diff --git a/ui/ui.go b/ui/ui.go
index 0276fc6..a753045 100755
--- a/ui/ui.go
+++ b/ui/ui.go
@@ -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()")
}