Skip to content

Commit

Permalink
Filter out null browser
Browse files Browse the repository at this point in the history
  • Loading branch information
johnste committed Aug 18, 2019
1 parent f8f25b6 commit 632689d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
9 changes: 3 additions & 6 deletions Finicky/Finicky/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
if let browser = appDescriptor.browsers.first {
description += "Browser:\n"
description += " \(browser.name) \(browser.openInBackground ?? false ? "(opens in background)" : "")\n"
} else {}
}
} else if appDescriptor.browsers.count == 0 {
description += "Won't open any browser"
} else {
description += "First active browser of:\n"
for (index, browser) in appDescriptor.browsers.enumerated() {
Expand Down Expand Up @@ -200,11 +202,6 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSUserNotificationCenterDele
logToConsole(description)
showNotification(title: "Unable to find application", informativeText: "Finicky was unable to find the application \"" + appToStart.name + "\"", error: true)
}
} else {
let description = "Finicky did not understand what application to start"
print(description)
logToConsole(description)
showNotification(title: description, informativeText: "Finicky was unable to find the application", error: true)
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions Finicky/Finicky/Config.swift
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,11 @@ open class FinickyConfig {
let appType = AppDescriptorType(rawValue: dict["appType"] as! String)
let openInBackground: Bool? = dict["openInBackground"] as? Bool
let browserName = dict["name"] as! String

if browserName == "" {
return nil
}

do {
let browser = try BrowserOpts(name: browserName, appType: appType!, openInBackground: openInBackground)
return browser
Expand Down
8 changes: 6 additions & 2 deletions config-api/.finicky.example.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ module.exports = {
// Open workplace related sites in work browser
match: [/workplace/],
browser: [{ name: "Google Chrome Canary", openInBackground: true }, "Safari"]

}
},
{
// Open workplace related sites in work browser
match: [/test/],
browser: [null, "Safari"]
},
]
};

0 comments on commit 632689d

Please sign in to comment.