From 8d322092cfd170fb8ddfeaf9e44ab9e3d9886f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Wed, 12 Apr 2023 12:31:35 +0200 Subject: [PATCH] fix: `packId` is a string in NIM backend fixes the currently selected sticker pack not being highlighted in the popup footer The strict equality operator would no longer yield true here: ``` property int selectedPackId ... selected: stickerPackListView.selectedPackId === packId ``` --- ui/imports/shared/status/StatusStickerList.qml | 4 ++-- .../shared/status/StatusStickerMarket.qml | 12 ++++++------ .../status/StatusStickerPackClickPopup.qml | 6 +++--- .../shared/status/StatusStickersPopup.qml | 17 +++++++---------- 4 files changed, 18 insertions(+), 21 deletions(-) diff --git a/ui/imports/shared/status/StatusStickerList.qml b/ui/imports/shared/status/StatusStickerList.qml index f7935e1969..8215374d90 100644 --- a/ui/imports/shared/status/StatusStickerList.qml +++ b/ui/imports/shared/status/StatusStickerList.qml @@ -11,7 +11,7 @@ import shared.panels 1.0 StatusGridView { id: root - property int packId: -1 + property string packId property var stickerGrid visible: count > 0 anchors.fill: parent @@ -19,7 +19,7 @@ StatusGridView { cellHeight: 88 model: stickerList focus: true - signal stickerClicked(string hash, int packId, string url) + signal stickerClicked(string hash, string packId, string url) delegate: Item { width: root.cellWidth height: root.cellHeight diff --git a/ui/imports/shared/status/StatusStickerMarket.qml b/ui/imports/shared/status/StatusStickerMarket.qml index 0d6a4378c8..c7116668f0 100644 --- a/ui/imports/shared/status/StatusStickerMarket.qml +++ b/ui/imports/shared/status/StatusStickerMarket.qml @@ -21,14 +21,14 @@ Item { property var store property var stickerPacks: StickerPackData {} - property int packId: -1 + property string packId signal backClicked - signal uninstallClicked(int packId) - signal installClicked(var stickers, int packId, int index) - signal cancelClicked(int packId) - signal updateClicked(int packId) - signal buyClicked(int packId) + signal uninstallClicked(string packId) + signal installClicked(var stickers, string packId, int index) + signal cancelClicked(string packId) + signal updateClicked(string packId) + signal buyClicked(string packId) StatusGridView { id: availableStickerPacks diff --git a/ui/imports/shared/status/StatusStickerPackClickPopup.qml b/ui/imports/shared/status/StatusStickerPackClickPopup.qml index 64a4319ffb..c043eb5b14 100644 --- a/ui/imports/shared/status/StatusStickerPackClickPopup.qml +++ b/ui/imports/shared/status/StatusStickerPackClickPopup.qml @@ -18,7 +18,7 @@ import "../../../app/AppLayouts/Chat/stores" ModalPopup { id: stickerPackDetailsPopup - property int packId: -1 + property string packId property var store property string thumbnail: "" @@ -29,7 +29,7 @@ ModalPopup { property bool bought: false; property bool pending: false; property var stickers; - signal buyClicked(int packId) + signal buyClicked(string packId) Component.onCompleted: { const idx = stickersModule.stickerPacks.findIndexById(packId, false); @@ -126,7 +126,7 @@ ModalPopup { isBought: bought isPending: pending greyedOut: store.networkConnectionStore.stickersNetworkAvailable - tooltip.text: root.store.networkConnectionStore.stickersNetworkUnavailableText + tooltip.text: store.networkConnectionStore.stickersNetworkUnavailableText onInstallClicked: { stickersModule.install(packId); stickerPackDetailsPopup.close(); diff --git a/ui/imports/shared/status/StatusStickersPopup.qml b/ui/imports/shared/status/StatusStickersPopup.qml index 063abcab4f..9cfc6100c8 100644 --- a/ui/imports/shared/status/StatusStickersPopup.qml +++ b/ui/imports/shared/status/StatusStickersPopup.qml @@ -66,7 +66,7 @@ Popup { onAboutToShow: { d.getInstalledStickerPacks() - if (stickerGrid.packId == -1) { + if (!stickerGrid.packId) { d.getRecentStickers() } } @@ -197,7 +197,7 @@ Popup { StyledText { id: lblNoRecentStickers - visible: stickerPackListView.selectedPackId === -1 && stickersModule.recent.rowCount() === 0 && !lblNoStickersYet.visible + visible: !stickerPackListView.selectedPackId && stickersModule.recent.rowCount() === 0 && !lblNoStickersYet.visible anchors.fill: parent font.pixelSize: 15 text: qsTr("Recently used stickers will appear here") @@ -275,36 +275,33 @@ Popup { highlighted: true onClicked: { highlighted = true - stickerPackListView.selectedPackId = -1 + stickerPackListView.selectedPackId = "" d.getRecentStickers() stickerGrid.model = d.recentStickers } } StatusScrollView { - height: 40 Layout.fillWidth: true Layout.fillHeight: true ScrollBar.vertical.policy: ScrollBar.AlwaysOff RowLayout { - spacing: Style.current.padding + spacing: footerContent.spacing Repeater { id: stickerPackListView - property int selectedPackId: -1 + property string selectedPackId model: d.stickerPackList visible: d.stickerPacksLoaded delegate: StatusStickerPackIconWithIndicator { id: packIconWithIndicator visible: installed - width: 24 - height: 24 + Layout.preferredWidth: 24 + Layout.preferredHeight: 24 selected: stickerPackListView.selectedPackId === packId source: thumbnail - Layout.preferredHeight: height - Layout.preferredWidth: width onClicked: { btnHistory.highlighted = false stickerPackListView.selectedPackId = packId