Skip to content

Commit

Permalink
Fix smart trigger from past > scheduled trigger from present.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonesiscoding committed Apr 12, 2023
1 parent a7c595d commit 6c47553
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 26 deletions.
4 changes: 2 additions & 2 deletions dist/Available.app/Contents/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>BuildMachineOSBuild</key>
<string>22E252</string>
<string>22E261</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleDisplayName</key>
Expand All @@ -23,7 +23,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.4.6</string>
<string>1.4.7</string>
<key>CFBundleSupportedPlatforms</key>
<array>
<string>MacOSX</string>
Expand Down
Binary file modified dist/Available.app/Contents/MacOS/Available
Binary file not shown.
Binary file not shown.
Binary file modified dist/Available.app/Contents/Resources/available-cli
Binary file not shown.
Binary file modified dist/Available.app/Contents/Resources/output-cli
Binary file not shown.
12 changes: 6 additions & 6 deletions dist/Available.app/Contents/_CodeSignature/CodeResources
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
</data>
<key>Resources/Base.lproj/Main.storyboardc/MainMenu.nib</key>
<data>
duhx0JUtdOeQ+XkStIgAKCZYVgw=
NB8gl+eVnWQculmbS6znhZJqteE=
</data>
<key>Resources/available-cli</key>
<data>
Cr1BNtjDDl+iEXSihTy337pdLuI=
RyRUvHndZQz4UlDynyZAkN6q7dM=
</data>
<key>Resources/output-cli</key>
<data>
czIT40V7bJPCVgEGKNEd/T10S/8=
AUsAf69OwA6RS7saPvG+S9a9ZuE=
</data>
</dict>
<key>files2</key>
Expand Down Expand Up @@ -56,21 +56,21 @@
<dict>
<key>hash2</key>
<data>
ysCrHXYCmshE7qMMo7QR8+7/hDchoHBZBex4peOleDM=
UbR+ZUQJ8aVVAop/0yUK8DX+HAGDw480Yix/BktCbY4=
</data>
</dict>
<key>Resources/available-cli</key>
<dict>
<key>hash2</key>
<data>
54rajGJtjw4UN2e5PYUBx9p5TCvfJ8uFAiSvob3CU7s=
9dpnpWe8Q7lFhphWglzO3XSjIqxY/z+XjKs3DU4SpHI=
</data>
</dict>
<key>Resources/output-cli</key>
<dict>
<key>hash2</key>
<data>
XmtQcaLbgJCPq4jbnkT/KSGlKWroAOsf9153jjXVacE=
ow2M490m5BP2iXHGXd6Rj0TW2PBymPAI5LKwRsuyAwc=
</data>
</dict>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion dist/Available.pkgproj
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@
<key>USE_HFS+_COMPRESSION</key>
<false/>
<key>VERSION</key>
<string>1.4.6</string>
<string>1.4.7</string>
</dict>
<key>TYPE</key>
<integer>0</integer>
Expand Down
12 changes: 6 additions & 6 deletions src/Available.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.6;
MARKETING_VERSION = 1.4.7;
PRODUCT_BUNDLE_IDENTIFIER = com.deviscoding.available;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -601,7 +601,7 @@
"@executable_path/../Frameworks",
);
MACOSX_DEPLOYMENT_TARGET = 11.0;
MARKETING_VERSION = 1.4.6;
MARKETING_VERSION = 1.4.7;
PRODUCT_BUNDLE_IDENTIFIER = com.deviscoding.available;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -620,7 +620,7 @@
DEVELOPMENT_TEAM = M97V8HVFPX;
INFOPLIST_FILE = "$(SRCROOT)/Available/Trunk/Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.4.6;
MARKETING_VERSION = 1.4.7;
PRODUCT_BUNDLE_IDENTIFIER = "com.deviscoding.output-cli";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -637,7 +637,7 @@
DEVELOPMENT_TEAM = M97V8HVFPX;
INFOPLIST_FILE = "$(SRCROOT)/Available/Trunk/Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.4.6;
MARKETING_VERSION = 1.4.7;
PRODUCT_BUNDLE_IDENTIFIER = "com.deviscoding.output-cli";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -655,7 +655,7 @@
DEVELOPMENT_TEAM = M97V8HVFPX;
INFOPLIST_FILE = "$(SRCROOT)/Available/Trunk/Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.4.6;
MARKETING_VERSION = 1.4.7;
PRODUCT_BUNDLE_IDENTIFIER = "com.deviscoding.available-cli";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -674,7 +674,7 @@
DEVELOPMENT_TEAM = M97V8HVFPX;
INFOPLIST_FILE = "$(SRCROOT)/Available/Trunk/Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.4.6;
MARKETING_VERSION = 1.4.7;
PRODUCT_BUNDLE_IDENTIFIER = "com.deviscoding.available-cli";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
18 changes: 7 additions & 11 deletions src/available-cli/Focus.swift
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class FocusMonterey: FocusBase {
let assertFile = URL(fileURLWithPath: "\(user.userHome.path)/Library/DoNotDisturb/DB/Assertions.json")
let modeConfigFile = URL(fileURLWithPath: "\(user.userHome.path)/Library/DoNotDisturb/DB/ModeConfigurations.json")
let jsonDecoder = JSONDecoder()
var manualStart: Int = 0
var smartStart: Int = 0

if fm.fileExists(atPath: assertFile.path) && fm.fileExists(atPath: modeConfigFile.path) {
let calendar = Calendar.current
Expand All @@ -264,7 +264,7 @@ class FocusMonterey: FocusBase {
// seems like a smart trigger, let's get the time for comparison.
let ms = (record.assertionStartDateTimestamp + 978307200) * 1000
let dt = calendar.dateComponents([.hour, .minute], from: Date(milliseconds: ms))
manualStart = (dt.hour ?? 0) * 60 + (dt.minute ?? 0)
smartStart = (dt.hour ?? 0) * 60 + (dt.minute ?? 0)
} else {
return focus
}
Expand All @@ -281,18 +281,14 @@ class FocusMonterey: FocusBase {
let end = triggers.timePeriodEndTimeHour * 60 + triggers.timePeriodEndTimeMinute
if (start < end) {
if (now >= start && now < end) {
if(manualStart > 0 && manualStart < start) {
if(manualStart > start) {
focus = config.mode.name
}
} else {
focus = config.mode.name
}
if(smartStart == 0 || smartStart < start) {
focus = config.mode.name
}
}
} else if (start > end) {
if (now >= start || now < end) {
if(manualStart > 0) {
if(manualStart >= start || manualStart < end) {
if(smartStart > 0) {
if(smartStart >= start || smartStart < end) {
focus = config.mode.name
}
} else {
Expand Down

0 comments on commit 6c47553

Please sign in to comment.