Skip to content

Commit

Permalink
Fixed playing popup title not being set when launcher is reopened to …
Browse files Browse the repository at this point in the history
…show a problem
  • Loading branch information
hhyyrylainen committed Dec 8, 2022
1 parent 4d3b461 commit 71821b0
Showing 1 changed file with 38 additions and 24 deletions.
62 changes: 38 additions & 24 deletions ThriveLauncher/ViewModels/MainWindowViewModel.Playing.cs
Original file line number Diff line number Diff line change
Expand Up @@ -765,40 +765,54 @@ private async void DetectPlayingStatusFromBackend()

try
{
if (thriveRunner.ThriveRunning || thriveRunner.PlayMessages.Count > 0 ||
thriveRunner.ThriveOutput.Count > 0)
if (!thriveRunner.ThriveRunning && thriveRunner.PlayMessages.Count <= 0 &&
thriveRunner.ThriveOutput.Count <= 0)
{
logger.LogInformation("Restoring state from backend for Thrive runner");
return;
}

CurrentlyPlaying = true;
logger.LogInformation("Restoring state from backend for Thrive runner");

logger.LogDebug("Restoring play messages from runner");
PlayMessages.Clear();
PlayMessages.AddRange(thriveRunner.PlayMessages.Select(FormatPlayMessage));
CurrentlyPlaying = true;

ThriveOutputFirstPart.Clear();
ThriveOutputFirstPart.AddRange(thriveRunner.ThriveOutput);
// Restore the playing title to not leave it awkwardly blank
if (thriveRunner.PlayedThriveVersion == null)
{
logger.LogWarning(
"Could not detect played version from Thrive runner, play popup title will be blank");
}
else
{
PlayingThrivePopupTitle =
string.Format(Resources.PlayingTitle, thriveRunner.PlayedThriveVersion.VersionName);
}

// Output last part has to be updated by the GUI to make sure it is showing the latest data
logger.LogDebug("Restoring play messages from runner");
PlayMessages.Clear();
PlayMessages.AddRange(thriveRunner.PlayMessages.Select(FormatPlayMessage));

RegisterThriveRunnerListeners();
ThriveOutputFirstPart.Clear();
ThriveOutputFirstPart.AddRange(thriveRunner.ThriveOutput);

if (!thriveRunner.ThriveRunning)
{
CanCancelPlaying = true;
ThriveIsRunning = false;
// Output last part has to be updated by the GUI to make sure it is showing the latest data

// Make sure this is called, which it isn't necessarily due to the default value of ThriveIsRunning
// variable
OnPlayingEnded();
}
else
{
ThriveIsRunning = true;
}
RegisterThriveRunnerListeners();

ThriveOutputIsTruncated = thriveRunner.OutputTruncated;
if (!thriveRunner.ThriveRunning)
{
CanCancelPlaying = true;
ThriveIsRunning = false;

// Make sure this is called, which it isn't necessarily due to the default value of ThriveIsRunning
// variable
OnPlayingEnded();
}
else
{
ThriveIsRunning = true;
}

ThriveOutputIsTruncated = thriveRunner.OutputTruncated;
}
catch (Exception e)
{
Expand Down

0 comments on commit 71821b0

Please sign in to comment.