From e95e878d2a6bb9d3bc0119ddf1675e8efdff2f69 Mon Sep 17 00:00:00 2001 From: Keeyou Date: Wed, 12 Jun 2024 11:09:19 +0800 Subject: [PATCH] mac: handle started event when dismissed --- src/mac/YassViewController.mm | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/mac/YassViewController.mm b/src/mac/YassViewController.mm index 1213e4703..a29fa244a 100644 --- a/src/mac/YassViewController.mm +++ b/src/mac/YassViewController.mm @@ -13,6 +13,7 @@ #include "core/logging.hpp" #include "core/utils.hpp" #include "crypto/crypter_export.hpp" +#include "mac/YassAppDelegate.h" #include "mac/YassWindowController.h" #include "mac/utils.h" @@ -39,11 +40,25 @@ - (void)viewDidLoad { [self.autoStart setState:(CheckLoginItemStatus(nullptr) ? NSControlStateValueOn : NSControlStateValueOff)]; [self.systemProxy setState:(GetSystemProxy() ? NSControlStateValueOn : NSControlStateValueOff)]; [self LoadChanges]; - [self.startButton setEnabled:TRUE]; - [self.stopButton setEnabled:FALSE]; } - (void)viewWillAppear { + // vc might be dismissed in starting/stopping state, refresh the state + YassAppDelegate* appDelegate = (YassAppDelegate*)NSApplication.sharedApplication.delegate; + switch ([appDelegate getState]) { + case STARTED: + [self Started]; + break; + case START_FAILED: + [self StartFailed]; + break; + case STOPPED: + [self Stopped]; + break; + default: + break; + } + [self.view.window center]; }