From 240e9c480e59583769cd99cdcd4c02f82ffdeb63 Mon Sep 17 00:00:00 2001 From: Chen-I Lim Date: Mon, 8 Mar 2021 18:38:50 -0800 Subject: [PATCH] Fix #67: Load homepage on new Mac window --- mac/Focalboard/AppDelegate.swift | 5 +++++ mac/Focalboard/ViewController.swift | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/mac/Focalboard/AppDelegate.swift b/mac/Focalboard/AppDelegate.swift index 041a8f199..6b9b0eff2 100644 --- a/mac/Focalboard/AppDelegate.swift +++ b/mac/Focalboard/AppDelegate.swift @@ -8,6 +8,11 @@ class AppDelegate: NSObject, NSApplicationDelegate { static let serverStartedNotification = NSNotification.Name("serverStarted") private var serverProcess: Process? + + var isServerStarted: Bool { + get { return serverProcess != nil } + } + var serverPort = 8088 var sessionToken: String = "" diff --git a/mac/Focalboard/ViewController.swift b/mac/Focalboard/ViewController.swift index 0618c5e4e..0faf215ac 100644 --- a/mac/Focalboard/ViewController.swift +++ b/mac/Focalboard/ViewController.swift @@ -21,6 +21,13 @@ class ViewController: clearWebViewCache() + // Load the home page if the server was started, otherwise wait until it has + let appDelegate = NSApplication.shared.delegate as! AppDelegate + if (appDelegate.isServerStarted) { + self.updateSessionToken() + self.loadHomepage() + } + // Do any additional setup after loading the view. NotificationCenter.default.addObserver(self, selector: #selector(onServerStarted), name: AppDelegate.serverStartedNotification, object: nil) }