| Index: chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js
|
| diff --git a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js
|
| index a5ebfd0931c94c64369bf1a227d78cd9e803b70b..30e11a04a76ffe0c750ca74862a3ec2cd2f45d2c 100644
|
| --- a/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js
|
| +++ b/chrome/browser/resources/settings/bluetooth_page/bluetooth_device_dialog.js
|
| @@ -32,20 +32,33 @@ settings.BluetoothAddDeviceBehavior = {
|
| value: /** @return {Array} */ function() {
|
| return [];
|
| },
|
| - observer: 'deviceListChanged_',
|
| + },
|
| +
|
| + /**
|
| + * The ordered list of unpaired bluetooth devices.
|
| + * @type {!Array<!chrome.bluetooth.Device>}
|
| + */
|
| + unpairedDeviceList_: {
|
| + type: Array,
|
| + value: /** @return {Array} */ function() {
|
| + return [];
|
| + },
|
| },
|
|
|
| /**
|
| * Reflects the iron-list selecteditem property.
|
| * @type {!chrome.bluetooth.Device}
|
| */
|
| - selectedItem: {
|
| + selectedItem_: {
|
| type: Object,
|
| observer: 'selectedItemChanged_',
|
| },
|
| },
|
|
|
| - /** @type {boolean} */ itemWasFocused_: false,
|
| + observers: ['deviceListChanged_(deviceList.*)'],
|
| +
|
| + /** @type {boolean} */
|
| + itemWasFocused_: false,
|
|
|
| /** @private */
|
| adapterStateChanged_: function() {
|
| @@ -55,8 +68,15 @@ settings.BluetoothAddDeviceBehavior = {
|
|
|
| /** @private */
|
| deviceListChanged_: function() {
|
| + var devices = this.$.devices;
|
| + this.saveScroll(devices);
|
| + this.unpairedDeviceList_ = this.deviceList.filter(function(device) {
|
| + return !device.paired;
|
| + });
|
| this.updateScrollableContents();
|
| - if (this.itemWasFocused_ || !this.getUnpaired_().length)
|
| + this.restoreScroll(devices);
|
| +
|
| + if (this.itemWasFocused_ || !this.unpairedDeviceList_.length)
|
| return;
|
| // If the iron-list is populated with at least one visible item then
|
| // focus it.
|
| @@ -72,26 +92,17 @@ settings.BluetoothAddDeviceBehavior = {
|
|
|
| /** @private */
|
| selectedItemChanged_: function() {
|
| - if (this.selectedItem)
|
| - this.fire('device-event', {action: 'connect', device: this.selectedItem});
|
| - },
|
| -
|
| - /**
|
| - * @return {!Array<!chrome.bluetooth.Device>}
|
| - * @private
|
| - */
|
| - getUnpaired_: function() {
|
| - return this.deviceList.filter(function(device) {
|
| - return !device.paired;
|
| - });
|
| + if (!this.selectedItem_)
|
| + return;
|
| + this.fire('device-event', {action: 'connect', device: this.selectedItem_});
|
| },
|
|
|
| /**
|
| - * @return {boolean} True if deviceList contains any unpaired devices.
|
| + * @return {boolean}
|
| * @private
|
| */
|
| - haveUnpaired_: function(deviceList) {
|
| - return this.getUnpaired_().length > 0;
|
| + haveUnpaired_: function() {
|
| + return this.unpairedDeviceList_.length > 0;
|
| },
|
| };
|
|
|
|
|