From d029e72b4798972c7ac3dca1afe351801301f2c0 Mon Sep 17 00:00:00 2001 From: Blake Kaplan Date: Wed, 9 Jan 2013 15:14:22 +0100 Subject: [PATCH] Bug 823783 - Handle various combinations of settings events and wifi events more correctly. --- apps/settings/js/wifi.js | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/apps/settings/js/wifi.js b/apps/settings/js/wifi.js index bf988f2bd4da..6325deb65a52 100644 --- a/apps/settings/js/wifi.js +++ b/apps/settings/js/wifi.js @@ -81,14 +81,33 @@ onLocalized(function wifiSettings() { }; gWifiManager.onenabled = function onWifiEnabled() { - // enable UI toogle + // enable UI toggle + if (!lastMozSettingValue) { + // Wifi just came up, but the last known value of the setting was false. + // This either means that some external force turned it on (in which + // case we need to update the setting) or we simply haven't received the + // settings change event. Do that now and update our + // lastMozSettingValue. This will have the side-effect of not disabling + // the checkbox. + settings.createLock().set({ 'wifi.enabled': true }); + lastMozSettingValue = true; + setMozSettingsEnabled(lastMozSettingValue); + } + gWifiCheckBox.disabled = false; updateNetworkState(); gNetworkList.scan(); }; gWifiManager.ondisabled = function onWifiDisabled() { - // enable UI toogle + // enable UI toggle + if (lastMozSettingValue) { + // See the comment in onWifiEnabled for why we do this. + settings.createLock().set({ 'wifi.enabled': false }); + lastMozSettingValue = false; + setMozSettingsEnabled(lastMozSettingValue); + } + gWifiCheckBox.disabled = false; gWifiInfoBlock.textContent = _('disabled'); gNetworkList.clear(false);