2019-09-18 15:02:21 +09:00
|
|
|
import { Injectable } from '@angular/core';
|
|
|
|
|
|
|
|
import { ipcRenderer } from 'electron';
|
|
|
|
|
2019-09-19 10:40:16 +09:00
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
2019-09-18 15:02:21 +09:00
|
|
|
import { NativeService } from '@ucap-webmessenger/native';
|
|
|
|
import { Channel } from '../types/channel.type';
|
|
|
|
|
|
|
|
export class ElectronNativeService implements NativeService {
|
|
|
|
showNotify(
|
|
|
|
roomSeq: number,
|
|
|
|
title: string,
|
|
|
|
contents: string,
|
|
|
|
image: string,
|
|
|
|
useSound: boolean
|
|
|
|
): void {
|
|
|
|
ipcRenderer.send(
|
|
|
|
Channel.showNotify,
|
|
|
|
roomSeq,
|
|
|
|
title,
|
|
|
|
contents,
|
|
|
|
image,
|
|
|
|
useSound
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-09-19 10:40:16 +09:00
|
|
|
checkForUpdates(): Observable<boolean> {
|
|
|
|
return new Observable<boolean>(subscriber => {
|
2019-09-18 15:02:21 +09:00
|
|
|
try {
|
2019-09-19 10:40:16 +09:00
|
|
|
subscriber.next(ipcRenderer.sendSync(Channel.checkForUpdates));
|
2019-09-18 15:02:21 +09:00
|
|
|
} catch (error) {
|
2019-09-19 10:40:16 +09:00
|
|
|
subscriber.error(error);
|
|
|
|
} finally {
|
|
|
|
subscriber.complete();
|
2019-09-18 15:02:21 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
showImageViewer(): void {
|
|
|
|
ipcRenderer.send(Channel.showImageViewer);
|
|
|
|
}
|
|
|
|
|
|
|
|
saveFile(blob: Blob): void {
|
|
|
|
ipcRenderer.send(Channel.saveFile, blob);
|
|
|
|
}
|
|
|
|
constructor() {}
|
|
|
|
}
|