Skip to content

Commit e342a99

Browse files
committed
Refactor WiFi settings saving to avoid redundant calls
1 parent 6cc39f5 commit e342a99

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

gonotego/settings/server.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,7 @@ def do_POST(self):
173173
continue
174174

175175
try:
176-
settings.set(key, value)
177-
# If we're updating WiFi networks, save networks and update the wpa_supplicant.conf file
176+
# Handle WiFi networks specially
178177
if key == 'WIFI_NETWORKS':
179178
try:
180179
# Parse the value to ensure it's in the correct format
@@ -184,13 +183,17 @@ def do_POST(self):
184183
networks = value
185184

186185
# Save networks using the wifi module's function
186+
# This already calls settings.set() internally
187187
wifi.save_networks(networks)
188188

189189
# Update wpa_supplicant configuration using the wifi module
190190
wifi.update_wpa_supplicant_config()
191191
wifi.reconfigure_wifi()
192192
except Exception as e:
193193
print(f"Error updating WiFi configuration: {e}")
194+
else:
195+
# For all other settings, just use settings.set
196+
settings.set(key, value)
194197
except Exception as e:
195198
print(f"Error setting {key}: {e}")
196199

0 commit comments

Comments
 (0)