From af8fff6073f2f499e49719d118b1a1740687f881 Mon Sep 17 00:00:00 2001 From: Shelley Vohr Date: Thu, 14 Mar 2024 10:21:48 +0100 Subject: [PATCH] fix: default calendar accessLevel --- index.js | 8 ++++---- permissions.mm | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index a86c525..19b5773 100644 --- a/index.js +++ b/index.js @@ -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) { diff --git a/permissions.mm b/permissions.mm index 080f579..81ee09e 100644 --- a/permissions.mm +++ b/permissions.mm @@ -511,7 +511,7 @@ bool HasOpenSystemPreferencesDialog() { __block Napi::ThreadSafeFunction tsfn = ts_fn; if (@available(macOS 14.0, *)) { - const std::string type = info[0].As().Utf8Value(); + const std::string access_level = info[0].As().Utf8Value(); EKEventStoreRequestAccessCompletionHandler handler = ^(BOOL granted, NSError *error) { @@ -523,7 +523,7 @@ bool HasOpenSystemPreferencesDialog() { tsfn.Release(); }; - if (type == "full") { + if (access_level == "full") { [[EKEventStore new] requestFullAccessToEventsWithCompletion:handler]; } else { [[EKEventStore new] requestWriteOnlyAccessToEventsWithCompletion:handler];