77 Output ,
88 ViewChild ,
99} from '@angular/core' ;
10- import { CameraSource } from '@capacitor/camera' ;
1110import { Directory , FilesystemPlugin } from '@capacitor/filesystem' ;
1211import { AlertController , Platform } from '@ionic/angular' ;
1312import { TranslocoService } from '@ngneat/transloco' ;
@@ -59,12 +58,6 @@ export class PrePublishModeComponent {
5958
6059 private toggleBlackAndWhiteFilter = true ;
6160
62- readonly curCaptureCameraSource$ = new ReplaySubject < CameraSource > ( 1 ) ;
63-
64- readonly isFromGallery$ = this . curCaptureCameraSource$ . pipe (
65- map ( cameraSource => cameraSource === CameraSource . Photos )
66- ) ;
67-
6861 readonly curCaptureFileSize$ = new ReplaySubject < number > ( 1 ) ;
6962
7063 readonly curCaptureFilePath$ = new ReplaySubject < string > ( 1 ) ;
@@ -105,12 +98,7 @@ export class PrePublishModeComponent {
10598 readonly isFileSizeExceeded$ = combineLatest ( [
10699 this . curCaptureFileSize$ ,
107100 this . maxAllowedFileSize$ ,
108- ] ) . pipe ( map ( ( [ curSize , maxSize ] ) => curSize > maxSize ) ) ;
109-
110- @Input ( )
111- set curCaptureCameraSource ( value : CameraSource | undefined ) {
112- if ( value ) this . curCaptureCameraSource$ . next ( value ) ;
113- }
101+ ] ) . pipe ( map ( ( [ curSize , maxSize ] ) => curSize < maxSize ) ) ;
114102
115103 @Input ( )
116104 set curCaptureFileSize ( value : number | undefined ) {
@@ -235,25 +223,21 @@ export class PrePublishModeComponent {
235223 tap ( isImage => ( isImage ? this . confirmImage ( ) : this . confirmVideo ( ) ) )
236224 ) ;
237225
238- const showFileSizeExceededAction $ = defer ( ( ) =>
239- this . showFileSizeExceededModal ( )
226+ const showIsFileSizeExceededAction $ = defer ( ( ) =>
227+ this . showIsFileSizeExceededModal ( )
240228 ) ;
241229
242- const shouldShowFileSizeExeededDialog$ = combineLatest ( [
243- this . isFromGallery$ ,
244- this . isFileSizeExceeded$ ,
245- ] ) . pipe ( map ( ( [ c1 , c2 ] ) => c1 === true && c2 === true ) ) ;
246-
247- shouldShowFileSizeExeededDialog$
230+ this . isFileSizeExceeded$
248231 . pipe (
249232 first ( ) ,
250- switchMap ( shouldShowFileSizeExeededDialog =>
233+ switchMap ( hasEnoughMemory =>
251234 iif (
252- ( ) => shouldShowFileSizeExeededDialog ,
253- showFileSizeExceededAction $,
254- runConfirmAction $
235+ ( ) => hasEnoughMemory ,
236+ runConfirmAction $,
237+ showIsFileSizeExceededAction $
255238 )
256- )
239+ ) ,
240+ catchError ( ( error : unknown ) => this . errorService . toastError$ ( error ) )
257241 )
258242 . subscribe ( ) ;
259243 }
@@ -275,7 +259,7 @@ export class PrePublishModeComponent {
275259 this . confirm . emit ( true ) ;
276260 }
277261
278- private showFileSizeExceededModal ( ) {
262+ private showIsFileSizeExceededModal ( ) {
279263 const translations$ = this . translocoService . selectTranslateObject ( {
280264 'customCamera.error.fileSizeExeedsLimit' : null ,
281265 ok : null ,
0 commit comments