Skip to content

Commit

Permalink
no need to request update again: if there is no update - skip
Browse files Browse the repository at this point in the history
  • Loading branch information
Eism committed Feb 18, 2025
1 parent 289c418 commit f3d36dd
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@

using namespace muse::update;

void MuseSoundsCheckUpdateScenarioStub::checkForUpdate()
bool MuseSoundsCheckUpdateScenarioStub::hasUpdate() const
{
return false;
}

void MuseSoundsCheckUpdateScenarioStub::showUpdate()
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ namespace muse::update {
class MuseSoundsCheckUpdateScenarioStub : public IMuseSoundsCheckUpdateScenario
{
public:
void checkForUpdate() override;
bool hasUpdate() const override;
void showUpdate() override;
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/framework/update/imusesoundscheckupdatescenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class IMuseSoundsCheckUpdateScenario : MODULE_EXPORT_INTERFACE
public:
virtual ~IMuseSoundsCheckUpdateScenario() = default;

virtual void checkForUpdate() = 0;
virtual bool hasUpdate() const = 0;
virtual void showUpdate() = 0;
};
}

Expand Down
26 changes: 15 additions & 11 deletions src/framework/update/internal/musesoundscheckupdatescenario.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,29 +48,33 @@ void MuseSoundsCheckUpdateScenario::delayedInit()
}
}

void MuseSoundsCheckUpdateScenario::checkForUpdate()
bool MuseSoundsCheckUpdateScenario::hasUpdate() const
{
if (isCheckStarted() || !service()->needCheckForUpdate()) {
return;
return false;
}

RetVal<ReleaseInfo> lastCheckResult = service()->lastCheckResult();
if (lastCheckResult.ret) {
//! NOTE: recheck if we already shown the info
if (shouldIgnoreUpdate(lastCheckResult.val)) {
return;
}

showReleaseInfo(lastCheckResult.val);
return;
if (!lastCheckResult.ret) {
return false;
}

bool noUpdate = lastCheckResult.ret.code() == static_cast<int>(Err::NoUpdate);
if (noUpdate) {
return false;
}

return !shouldIgnoreUpdate(lastCheckResult.val);
}

void MuseSoundsCheckUpdateScenario::showUpdate()
{
RetVal<ReleaseInfo> lastCheckResult = service()->lastCheckResult();
if (!lastCheckResult.ret) {
return;
}

doCheckForUpdate(true);
showReleaseInfo(lastCheckResult.val);
}

bool MuseSoundsCheckUpdateScenario::isCheckStarted() const
Expand Down
4 changes: 2 additions & 2 deletions src/framework/update/internal/musesoundscheckupdatescenario.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
#include "../iupdateconfiguration.h"
#include "../imusesoundscheckupdateservice.h"

#include "../iappupdateservice.h"
#include "../imusesoundscheckupdatescenario.h"

namespace muse::update {
Expand All @@ -51,7 +50,8 @@ class MuseSoundsCheckUpdateScenario : public IMuseSoundsCheckUpdateScenario, pub

void delayedInit();

void checkForUpdate() override;
bool hasUpdate() const override;
void showUpdate() override;

private:
bool isCheckStarted() const;
Expand Down
5 changes: 4 additions & 1 deletion src/project/internal/projectactionscontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,10 @@ Ret ProjectActionsController::doFinishOpenProject()
//! Show Tours & Muse Sounds update if need
auto showToursAndMuseSoundsUpdate = [=](){
QTimer::singleShot(1000, [this]() {
museSoundsCheckUpdateScenario()->checkForUpdate();
if (museSoundsCheckUpdateScenario()->hasUpdate()) {
museSoundsCheckUpdateScenario()->showUpdate();
}

toursService()->onEvent(u"project_opened");
});
};
Expand Down

0 comments on commit f3d36dd

Please sign in to comment.