From cddf4ac2fe4acbbf91921f87e7ae8a0b7dcc21a6 Mon Sep 17 00:00:00 2001 From: miruka Date: Fri, 26 Jun 2020 02:20:12 -0400 Subject: [PATCH] Reload section item counts on verify/blacklist --- .../Pages/AccountSettings/DeviceSection.qml | 2 +- src/gui/Pages/AccountSettings/Sessions.qml | 26 ++++++++++--------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/gui/Pages/AccountSettings/DeviceSection.qml b/src/gui/Pages/AccountSettings/DeviceSection.qml index 908ca2aa..4ba77009 100644 --- a/src/gui/Pages/AccountSettings/DeviceSection.qml +++ b/src/gui/Pages/AccountSettings/DeviceSection.qml @@ -31,8 +31,8 @@ HRowLayout { tristate: true checkState: - sectionTotalCount === sectionCheckedCount ? Qt.Checked : ! sectionCheckedCount ? Qt.Unchecked : + sectionTotalCount === sectionCheckedCount ? Qt.Checked : Qt.PartiallyChecked nextCheckState: diff --git a/src/gui/Pages/AccountSettings/Sessions.qml b/src/gui/Pages/AccountSettings/Sessions.qml index bb0501dd..99198d57 100644 --- a/src/gui/Pages/AccountSettings/Sessions.qml +++ b/src/gui/Pages/AccountSettings/Sessions.qml @@ -25,7 +25,8 @@ HColumnPage { for (const device of devices) deviceList.model.append(device) - loadFuture = null + loadFuture = null + deviceList.sectionItemCounts = getSectionItemCounts() }) } @@ -39,6 +40,17 @@ HColumnPage { }) } + function getSectionItemCounts() { + const counts = {} + + for (let i = 0; i < deviceList.model.count; i++) { + const section = deviceList.model.get(i).type + section in counts ? counts[section] += 1 : counts[section] = 1 + } + + return counts + } + footer: ButtonLayout { visible: height >= 0 @@ -61,17 +73,7 @@ HColumnPage { HListView { id: deviceList - readonly property var sectionItemCounts: { - const counts = {} - - for (let i = 0; i < count; i++) { - const section = model.get(i).type - section in counts ? counts[section] += 1 : counts[section] = 1 - } - - print( "rec") - return counts - } + property var sectionItemCounts: getSectionItemCounts() clip: true model: ListModel {}