From d1698a28e65c6a1cabb91ac08659a83771f5b378 Mon Sep 17 00:00:00 2001 From: richard-loafle <44828666+richard-loafle@users.noreply.github.com> Date: Thu, 6 Feb 2020 10:26:39 +0900 Subject: [PATCH 1/2] open file is added --- .../components/messages.component.ts | 21 +++++++++++++++---- .../native/components/top-bar.component.html | 2 +- .../src/assets/i18n/en.json | 1 + .../src/assets/i18n/ko.json | 1 + 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts index 00a6126f..7bbecb02 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts +++ b/projects/ucap-webmessenger-app/src/app/layouts/messenger/components/messages.component.ts @@ -9,7 +9,8 @@ import { Inject, ChangeDetectorRef, ChangeDetectionStrategy, - ElementRef + ElementRef, + NgZone } from '@angular/core'; import { ucapAnimations, @@ -248,6 +249,7 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { private dialogService: DialogService, private snackBarService: SnackBarService, @Inject(UCAP_NATIVE_SERVICE) private nativeService: NativeService, + private ngZone: NgZone, private logger: NGXLogger ) { this.sessionVerInfo = this.sessionStorageService.get( @@ -1080,19 +1082,30 @@ export class MessagesComponent implements OnInit, OnDestroy, AfterViewInit { .saveFile(buffer, value.fileInfo.fileName, mimeType, savePath) .then(result => { if (!!result) { - this.snackBarService.open( + const snackBarRef = this.snackBarService.open( this.translateService.instant( 'common.file.results.savedToPath', { path: result } ), - '', + this.translateService.instant('common.file.open'), { duration: 3000, - verticalPosition: 'bottom' + verticalPosition: 'bottom', + horizontalPosition: 'center' } ); + + snackBarRef.onAction().subscribe(() => { + this.ngZone.runOutsideAngular(() => { + this.nativeService + .openTargetItem(result) + .catch(reason => { + this.logger.warn(reason); + }); + }); + }); } else { this.snackBarService.openFromComponent< AlertSnackbarComponent, diff --git a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html index 3fcf99a9..c72a8dc9 100644 --- a/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html +++ b/projects/ucap-webmessenger-app/src/app/layouts/native/components/top-bar.component.html @@ -501,7 +501,7 @@