- Notifications
You must be signed in to change notification settings - Fork3
chore: check server version on sign-in and launch#43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
cb3a049
da0ff72
90e85fb
1089677
df23617
27acd32
77916ed
9bedf2b
585418c
6f742dc
709eff9
f0cca56
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Coder.Desktop.App.Models; | ||
using Coder.Desktop.App.Services; | ||
using Coder.Desktop.App.ViewModels; | ||
using Coder.Desktop.App.Views; | ||
@@ -26,6 +28,7 @@ public App() | ||
services.AddTransient<SignInWindow>(); | ||
// TrayWindow views and view models | ||
services.AddTransient<TrayWindowLoadingPage>(); | ||
services.AddTransient<TrayWindowDisconnectedViewModel>(); | ||
services.AddTransient<TrayWindowDisconnectedPage>(); | ||
services.AddTransient<TrayWindowLoginRequiredViewModel>(); | ||
@@ -45,17 +48,29 @@ public async Task ExitApplication() | ||
{ | ||
_handleWindowClosed = false; | ||
Exit(); | ||
varrpcController = _services.GetRequiredService<IRpcController>(); | ||
// TODO: send a StopRequest if we're connected??? | ||
awaitrpcController.DisposeAsync(); | ||
Environment.Exit(0); | ||
} | ||
protected override void OnLaunched(LaunchActivatedEventArgs args) | ||
{ | ||
// Start connecting to the manager in the background. | ||
var rpcController = _services.GetRequiredService<IRpcController>(); | ||
if (rpcController.GetState().RpcLifecycle == RpcLifecycle.Disconnected) | ||
// Passing in a CT with no cancellation is desired here, because | ||
// the named pipe open will block until the pipe comes up. | ||
_ = rpcController.Reconnect(CancellationToken.None); | ||
// Load the credentials in the background. Even though we pass a CT | ||
// with no cancellation, the method itself will impose a timeout on the | ||
// HTTP portion. | ||
var credentialManager = _services.GetRequiredService<ICredentialManager>(); | ||
_ = credentialManager.LoadCredentials(CancellationToken.None); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Just to check my understanding here, because we are not I ask because we want the rest of this function to still run and handle closing of the tray window. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. Yep, we run it in the background and ignore all errors. If the credentials fail to load, the state will transition to "invalid" which will show the "please sign in" screen. | ||
// Prevent the TrayWindow from closing, just hide it. | ||
var trayWindow = _services.GetRequiredService<TrayWindow>(); | ||
trayWindow.Closed += (sender, args) => | ||
{ | ||
if (!_handleWindowClosed) return; | ||
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.