Skip to content

Commit

Permalink
fix qr visibility (#57)
Browse files Browse the repository at this point in the history
fix qr visibility
  • Loading branch information
mrerro authored May 2, 2023
1 parent 31abcf6 commit ab88df9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion PrinterApp/PrinterApp.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>WinExe</OutputType>
Expand Down
16 changes: 8 additions & 8 deletions PrinterApp/PrinterModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ public async void PrintAsync(bool printDialog)
}

PrinterViewModel.DownloadNotInProgress = false;
PrinterViewModel.PrintQrVisibility = Visibility.Collapsed;
if (PrinterViewModel.CodeTextBoxText.ToUpper() == "IDDQD")
{
var saveFilePath = _configFile.TempSavePath + Path.DirectorySeparatorChar +
"iddqd.pdf";
saveFilePath =
saveFilePath.Replace(Path.DirectorySeparatorChar.ToString(), "/");
PrinterViewModel.PrintQrVisibility = Visibility.Collapsed;
ShowComplement();
await using var s =
await _httpClient.GetStreamAsync(
Expand All @@ -133,14 +133,13 @@ await _httpClient.GetStreamAsync(
PrinterViewModel.DownloadNotInProgress = true;
Log.Information(
$"{GetType().Name} {MethodBase.GetCurrentMethod()?.Name}: Easter");

PrintAsyncCompleteEvent?.Invoke();
return;
}

Log.Debug(
$"{GetType().Name} {MethodBase.GetCurrentMethod()?.Name}: Start response code {PrinterViewModel.CodeTextBoxText}");
var patchFrom = $"{FileUrl}/{PrinterViewModel.CodeTextBoxText}";
PrinterViewModel.DownloadNotInProgress = false;
try
{
var response =
Expand Down Expand Up @@ -198,7 +197,6 @@ await _httpClient.GetStreamAsync(
PrinterViewModel.ErrorTextBlockVisibility = Visibility.Visible;
PrinterViewModel.ErrorTextBlockText = HttpError;
}

PrinterViewModel.DownloadNotInProgress = true;
Log.Debug(
$"{GetType().Name} {MethodBase.GetCurrentMethod()?.Name}: End response code {PrinterViewModel.CodeTextBoxText}");
Expand All @@ -219,7 +217,6 @@ private async Task Download(FileWithOptions fileWithOptions, string patchFrom,
var name = Guid.NewGuid() + ".pdf";
var saveFilePath = _configFile.TempSavePath + Path.DirectorySeparatorChar + name;
saveFilePath = saveFilePath.Replace(Path.DirectorySeparatorChar.ToString(), "/");
PrinterViewModel.PrintQrVisibility = Visibility.Collapsed;
ShowComplement();
await using var s =
await _httpClient.GetStreamAsync($"{StaticUrl}/{fileWithOptions.Filename}");
Expand Down Expand Up @@ -296,7 +293,8 @@ private void ShowComplement()
PrinterViewModel.Compliment = Compliments.GetRandomCompliment();
await Task.Delay(5000);
PrinterViewModel.Compliment = "";
PrinterViewModel.PrintQrVisibility = Visibility.Visible;
if(PrinterViewModel.DownloadNotInProgress)
PrinterViewModel.PrintQrVisibility = Visibility.Visible;
}).Start();
}

Expand Down Expand Up @@ -382,9 +380,10 @@ private async Task ParseResponseFromSocket(WebsocketReceiveOptions? websocketRec
}

PrinterViewModel.PrintQr = null!;
PrinterViewModel.DownloadNotInProgress = false;
if (websocketReceiveOptions.Files != null!)
{
PrinterViewModel.DownloadNotInProgress = false;
PrinterViewModel.PrintQrVisibility = Visibility.Collapsed;
DeleteOldFiles();
foreach (var fileWithOptions in websocketReceiveOptions.Files)
{
Expand Down Expand Up @@ -416,9 +415,10 @@ private async Task ParseResponseFromSocket(WebsocketReceiveOptions? websocketRec
PrinterViewModel.ErrorTextBlockText = HttpError;
}
}

PrinterViewModel.DownloadNotInProgress = true;
}

PrinterViewModel.DownloadNotInProgress = true;
GenerateQr(websocketReceiveOptions.QrToken);
}

Expand Down

0 comments on commit ab88df9

Please sign in to comment.