Commit aa9e92bc authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧
Browse files

flatpak: Improve behaviour of the beta display

Ensures it updates properly when the view isn't recreated (i.e. the
resource instance changes).
Also doesn't always display itself when the same repo is added twice
which it can happen (e.g. for user and system)
parent b244f552
Pipeline #225574 passed with stage
in 2 minutes and 50 seconds
......@@ -888,10 +888,10 @@ void FlatpakResource::clearUserData()
Q_EMIT hasDataButUninstalledChanged();
}
bool FlatpakResource::isOlderThan(FlatpakResource *resource) const
int FlatpakResource::versionCompare(FlatpakResource *resource) const
{
const QString other = resource->availableVersion();
return AppStream::Utils::vercmpSimple(installedVersion(), other) < 0;
return AppStream::Utils::vercmpSimple(availableVersion(), other);
}
QString FlatpakResource::contentRatingDescription() const
......
......@@ -188,7 +188,7 @@ public:
}
Q_INVOKABLE void clearUserData();
Q_INVOKABLE bool isOlderThan(FlatpakResource *resource) const;
Q_INVOKABLE int versionCompare(FlatpakResource *resource) const;
const AppStream::Component appdata() const
{
......
......@@ -23,6 +23,13 @@ Kirigami.InlineMessage
type: betaOlderThanStable ? Kirigami.MessageType.Warning : Kirigami.MessageType.Information
property bool betaOlderThanStable: false
property var app: resource
onAppChanged: {
betaOlderThanStable = false
for (const action in actionsArray) {
actionsArray[action].reset()
}
}
Instantiator {
id: inst
......@@ -32,16 +39,16 @@ Kirigami.InlineMessage
resourcesUrl: resource.url
}
delegate: Kirigami.Action {
visible: model.application !== resource && model.application.branch !== "beta" && model.application.branch !== "master"
visible: model.application !== resource && model.application.branch !== "beta" && model.application.branch !== "master" && versionCompare !== 0
text: i18nc("@action: button %1 is the name of a Flatpak repo", "View Stable Version on %1", displayOrigin)
onTriggered: {
applicationWindow().pageStack.pop();
Navigation.openApplication(model.application)
}
Component.onCompleted: {
if (visible) {
betaOlderThanStable |= resource.isOlderThan(model.application)
}
readonly property int versionCompare: resource.versionCompare(model.application)
Component.onCompleted: reset()
function reset() {
oldBetaItem.betaOlderThanStable |= versionCompare > 0
}
}
......
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