Skip to content

Commit 1ba4af6

Browse files
committed
Use typed JSObject arrays in Capacitor notification patch
- Replace manual compactMap parsing with `getArray(..., JSObject.self) ?? []` - Keep notification and type extraction aligned with the newer Capacitor API
1 parent c99576c commit 1ba4af6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

scripts/patch-capacitor-local-notifications.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const REPLACEMENTS: ReadonlyArray<[string, string]> = [
2424
' call.reject("Must provide notifications array as notifications option")\n',
2525
" return\n",
2626
" }\n",
27-
' let notifications = call.getArray("notifications", []).compactMap({ $0 as? JSObject })\n',
27+
' let notifications = call.getArray("notifications", JSObject.self) ?? []\n',
2828
].join(""),
2929
],
3030
[
@@ -39,7 +39,7 @@ const REPLACEMENTS: ReadonlyArray<[string, string]> = [
3939
' call.reject("Must supply notifications to cancel")\n',
4040
" return\n",
4141
" }\n",
42-
' let notifications = call.getArray("notifications", []).compactMap({ $0 as? JSObject })\n',
42+
' let notifications = call.getArray("notifications", JSObject.self) ?? []\n',
4343
" guard notifications.count > 0 else {\n",
4444
' call.reject("Must supply notifications to cancel")\n',
4545
" return\n",
@@ -58,7 +58,7 @@ const REPLACEMENTS: ReadonlyArray<[string, string]> = [
5858
' call.reject("Must supply notifications to remove")\n',
5959
" return\n",
6060
" }\n",
61-
' let notifications = call.getArray("notifications", []).compactMap({ $0 as? JSObject })\n',
61+
' let notifications = call.getArray("notifications", JSObject.self) ?? []\n',
6262
" guard notifications.count > 0 else {\n",
6363
' call.reject("Must supply notifications to remove")\n',
6464
" return\n",
@@ -75,7 +75,7 @@ const REPLACEMENTS: ReadonlyArray<[string, string]> = [
7575
' guard call.getValue("types") != nil else {\n',
7676
" return\n",
7777
" }\n",
78-
' let types = call.getArray("types", []).compactMap({ $0 as? JSObject })\n',
78+
' let types = call.getArray("types", JSObject.self) ?? []\n',
7979
].join(""),
8080
],
8181
[

0 commit comments

Comments
 (0)