Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(camera): Allow cancelation of sheet in Web #2284

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion camera/src/web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
document.body.appendChild(actionSheet);
}
actionSheet.header = options.promptLabelHeader || 'Photo';
actionSheet.cancelable = false;
actionSheet.cancelable = true;
actionSheet.options = [
{ title: options.promptLabelPhoto || 'From Photos' },
{ title: options.promptLabelPicture || 'Take Picture' },
Expand All @@ -42,7 +42,7 @@
});
}

async pickImages(_options: GalleryImageOptions): Promise<GalleryPhotos> {

Check warning on line 45 in camera/src/web.ts

View workflow job for this annotation

GitHub Actions / lint (camera)

'_options' is defined but never used
// eslint-disable-next-line no-async-promise-executor
return new Promise<GalleryPhotos>(async (resolve, reject) => {
this.multipleFileInputExperience(resolve, reject);
Expand Down Expand Up @@ -107,8 +107,8 @@
input.type = 'file';
input.hidden = true;
document.body.appendChild(input);
input.addEventListener('change', (_e: any) => {

Check warning on line 110 in camera/src/web.ts

View workflow job for this annotation

GitHub Actions / lint (camera)

'_e' is defined but never used
const file = input.files![0];

Check warning on line 111 in camera/src/web.ts

View workflow job for this annotation

GitHub Actions / lint (camera)

Forbidden non-null assertion
let format = 'jpeg';

if (file.type === 'image/png') {
Expand Down Expand Up @@ -149,7 +149,7 @@
cleanup();
}
});
input.addEventListener('cancel', (_e: any) => {

Check warning on line 152 in camera/src/web.ts

View workflow job for this annotation

GitHub Actions / lint (camera)

'_e' is defined but never used
reject(new CapacitorException('User cancelled photos app'));
cleanup();
});
Expand Down Expand Up @@ -188,11 +188,11 @@
input.hidden = true;
input.multiple = true;
document.body.appendChild(input);
input.addEventListener('change', (_e: any) => {

Check warning on line 191 in camera/src/web.ts

View workflow job for this annotation

GitHub Actions / lint (camera)

'_e' is defined but never used
const photos = [];
// eslint-disable-next-line @typescript-eslint/prefer-for-of
for (let i = 0; i < input.files!.length; i++) {

Check warning on line 194 in camera/src/web.ts

View workflow job for this annotation

GitHub Actions / lint (camera)

Forbidden non-null assertion
const file = input.files![i];

Check warning on line 195 in camera/src/web.ts

View workflow job for this annotation

GitHub Actions / lint (camera)

Forbidden non-null assertion
let format = 'jpeg';

if (file.type === 'image/png') {
Expand All @@ -208,7 +208,7 @@
resolve({ photos });
cleanup();
});
input.addEventListener('cancel', (_e: any) => {

Check warning on line 211 in camera/src/web.ts

View workflow job for this annotation

GitHub Actions / lint (camera)

'_e' is defined but never used
reject(new CapacitorException('User cancelled photos app'));
cleanup();
});
Expand Down
Loading