2626#import " KBDebugViews.h"
2727#import " KBAppProgressView.h"
2828#import " KBSecretPromptView.h"
29- #import " KBStatusView .h"
29+ #import " KBInstallStatusView .h"
3030#import " KBAppDebug.h"
3131#import " KBNotifications.h"
32- #import " KBErrorStatusView.h"
32+ #import " KBStatusView.h"
33+ #import " KBTask.h"
34+ #import " KBWorkspace.h"
3335
3436typedef NS_ENUM (NSInteger , KBAppViewMode) {
3537 KBAppViewModeInProgress = 1 ,
36- KBAppViewModeError ,
38+ KBAppViewModeStatus ,
3739 KBAppViewModeInstaller,
3840 KBAppViewModeLogin,
3941 KBAppViewModeSignup,
@@ -46,7 +48,6 @@ @interface KBAppView () <KBAppToolbarDelegate, KBComponent, KBSignupViewDelegate
4648@property (readonly ) YOView *contentView;
4749
4850@property KBAppProgressView *appProgressView;
49- @property KBErrorStatusView *errorView;
5051
5152@property KBUsersAppView *usersAppView;
5253@property KBDevicesAppView *devicesAppView;
@@ -65,7 +66,6 @@ @interface KBAppView () <KBAppToolbarDelegate, KBComponent, KBSignupViewDelegate
6566@property KBEnvironment *environment;
6667@property KBRConfig *userConfig;
6768@property KBRGetCurrentStatusRes *userStatus;
68-
6969@end
7070
7171#define TITLE_HEIGHT (32 )
@@ -111,28 +111,14 @@ - (void)openWithEnvironment:(KBEnvironment *)environment completion:(KBCompletio
111111 NSDictionary *info = [[NSBundle mainBundle ] infoDictionary ];
112112 DDLogInfo (@" Keybase.app Version: %@ " , info[@" CFBundleShortVersionString" ]);
113113
114- [self checkInstall : completion];
114+ [self install : completion];
115115}
116116
117- - (void )checkInstall : (KBCompletion)completion {
117+ - (void )install : (KBCompletion)completion {
118118 [self showInProgress: @" Loading" ];
119119 KBInstaller *installer = [[KBInstaller alloc ] init ];
120- [installer installStatusWithEnvironment: _environment completion: ^(BOOL needsInstall, BOOL brewConflict) {
121- if (brewConflict) {
122- [self showBrewWarning: ^{
123- [self checkInstall: completion];
124- }];
125- return ;
126- }
127-
128- [self showStatusView: self .environment completion: completion];
129- /*
130- if (needsInstall) {
131- [self showStatusView:environment completion:completion];
132- } else {
133- [self connect:completion];
134- }
135- */
120+ [installer installWithEnvironment: _environment force: NO completion: ^() {
121+ [self showInstallStatusView: completion];
136122 }];
137123}
138124
@@ -229,32 +215,40 @@ - (void)showInProgress:(NSString *)title {
229215}
230216
231217- (void )showErrorView : (NSString *)title error : (NSError *)error {
232- if (_errorView || self.mode != KBAppViewModeError) {
233- _errorView = [[KBErrorStatusView alloc ] init ];
234- KBNavigationView *navigation = [[KBNavigationView alloc ] initWithView: _errorView title: _title];
235- [self setContentView: navigation mode: KBAppViewModeError];
236- }
218+ KBStatusView *errorView = [[KBStatusView alloc ] init ];
219+ KBNavigationView *navigation = [[KBNavigationView alloc ] initWithView: errorView title: _title];
220+ [self setContentView: navigation mode: KBAppViewModeStatus];
237221 GHWeakSelf gself = self;
238- [_errorView setError: error title: title retry: ^{
222+ [errorView setError: error title: title retry: ^{
239223 [gself showConnect: ^(NSError *error) {}];
240224 } close: ^{
241- [KBApp.app quitWithPrompt: NO sender: gself.errorView ];
225+ [KBApp.app quitWithPrompt: NO sender: self ];
242226 }];
243227}
244228
245229- (void )showBrewWarning : (dispatch_block_t )retry {
246- KBErrorStatusView *view = [[KBErrorStatusView alloc ] init ];
230+ KBStatusView *view = [[KBStatusView alloc ] init ];
247231 view.insets = UIEdgeInsetsMake (100 , 100 , 100 , 100 );
248232 [view setText: @" We've detected that you already have Keybase installed via Homebrew." description: @" We recommend that you uninstall the Homebrew installation since running both at the same time can causes issues." title: @" Homebrew Install Found" retry: retry close: ^{
249233 [KBApp.app quitWithPrompt: NO sender: self ];
250234 }];
251235 KBNavigationView *navigation = [[KBNavigationView alloc ] initWithView: view title: _title];
252- [self setContentView: navigation mode: KBAppViewModeError ];
236+ [self setContentView: navigation mode: KBAppViewModeStatus ];
253237}
254238
255- - (void )showStatusView : (KBEnvironment *) environment completion : (KBCompletion) completion {
239+ - (void )showWelcome {
256240 KBStatusView *view = [[KBStatusView alloc ] init ];
257- [view setEnvironment: environment];
241+ view.insets = UIEdgeInsetsMake (100 , 100 , 100 , 100 );
242+ [view setText: @" Thanks for installing Keybase." description: @" Cliche echo park synth, shoreditch crucifix church-key hoodie. Banh mi kitsch portland pitchfork iPhone mlkshk keffiyeh bitters stumptown polaroid listicle. Chambray ethical brunch, dreamcatcher lomo single-origin coffee yuccie irony beard. Microdosing knausgaard raw denim ethical fashion axe. Waistcoat cornhole brooklyn, truffaut bushwick meh keffiyeh. Blog schlitz next level banh mi, umami hella ugh tote bag paleo cliche lo-fi 8-bit ennui kinfolk. Shabby chic fap fixie keytar." title: @" Welcome to Keybase" retry: nil close: ^{
243+ [self .window close ];
244+ }];
245+ KBNavigationView *navigation = [[KBNavigationView alloc ] initWithView: view title: _title];
246+ [self setContentView: navigation mode: KBAppViewModeStatus];
247+ }
248+
249+ - (void )showInstallStatusView : (KBCompletion)completion {
250+ KBInstallStatusView *view = [[KBInstallStatusView alloc ] init ];
251+ [view setEnvironment: self .environment];
258252 view.completion = ^() {
259253 [self showConnect: completion];
260254 };
@@ -381,6 +375,10 @@ - (void)setUserStatus:(KBRGetCurrentStatusRes *)userStatus userConfig:(KBRConfig
381375 // Don't change if we are in the installer
382376 if (_mode == KBAppViewModeInstaller) return ;
383377
378+ [self showWelcome ];
379+ return ;
380+
381+ /*
384382 if (userStatus.loggedIn && userStatus.user) {
385383 // Show profile if logging in or we are already showing profile, refresh it
386384 if (_mode != KBAppViewModeMain || _toolbar.selectedItem == KBAppViewItemProfile) {
@@ -389,6 +387,7 @@ - (void)setUserStatus:(KBRGetCurrentStatusRes *)userStatus userConfig:(KBRConfig
389387 } else if (_mode != KBAppViewModeLogin || _mode != KBAppViewModeSignup) {
390388 [self showLogin];
391389 }
390+ */
392391}
393392
394393- (void )signupViewDidSignup : (KBSignupView *)signupView {
@@ -462,24 +461,6 @@ - (void)appToolbar:(KBAppToolbar *)appToolbar didSelectItem:(KBAppViewItem)item
462461 }
463462}
464463
465- - (KBWindow *)createWindow {
466- NSAssert (!self.superview, @" Already has superview" );
467- KBWindow *window = [KBWindow windowWithContentView: self size: CGSizeMake (800 , 600 ) retain: YES ];
468- window.minSize = CGSizeMake (600 , 600 );
469- // window.restorable = YES;
470- // window.maxSize = CGSizeMake(600, 900);
471- window.delegate = self; // Overrides default delegate
472- window.titleVisibility = NO ;
473- window.styleMask = NSClosableWindowMask | NSFullSizeContentViewWindowMask | NSTitledWindowMask | NSResizableWindowMask | NSMiniaturizableWindowMask ;
474-
475- window.backgroundColor = KBAppearance.currentAppearance .secondaryBackgroundColor ;
476- window.restorable = YES ;
477- // window.restorationClass = self.class;
478- // window.navigation.titleView = [KBTitleView titleViewWithTitle:@"Keybase" navigation:window.navigation];
479- // [window setLevel:NSStatusWindowLevel];
480- return window;
481- }
482-
483464- (NSRect )window : (NSWindow *)window willPositionSheet : (NSWindow *)sheet usingRect : (NSRect )rect {
484465 CGFloat sheetPosition = 0 ;
485466 if (_mode == KBAppViewModeMain) sheetPosition = 74 ;
@@ -488,17 +469,22 @@ - (NSRect)window:(NSWindow *)window willPositionSheet:(NSWindow *)sheet usingRec
488469 return rect;
489470}
490471
472+ /*
491473- (BOOL)windowShouldClose:(id)sender {
492474 [KBApp.app quitWithPrompt:YES sender:self];
493475 return NO;
494476}
477+ */
495478
496- - (KBWindow *)openWindow {
497- NSAssert (!self.window, @" Already has window" );
498- KBWindow *window = [self createWindow ];
499- [window center ];
500- [window makeKeyAndOrderFront: nil ];
501- return window;
479+ - (void )openWindow {
480+ if (self.window ) {
481+ [NSApplication .sharedApplication activateIgnoringOtherApps: YES ];
482+ [self .window orderFrontRegardless ];
483+ } else {
484+ NSWindow *window = [KBWorkspace createMainWindow: self ];
485+ [window center ];
486+ [window makeKeyAndOrderFront: nil ];
487+ }
502488}
503489
504490// - (void)encodeRestorableStateWithCoder:(NSCoder *)coder { }
0 commit comments