Skip to content

Commit

Permalink
Make opening/saving viewer asynchronous
Browse files Browse the repository at this point in the history
  • Loading branch information
chylex committed Dec 31, 2023
1 parent 9904a71 commit 23ddb45
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app/Desktop/Main/Pages/ViewerPageModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ public async void OnClickOpenViewer() {
var fullPath = await PrepareTemporaryViewerFile();
var strategy = new LiveViewerExportStrategy(ServerConfiguration.Port, ServerConfiguration.Token);

await WriteViewerFile(fullPath, strategy);
Process.Start(new ProcessStartInfo(fullPath) { UseShellExecute = true });
await ProgressDialog.ShowIndeterminate(window, "Open Viewer", "Creating viewer...", _ => Task.Run(() => WriteViewerFile(fullPath, strategy)));

Process.Start(new ProcessStartInfo(fullPath) {
UseShellExecute = true
});
} catch (Exception e) {
await Dialog.ShowOk(window, "Open Viewer", "Could not save viewer: " + e.Message);
await Dialog.ShowOk(window, "Open Viewer", "Could not create or save viewer: " + e.Message);
}
}

Expand Down Expand Up @@ -106,9 +109,9 @@ public async void OnClickSaveViewer() {
}

try {
await WriteViewerFile(path, StandaloneViewerExportStrategy.Instance);
await ProgressDialog.ShowIndeterminate(window, "Save Viewer", "Creating viewer...", _ => Task.Run(() => WriteViewerFile(path, StandaloneViewerExportStrategy.Instance)));
} catch (Exception e) {
await Dialog.ShowOk(window, "Save Viewer", "Could not save viewer: " + e.Message);
await Dialog.ShowOk(window, "Save Viewer", "Could not create or save viewer: " + e.Message);
}
}

Expand Down

0 comments on commit 23ddb45

Please sign in to comment.