Skip to content

Commit

Permalink
fix: additional logging when blocking apps
Browse files Browse the repository at this point in the history
  • Loading branch information
iloveitaly committed Dec 24, 2023
1 parent 0adcbbe commit 3465711
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: Build & Release

on:
# allow manual runs for debugging purposes
workflow_dispatch: {}

push:
branches:
- main
Expand Down
12 changes: 8 additions & 4 deletions Sources/hyper-focus/action_handler.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ enum ActionHandler {
return url?.host
}

static func hideApp() {
// TODO: sometimes this hide method does not work
NSWorkspace.shared.frontmostApplication!.hide()
}

static func appAction(_ data: SwitchingActivity) -> Bool {
let allowApps = data.configuration.allow_apps
let hasAllowApps = allowApps != nil
Expand All @@ -30,16 +35,15 @@ enum ActionHandler {
return false
} else {
log("app is not in allow_apps, blocking")
// TODO: sometimes this hide method does not work
NSWorkspace.shared.frontmostApplication!.hide()
debug("allow_apps: \(allowApps!)")
hideApp()
return true
}
}

if match(data.app, data.configuration.block_apps ?? []) {
log("app is in block_apps, hiding application to prevent usage")
// TODO: sometimes this hide method does not work
NSWorkspace.shared.frontmostApplication!.hide()
hideApp()
return true
}

Expand Down
9 changes: 1 addition & 8 deletions Sources/hyper-focus/schedule_manager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,7 @@ class ScheduleManager {
var overrideSchedule: Configuration.ScheduleItem?
var plannedSchedule: Configuration.ScheduleItem?

let BLANK_SCHEDULE = Configuration.ScheduleItem(
block_hosts: [],
block_urls: [],
block_apps: [],
allow_hosts: [],
allow_urls: [],
allow_apps: []
)
let BLANK_SCHEDULE = Configuration.ScheduleItem()

init(_ config: Configuration? = nil) {
configuration = config ?? ConfigurationLoader.loadConfiguration()
Expand Down

0 comments on commit 3465711

Please sign in to comment.