Skip to content

Commit 64ee163

Browse files
authored
Merge pull request #2966 from numbersprotocol/fix-v230725-issue-Some-device-can’t-record-15s-SHORT-by-Capture-camera
Fix v230725 issue some device can’t record 15s short by capture camera
2 parents 4630fb9 + 146437c commit 64ee163

File tree

2 files changed

+28
-11
lines changed

2 files changed

+28
-11
lines changed

src/app/features/home/custom-camera/custom-camera.page.html

+1
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@
148148

149149
<app-pre-publish-mode
150150
*ngIf="(mode$ | ngrxPush) === 'pre-publish'"
151+
[curCaptureCameraSource]="curCaptureCameraSource"
151152
[curCaptureFileSize]="curCaptureFileSize"
152153
[curCaptureFilePath]="curCaptureFilePath"
153154
[curCaptureFileName]="curCaptureFileName"

src/app/features/home/custom-camera/pre-publish-mode/pre-publish-mode.component.ts

+27-11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
Output,
88
ViewChild,
99
} from '@angular/core';
10+
import { CameraSource } from '@capacitor/camera';
1011
import { Directory, FilesystemPlugin } from '@capacitor/filesystem';
1112
import { AlertController, Platform } from '@ionic/angular';
1213
import { TranslocoService } from '@ngneat/transloco';
@@ -58,6 +59,12 @@ export class PrePublishModeComponent {
5859

5960
private toggleBlackAndWhiteFilter = true;
6061

62+
readonly curCaptureCameraSource$ = new ReplaySubject<CameraSource>(1);
63+
64+
readonly isFromGallery$ = this.curCaptureCameraSource$.pipe(
65+
map(cameraSource => cameraSource === CameraSource.Photos)
66+
);
67+
6168
readonly curCaptureFileSize$ = new ReplaySubject<number>(1);
6269

6370
readonly curCaptureFilePath$ = new ReplaySubject<string>(1);
@@ -98,7 +105,12 @@ export class PrePublishModeComponent {
98105
readonly isFileSizeExceeded$ = combineLatest([
99106
this.curCaptureFileSize$,
100107
this.maxAllowedFileSize$,
101-
]).pipe(map(([curSize, maxSize]) => curSize < maxSize));
108+
]).pipe(map(([curSize, maxSize]) => curSize > maxSize));
109+
110+
@Input()
111+
set curCaptureCameraSource(value: CameraSource | undefined) {
112+
if (value) this.curCaptureCameraSource$.next(value);
113+
}
102114

103115
@Input()
104116
set curCaptureFileSize(value: number | undefined) {
@@ -223,21 +235,25 @@ export class PrePublishModeComponent {
223235
tap(isImage => (isImage ? this.confirmImage() : this.confirmVideo()))
224236
);
225237

226-
const showIsFileSizeExceededAction$ = defer(() =>
227-
this.showIsFileSizeExceededModal()
238+
const showFileSizeExceededAction$ = defer(() =>
239+
this.showFileSizeExceededModal()
228240
);
229241

230-
this.isFileSizeExceeded$
242+
const shouldShowFileSizeExeededDialog$ = combineLatest([
243+
this.isFromGallery$,
244+
this.isFileSizeExceeded$,
245+
]).pipe(map(([c1, c2]) => c1 === true && c2 === true));
246+
247+
shouldShowFileSizeExeededDialog$
231248
.pipe(
232249
first(),
233-
switchMap(hasEnoughMemory =>
250+
switchMap(shouldShowFileSizeExeededDialog =>
234251
iif(
235-
() => hasEnoughMemory,
236-
runConfirmAction$,
237-
showIsFileSizeExceededAction$
252+
() => shouldShowFileSizeExeededDialog,
253+
showFileSizeExceededAction$,
254+
runConfirmAction$
238255
)
239-
),
240-
catchError((error: unknown) => this.errorService.toastError$(error))
256+
)
241257
)
242258
.subscribe();
243259
}
@@ -259,7 +275,7 @@ export class PrePublishModeComponent {
259275
this.confirm.emit(true);
260276
}
261277

262-
private showIsFileSizeExceededModal() {
278+
private showFileSizeExceededModal() {
263279
const translations$ = this.translocoService.selectTranslateObject({
264280
'customCamera.error.fileSizeExeedsLimit': null,
265281
ok: null,

0 commit comments

Comments
 (0)