Skip to content

Commit 9d76c06

Browse files
NathanWalkerclaude
andcommitted
feat(imagepicker)!: migrate to @nativescript-community/perms v3
perms v3 changed single-permission `request()` to resolve to a `Status` string instead of the v2 `[Status, boolean]` tuple; the multi-permission `MultiResult` shape is unchanged. Under v3 `mapResult` took the MultiResult branch for a plain status string, found none of the media permission keys on it, and returned `authorized: true` regardless of what the user chose. BREAKING CHANGE: `AuthorizationResult.details` is now `MultiResult | Status` rather than `MultiResult | Result`, and perms v3 is required. Apps pinning perms v2 must upgrade alongside this release. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent 22fbbcb commit 9d76c06

2 files changed

Lines changed: 6 additions & 7 deletions

File tree

packages/imagepicker/common.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ImageAsset, ImageSource } from '@nativescript/core';
2-
import { MultiResult, Result } from '@nativescript-community/perms';
2+
import { MultiResult, Status } from '@nativescript-community/perms';
33

44
export enum ImagePickerMediaType {
55
Any = 0,
@@ -148,18 +148,17 @@ export interface ImagePickerApi {
148148

149149
export interface AuthorizationResult {
150150
authorized: boolean;
151-
details: MultiResult | Result;
151+
details: MultiResult | Status;
152152
}
153153
const requestingPermissions = ['android.permission.READ_MEDIA_IMAGES', 'android.permission.READ_MEDIA_VIDEO'];
154154

155155
export abstract class ImagePickerBase implements ImagePickerApi {
156156
abstract authorize(): Promise<AuthorizationResult>;
157157
abstract present(): Promise<ImagePickerSelection[]>;
158-
protected mapResult(result: MultiResult | Result): AuthorizationResult {
158+
protected mapResult(result: MultiResult | Status): AuthorizationResult {
159159
let authorized = true;
160-
if (Array.isArray(result) && result.length == 2) {
161-
// is of type Result
162-
authorized = result[0] === 'authorized' || result[0] === 'limited';
160+
if (typeof result === 'string') {
161+
authorized = result === 'authorized' || result === 'limited';
163162
} else {
164163
const t = result as MultiResult;
165164
requestingPermissions.forEach((permission) => {

packages/imagepicker/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,6 @@
3333
"readmeFilename": "README.md",
3434
"bootstrapper": "@nativescript/plugin-seed",
3535
"dependencies": {
36-
"@nativescript-community/perms": "^2.3.1"
36+
"@nativescript-community/perms": "^3.0.4"
3737
}
3838
}

0 commit comments

Comments
 (0)