From 3b493fd5becb8970844f2e7e8cb591b5ce2805ef Mon Sep 17 00:00:00 2001 From: Serg Date: Mon, 28 Jan 2019 10:36:04 +0700 Subject: [PATCH] create applescript on the queue it will run on --- MTMR/AppleScriptTouchBarItem.swift | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/MTMR/AppleScriptTouchBarItem.swift b/MTMR/AppleScriptTouchBarItem.swift index b6526c7..33d89cf 100644 --- a/MTMR/AppleScriptTouchBarItem.swift +++ b/MTMR/AppleScriptTouchBarItem.swift @@ -9,13 +9,19 @@ class AppleScriptTouchBarItem: CustomButtonTouchBarItem { self.interval = interval super.init(identifier: identifier, title: "⏳") forceHideConstraint = view.widthAnchor.constraint(equalToConstant: 0) - guard let script = source.appleScript else { - title = "no script" - return - } - self.script = script - isBordered = false + title = "scheduled" DispatchQueue.appleScriptQueue.async { + guard let script = source.appleScript else { + DispatchQueue.main.async { + self.title = "no script" + } + return + } + self.script = script + DispatchQueue.main.async { + self.isBordered = false + } + var error: NSDictionary? guard script.compileAndReturnError(&error) else { #if DEBUG