Skip to content

Commit 41217e4

Browse files
NathanWalkerclaude
andcommitted
feat(camera)!: migrate to @nativescript-community/perms v3
perms v3 changed `check()`/`request()` to resolve to a `Status` string instead of the v2 `[Status, boolean]` tuple. Under v3 `mapStatus` matched the first *character* of the status string against the Status keys, so every permission result mapped to `Status.unknown` and `requestPermissions()` always reported failure. BREAKING CHANGE: requires @nativescript-community/perms v3. Apps pinning perms v2 must upgrade alongside this release. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 22fbbcb commit 41217e4

2 files changed

Lines changed: 5 additions & 11 deletions

File tree

packages/camera/common.ts

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@ export function getAspectSafeDimensions(sourceWidth, sourceHeight, reqWidth, req
1010
height: Math.floor(sourceHeight / aspectCoef),
1111
};
1212
}
13-
function mapStatus(result: permissions.Result): Status {
14-
let status = Status.unknown;
15-
if (result && result.length > 1) {
16-
if (Object.keys(Status).findIndex((k) => k === result[0]) >= 0) {
17-
status = Status[result[0]];
18-
}
19-
}
20-
return status;
13+
function mapStatus(result: permissions.Status): Status {
14+
return Status[result] ?? Status.unknown;
2115
}
2216
export function mapError(e): PermissionResult {
2317
return {
@@ -26,7 +20,7 @@ export function mapError(e): PermissionResult {
2620
Error: e,
2721
};
2822
}
29-
export function mapCameraPermissionStatus(permission: permissions.Result): PermissionResult {
23+
export function mapCameraPermissionStatus(permission: permissions.Status): PermissionResult {
3024
const status = mapStatus(permission);
3125
const result = {
3226
Success: status === Status.authorized,
@@ -35,7 +29,7 @@ export function mapCameraPermissionStatus(permission: permissions.Result): Permi
3529
return result;
3630
}
3731

38-
export function mapPhotoPermissionStatus(permission: permissions.Result): PermissionResult {
32+
export function mapPhotoPermissionStatus(permission: permissions.Status): PermissionResult {
3933
const status = mapStatus(permission);
4034
const result = {
4135
Success: status === Status.authorized || status === Status.limited,

packages/camera/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,6 @@
3535
"readmeFilename": "README.md",
3636
"bootstrapper": "@nativescript/plugin-seed",
3737
"dependencies": {
38-
"@nativescript-community/perms": "^2.3.1"
38+
"@nativescript-community/perms": "^3.0.4"
3939
}
4040
}

0 commit comments

Comments
 (0)