From 9db10e23fc2164e76ea55811a441b1678102cdf8 Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Tue, 11 May 2021 21:28:54 +0100 Subject: [PATCH] fix contact subscriptions table which broke after recent redesign --- .../com/muwire/gui/MainFrameController.groovy | 2 +- .../views/com/muwire/gui/MainFrameView.groovy | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy index e7711ea7..65105897 100644 --- a/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy +++ b/gui/griffon-app/controllers/com/muwire/gui/MainFrameController.groovy @@ -339,7 +339,7 @@ class MainFrameController { } private RemoteTrustList getSelectedTrustList() { - int row = view.getSelectedTrustTablesRow("subscription-table") + int row = view.getSelectedContactSubscriptionTableRow() if (row < 0) return null model.subscriptions[row] diff --git a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy index 9c634327..76a34a9b 100644 --- a/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy +++ b/gui/griffon-app/views/com/muwire/gui/MainFrameView.groovy @@ -82,6 +82,7 @@ class MainFrameView { def lastUploadsSortEvent def lastSharedSortEvent def lastContactsSortEvent + def lastContactsSubscriptionSortEvent def expansionListener = new TreeExpansions() def lastFeedsSortEvent def lastFeedItemsSortEvent @@ -1109,12 +1110,12 @@ class MainFrameView { // subscription table def subscriptionTable = builder.getVariable("subscription-table") subscriptionTable.setDefaultRenderer(Integer.class, centerRenderer) - subscriptionTable.rowSorter.addRowSorterListener({ evt -> trustTablesSortEvents["subscription-table"] = evt }) + subscriptionTable.rowSorter.addRowSorterListener({ evt -> lastContactsSubscriptionSortEvent = evt }) subscriptionTable.rowSorter.setSortsOnUpdates(true) selectionModel = subscriptionTable.getSelectionModel() selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION) selectionModel.addListSelectionListener({ - int selectedRow = getSelectedTrustTablesRow("subscription-table") + int selectedRow = getSelectedContactSubscriptionTableRow() if (selectedRow < 0) { model.reviewButtonEnabled = false model.updateButtonEnabled = false @@ -1766,6 +1767,17 @@ class MainFrameView { selectedRow } + int getSelectedContactSubscriptionTableRow() { + def table = builder.getVariable("subscription-table") + int selectedRow = table.getSelectedRow() + if (selectedRow < 0) + return -1 + if (lastContactsSubscriptionSortEvent != null) + selectedRow = table.rowSorter.convertRowIndexToModel(selectedRow) + selectedRow + } + + public void refreshSharedFiles() { def tree = builder.getVariable("shared-files-tree") TreePath[] selectedPaths = tree.getSelectionPaths()