Commit e5d1e498 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Nate Graham
Browse files

flatpak: Show a more aggressive message when beta is older than stable

In the faulty case where the Beta/Nightly is older than stable,
encourage the user to use the right version of the app.
parent 8477234b
Pipeline #210313 passed with stage
in 1 minute and 58 seconds
......@@ -15,6 +15,7 @@
#include <AppStreamQt/icon.h>
#include <AppStreamQt/screenshot.h>
#include <AppStreamQt/utils.h>
#include <appstream/AppStreamUtils.h>
#include <KConfigGroup>
......@@ -871,3 +872,9 @@ void FlatpakResource::clearUserData()
QDir(dataLocation()).removeRecursively();
Q_EMIT hasDataButUninstalledChanged();
}
bool FlatpakResource::isOlderThan(FlatpakResource *resource) const
{
const QString other = resource->availableVersion();
return AppStream::Utils::vercmpSimple(installedVersion(), other) < 0;
}
......@@ -192,6 +192,7 @@ public:
}
Q_INVOKABLE void clearUserData();
Q_INVOKABLE bool isOlderThan(FlatpakResource *resource) const;
Q_SIGNALS:
void hasDataButUninstalledChanged();
......
......@@ -17,9 +17,12 @@ Kirigami.InlineMessage
// resource is set by the creator of the element in ApplicationPage.
//required property AbstractResource resource
Layout.fillWidth: true
text: i18n("There is a stable version of %1", resource.name)
text: betaOlderThanStable ? i18nc("@label %1 is the name of an application", "This development version of %1 is outdated. Using the stable version is highly recommended.", resource.name) : i18nc("@label %1 is the name of an application", "A more stable version of %1 is available.", resource.name)
height: visible ? implicitHeight : 0
visible: actionsArray.filter(action => action.visible).length > 0
type: betaOlderThanStable ? Kirigami.MessageType.Warning : Kirigami.MessageType.Information
property bool betaOlderThanStable: false
Instantiator {
id: inst
......@@ -35,6 +38,11 @@ Kirigami.InlineMessage
applicationWindow().pageStack.pop();
Navigation.openApplication(model.application)
}
Component.onCompleted: {
if (visible) {
betaOlderThanStable |= resource.isOlderThan(model.application)
}
}
}
onObjectAdded: {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment