Bug 425242 - "Add flathub" button is useless when flathub repo is already enabled
Summary: "Add flathub" button is useless when flathub repo is already enabled
Status: RESOLVED FIXED
Alias: None
Product: Discover
Classification: Applications
Component: discover (show other bugs)
Version: unspecified
Platform: Neon Linux
: VHI normal
Target Milestone: ---
Assignee: Dan Leinir Turthra Jensen
URL:
Keywords: regression
Depends on:
Blocks:
 
Reported: 2020-08-11 22:55 UTC by Patrick Silva
Modified: 2020-08-13 15:15 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In: 5.20
Sentry Crash Report:


Attachments
screenshot (70.62 KB, image/png)
2020-08-11 22:55 UTC, Patrick Silva
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Silva 2020-08-11 22:55:34 UTC
Created attachment 130806 [details]
screenshot

SUMMARY
As we can see in the attached screenshot, "Add flathub" button is still present and enabled in "Settings" page of Discover even when flathub repo is already enabled. Nothing happens when we click on it. This button should be hidden or greyed out when flathub repo is already enabled.

Operating System: KDE neon Unstable Edition
KDE Plasma Version: 5.19.80
KDE Frameworks Version: 5.74.0
Qt Version: 5.14.2
Comment 1 Nate Graham 2020-08-12 19:28:13 UTC
Can confirm. Don't think it used to be always visible in the past. Maybe something changed.
Comment 2 Nate Graham 2020-08-12 21:58:22 UTC
Something like this outghta fix it:


diff --git libdiscover/backends/FlatpakBackend/FlatpakSourcesBackend.cpp libdiscover/backends/FlatpakBackend/FlatpakSourcesBackend.cpp
index 8e766376..41b4eee6 100644
--- libdiscover/backends/FlatpakBackend/FlatpakSourcesBackend.cpp
+++ libdiscover/backends/FlatpakBackend/FlatpakSourcesBackend.cpp
@@ -230,7 +230,9 @@ bool FlatpakSourcesBackend::removeSource(const QString &id)
 
 QVariantList FlatpakSourcesBackend::actions() const
 {
-    return { QVariant::fromValue<QObject*>(m_flathubAction) };
+    if (/*flathub not already among sources*/) {
+        return { QVariant::fromValue<QObject*>(m_flathubAction) };
+    }
 }
 
 bool FlatpakSourcesBackend::listRepositories(FlatpakInstallation* installation)


Now to figure out how to turn /*flathub not already among sources*/ into real code...
Comment 3 Aleix Pol 2020-08-12 22:04:39 UTC
libdiscover/backends/FlatpakBackend/FlatpakSourcesBackend.cpp:313 sets the action to setVisible(false) when the repository is found.

It's probably a regression in Kirigami, it needs fixing there.
Comment 4 Aleix Pol 2020-08-13 10:51:15 UTC
Git commit 4725f5040207696a83314ee29f316ee02253d3d9 by Aleix Pol.
Committed on 13/08/2020 at 10:50.
Pushed by apol into branch 'master'.

Propagate QAction visibility to QML

M  +1    -0    discover/qml/SourcesPage.qml

https://invent.kde.org/plasma/discover/commit/4725f5040207696a83314ee29f316ee02253d3d9
Comment 5 Nate Graham 2020-08-13 14:44:57 UTC
That commit causes Discover to reproducibly crash for me when visiting the Settings page. Before it crashes, I can see that all of the Flatpak-related actions are hidden, not just the "Add Flathub" one.
Comment 6 Patrick Silva 2020-08-13 14:51:54 UTC
this fix did not land on neon unstable yet and Discover is crashing in Settings page.
reported a few days ago
https://bugs.kde.org/show_bug.cgi?id=425110
Comment 7 Nate Graham 2020-08-13 15:15:43 UTC
Ah, must be something else.