Skip to content

Commit

Permalink
fix: default calendar accessLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
codebytere committed Mar 14, 2024
1 parent fd7129c commit af8fff6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ function askForFoldersAccess(folder) {
return permissions.askForFoldersAccess.call(this, folder)
}

function askForCalendarAccess(type) {
if (!['write-only', 'full'].includes(type)) {
throw new TypeError(`${type} must be one of either 'write-only' or 'full'`)
function askForCalendarAccess(accessLevel = 'write-only') {
if (!['write-only', 'full'].includes(accessLevel)) {
throw new TypeError(`${accessLevel} must be one of either 'write-only' or 'full'`)
}

return permissions.askForCalendarAccess.call(this, type)
return permissions.askForCalendarAccess.call(this, accessLevel)
}

function askForScreenCaptureAccess(openPreferences = false) {
Expand Down
4 changes: 2 additions & 2 deletions permissions.mm
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ bool HasOpenSystemPreferencesDialog() {

__block Napi::ThreadSafeFunction tsfn = ts_fn;
if (@available(macOS 14.0, *)) {
const std::string type = info[0].As<Napi::String>().Utf8Value();
const std::string access_level = info[0].As<Napi::String>().Utf8Value();

EKEventStoreRequestAccessCompletionHandler handler =
^(BOOL granted, NSError *error) {
Expand All @@ -523,7 +523,7 @@ bool HasOpenSystemPreferencesDialog() {
tsfn.Release();
};

if (type == "full") {
if (access_level == "full") {
[[EKEventStore new] requestFullAccessToEventsWithCompletion:handler];
} else {
[[EKEventStore new] requestWriteOnlyAccessToEventsWithCompletion:handler];
Expand Down

0 comments on commit af8fff6

Please sign in to comment.