import { Observable } from 'rxjs'; import { NativeService, WindowState, NotificationRequest, WindowIdle } from '@ucap-webmessenger/native'; import { HttpClient } from '@angular/common/http'; import { map } from 'rxjs/operators'; import { Injectable } from '@angular/core'; import { TranslateLoader } from '@ngx-translate/core'; import { TranslateLoaderService } from '../translate/browser-loader'; import { NotificationService } from '../notification/notification.service'; @Injectable({ providedIn: 'root' }) export class BrowserNativeService implements NativeService { private notificationService: NotificationService; postAppInit(): void { this.notificationService.requestPermission(); } notify(noti: NotificationRequest): void { console.log('ddd'); this.notificationService.notify(noti); } closeAllNotify(): void {} checkForUpdates(): Observable { return new Observable(subscriber => { try { subscriber.next(false); } catch (error) { subscriber.error(error); } finally { subscriber.complete(); } }); } showImageViewer(): void {} readFile(path: string): Observable { return this.httpClient.get(path, { responseType: 'arraybuffer' }).pipe( map(arrayBuffer => { return Buffer.from(arrayBuffer); }) ); } saveFile( buffer: Buffer, fileName: string, path?: string ): Observable { return this.httpClient.post(path, buffer, {}); } windowStateChanged(): Observable { return new Observable(subscriber => { try { subscriber.next(WindowState.Normal); } catch (error) { subscriber.error(error); } finally { subscriber.complete(); } }); } windowClose(): void {} windowMinimize(): void {} windowMaximize(): void {} idleStateChanged(): Observable { return new Observable(subscriber => { try { subscriber.next(WindowIdle.Active); } catch (error) { subscriber.error(error); } finally { subscriber.complete(); } }); } getTranslateLoader(prefix?: string, suffix?: string): TranslateLoader { return new TranslateLoaderService(this, prefix, suffix); } constructor(private httpClient: HttpClient) { this.notificationService = new NotificationService(); } }