1
0
mirror of https://github.com/mattermost/focalboard.git synced 2025-01-02 14:47:55 +02:00

Fix MM-35819 for Mac

This commit is contained in:
Chen-I Lim 2021-05-24 15:59:21 -07:00
parent 3af92afadd
commit 4b3de6552b

View File

@ -107,8 +107,14 @@ class ViewController:
private func updateSessionTokenAndUserSettings() { private func updateSessionTokenAndUserSettings() {
let appDelegate = NSApplication.shared.delegate as! AppDelegate let appDelegate = NSApplication.shared.delegate as! AppDelegate
let url = URL(string: "http://localhost:\(appDelegate.serverPort)/")!
let sessionScript = """
if (window.location.href.toLowerCase().startsWith('\(url)'.toLowerCase())) {
localStorage.setItem('focalboardSessionId', '\(appDelegate.sessionToken)');
}
"""
let sessionTokenScript = WKUserScript( let sessionTokenScript = WKUserScript(
source: "localStorage.setItem('focalboardSessionId', '\(appDelegate.sessionToken)');", source: sessionScript,
injectionTime: .atDocumentStart, injectionTime: .atDocumentStart,
forMainFrameOnly: true forMainFrameOnly: true
) )
@ -126,8 +132,7 @@ class ViewController:
private func loadHomepage() { private func loadHomepage() {
NSLog("loadHomepage") NSLog("loadHomepage")
let appDelegate = NSApplication.shared.delegate as! AppDelegate let appDelegate = NSApplication.shared.delegate as! AppDelegate
let port = appDelegate.serverPort let url = URL(string: "http://localhost:\(appDelegate.serverPort)/")!
let url = URL(string: "http://localhost:\(port)/")!
let request = URLRequest(url: url) let request = URLRequest(url: url)
refreshWebViewOnLoad = true refreshWebViewOnLoad = true
webView.load(request) webView.load(request)