From 8704cb19a449e7f866d89c0c241ae95c4237f5bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Mon, 1 Apr 2024 16:20:07 +0200 Subject: [PATCH] chore(SharedAddressesPermissionsPanel): use FastExpressionFilter - speed up the construction of the permissions overview panels --- .../panels/SharedAddressesAccountSelector.qml | 1 + .../SharedAddressesPermissionsPanel.qml | 58 ++++++++++--------- 2 files changed, 33 insertions(+), 26 deletions(-) diff --git a/ui/app/AppLayouts/Communities/panels/SharedAddressesAccountSelector.qml b/ui/app/AppLayouts/Communities/panels/SharedAddressesAccountSelector.qml index 36ec5dc8d1..84a067136d 100644 --- a/ui/app/AppLayouts/Communities/panels/SharedAddressesAccountSelector.qml +++ b/ui/app/AppLayouts/Communities/panels/SharedAddressesAccountSelector.qml @@ -258,6 +258,7 @@ StatusListView { // Singletons cannot be used directly in sfpm's expressions expression: typeVal + expectedRoles: [] }, FastExpressionRole { name: "imageUrl" diff --git a/ui/app/AppLayouts/Communities/panels/SharedAddressesPermissionsPanel.qml b/ui/app/AppLayouts/Communities/panels/SharedAddressesPermissionsPanel.qml index bc24aa4744..0204c1d986 100644 --- a/ui/app/AppLayouts/Communities/panels/SharedAddressesPermissionsPanel.qml +++ b/ui/app/AppLayouts/Communities/panels/SharedAddressesPermissionsPanel.qml @@ -2,6 +2,7 @@ import QtQuick 2.15 import QtQuick.Controls 2.15 import QtQuick.Layouts 1.15 +import StatusQ 0.1 import StatusQ.Core 0.1 import StatusQ.Components 0.1 import StatusQ.Core.Theme 0.1 @@ -73,34 +74,36 @@ Rectangle { readonly property var tokenMasterPermissionsModel: SortFilterProxyModel { id: tokenMasterPermissionsModel sourceModel: root.permissionsModel - function filterPredicate(modelData) { - return (modelData.permissionType === Constants.permissionType.becomeTokenMaster) - && modelData.tokenCriteriaMet + function filterPredicate(permissionType, tokenCriteriaMet) { + return (permissionType === Constants.permissionType.becomeTokenMaster) && tokenCriteriaMet } - filters: ExpressionFilter { - expression: tokenMasterPermissionsModel.filterPredicate(model) + filters: FastExpressionFilter { + expression: tokenMasterPermissionsModel.filterPredicate(model.permissionType, model.tokenCriteriaMet) + expectedRoles: ["permissionType", "tokenCriteriaMet"] } } readonly property var adminPermissionsModel: SortFilterProxyModel { id: adminPermissionsModel sourceModel: root.permissionsModel - function filterPredicate(modelData) { - return (modelData.permissionType === Constants.permissionType.admin) && - (!modelData.isPrivate || (modelData.tokenCriteriaMet && modelData.isPrivate)) // visible or (hidden & met) + function filterPredicate(permissionType, tokenCriteriaMet, isPrivate) { + return (permissionType === Constants.permissionType.admin) && + (!isPrivate || (tokenCriteriaMet && isPrivate)) // visible or (hidden & met) } - filters: ExpressionFilter { - expression: adminPermissionsModel.filterPredicate(model) + filters: FastExpressionFilter { + expression: adminPermissionsModel.filterPredicate(model.permissionType, model.tokenCriteriaMet, model.isPrivate) + expectedRoles: ["permissionType", "tokenCriteriaMet", "isPrivate"] } } readonly property var joinPermissionsModel: SortFilterProxyModel { id: joinPermissionsModel sourceModel: root.permissionsModel - function filterPredicate(modelData) { - return (modelData.permissionType === Constants.permissionType.member) && - (!modelData.isPrivate || (modelData.tokenCriteriaMet && modelData.isPrivate)) // visible or (hidden & met) + function filterPredicate(permissionType, tokenCriteriaMet, isPrivate) { + return (permissionType === Constants.permissionType.member) && + (!isPrivate || (tokenCriteriaMet && isPrivate)) // visible or (hidden & met) } - filters: ExpressionFilter { - expression: joinPermissionsModel.filterPredicate(model) + filters: FastExpressionFilter { + expression: joinPermissionsModel.filterPredicate(model.permissionType, model.tokenCriteriaMet, model.isPrivate) + expectedRoles: ["permissionType", "tokenCriteriaMet", "isPrivate"] } } @@ -108,12 +111,13 @@ Rectangle { readonly property var channelsPermissionsModel: SortFilterProxyModel { id: channelsPermissionsModel sourceModel: root.permissionsModel - function filterPredicate(modelData) { - return (modelData.permissionType === Constants.permissionType.read || modelData.permissionType === Constants.permissionType.viewAndPost) && - (!modelData.isPrivate || (modelData.tokenCriteriaMet && modelData.isPrivate)) // visible or (hidden & met) + function filterPredicate(permissionType, tokenCriteriaMet, isPrivate) { + return (permissionType === Constants.permissionType.read || permissionType === Constants.permissionType.viewAndPost) && + (!isPrivate || (tokenCriteriaMet && isPrivate)) // visible or (hidden & met) } - filters: ExpressionFilter { - expression: channelsPermissionsModel.filterPredicate(model) + filters: FastExpressionFilter { + expression: channelsPermissionsModel.filterPredicate(model.permissionType, model.tokenCriteriaMet, model.isPrivate) + expectedRoles: ["permissionType", "tokenCriteriaMet", "isPrivate"] } } } @@ -485,13 +489,15 @@ Rectangle { model: SortFilterProxyModel { id: channelPermissionsModel sourceModel: root.permissionsModel - function filterPredicate(modelData) { - return modelData.permissionType === channelPermsSubPanel.permissionType && - (!modelData.isPrivate || (modelData.tokenCriteriaMet && modelData.isPrivate)) && - ModelUtils.contains(modelData.channelsListModel, "key", channelPermsPanel.channelKey) // filter and group by channel "key" + function filterPredicate(permissionType, tokenCriteriaMet, isPrivate, channelsListModel) { + return permissionType === channelPermsSubPanel.permissionType && + (!isPrivate || (tokenCriteriaMet && isPrivate)) && + ModelUtils.contains(channelsListModel, "key", channelPermsPanel.channelKey) // filter and group by channel "key" } - filters: ExpressionFilter { - expression: channelPermissionsModel.filterPredicate(model) + filters: FastExpressionFilter { + expression: channelPermissionsModel.filterPredicate(model.permissionType, model.tokenCriteriaMet, + model.isPrivate, model.channelsListModel) + expectedRoles: ["permissionType", "tokenCriteriaMet", "isPrivate", "channelsListModel"] } } delegate: ColumnLayout {