From 31ffe45b794b8cd5ffd9bd9a92e45d6f18bdf5ac Mon Sep 17 00:00:00 2001
From: Matt Ranostay <matt.ranostay@konsulko.com>
Date: Mon, 21 May 2018 00:56:42 -0700
Subject: settings: bluetooth: qml: stop duplicate entries in lists

Due to the current subscription model each subscriber causes an
discovery_result event to be emitted. So each client must be sure
they aren't adding entries more than once.

Bug-AGL: SPEC-1385
Change-Id: I125eb33327944407c018b01776ba9bb3e0d4c08f
Signed-off-by: Matt Ranostay <matt.ranostay@konsulko.com>
---
 app/bluetooth/Bluetooth.qml | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/app/bluetooth/Bluetooth.qml b/app/bluetooth/Bluetooth.qml
index 46aee81..3a65725 100644
--- a/app/bluetooth/Bluetooth.qml
+++ b/app/bluetooth/Bluetooth.qml
@@ -76,6 +76,7 @@ SettingPage {
             for (var i = 0; i < data.list.length; i++) {
                 var value = data.list[i]
                 if (value.Paired==="True") {
+                    if(findPairDevice(value.Address) == -1) {
                       pairedDeviceList.append({
                                       deviceAddress: value.Address,
                                       deviceName: value.Name,
@@ -86,8 +87,10 @@ SettingPage {
                                       textToShow: ""
                                   })
                       pairedDeviceCount = pairedDeviceCount + 1
+                    }
                   }
                 else
+                  if (findDevice(value.Address) == -1) {
                       btDeviceList.append({
                                        deviceAddress: value.Address,
                                        deviceName: value.Name,
@@ -97,6 +100,7 @@ SettingPage {
                                        connectHFP: value.HFPConnected,
                                        textToShow: ""
                                   })
+                  }
             }
         }
 
-- 
cgit