Commit fcb8345f authored by Steven Bennetts's avatar Steven Bennetts Committed by Commit Bot

Settings > Internet Details: Fix Device property fetch for MAC address

Prior to this change the Device properties were only fetched the first
time the page was displayed and when a device property changes.
(Navigating to the page with a new network type would not always fetch
the correct device properties). This ensures that the device properties
are always fetched.

The MAC address comes from Device properties and thus was not always
updated correctly.

This also makes the code in the details page and the details dialog
consistent.

Bug: 1012045
Change-Id: I9c39bee6f1077518add306100ff05802a4dc506f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1849265
Commit-Queue: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: default avatarKyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704343}
parent d7dc8866
......@@ -94,10 +94,10 @@ Polymer({
// Set default managedProperties_ until they are loaded.
this.propertiesReceived_ = false;
this.deviceState_ = null;
this.managedProperties_ = OncMojo.getDefaultManagedProperties(
OncMojo.getNetworkTypeFromString(type), this.guid, name);
this.getNetworkDetails_();
this.getDeviceState_();
},
/** @override */
......@@ -182,10 +182,11 @@ Polymer({
/** CrosNetworkConfigObserver impl */
onDeviceStateListChanged: function() {
this.getDeviceState_();
if (this.guid) {
this.getNetworkDetails_();
if (!this.guid || !this.managedProperties_) {
return;
}
this.getDeviceState_();
this.getNetworkDetails_();
},
/** @private */
......@@ -199,16 +200,21 @@ Polymer({
}
this.managedProperties_ = response.result;
this.propertiesReceived_ = true;
if (!this.deviceState_) {
this.getDeviceState_();
}
});
},
/** @private */
getDeviceState_: function() {
if (!this.managedProperties_) {
return;
}
const type = this.managedProperties_.type;
this.networkConfig_.getDeviceStateList().then(response => {
const devices = response.result;
this.deviceState_ =
devices.find(device => device.type == this.managedProperties_.type) ||
null;
this.deviceState_ = devices.find(device => device.type == type) || null;
});
},
......
......@@ -243,6 +243,7 @@ Polymer({
this.guid = guid;
// Set default properties until they are loaded.
this.propertiesReceived_ = false;
this.deviceState_ = null;
this.managedProperties_ = OncMojo.getDefaultManagedProperties(
OncMojo.getNetworkTypeFromString(type), this.guid, name);
this.didSetFocus_ = false;
......@@ -364,15 +365,10 @@ Polymer({
if (!this.managedProperties_) {
return;
}
const type = this.managedProperties_.type;
this.networkConfig_.getDeviceStateList().then(response => {
if (!this.managedProperties_) {
return;
}
const devices = response.result;
this.deviceState_ =
devices.find(device => device.type == this.managedProperties_.type) ||
null;
this.deviceState_ = devices.find(device => device.type == type) || null;
});
},
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment