import { ipcRenderer } from 'electron' ; import { ApplicationSettings , IpcEvents , UserConfiguration } from 'uhk-common' ; import { Observable , from , of } from 'rxjs' ; import { DataStorageRepositoryService } from '../../app/services/datastorage-repository.service' ; export class ElectronDataStorageRepositoryService implements DataStorageRepositoryService { static async getValue ( key ) { const value = await ipcRenderer . invoke ( IpcEvents . app . getConfig , key ) ; if ( ! value ) { return null ; } return JSON . parse ( < string > value ) ; } static async saveValue ( key , value ) { await ipcRenderer . invoke ( IpcEvents . app . setConfig , key , JSON . stringify ( value ) ) ; return null ; } getConfig ( ) { return of ( null ) ; } saveConfig ( config ) { return of ( null ) ; } getApplicationSettings ( ) { return from ( ElectronDataStorageRepositoryService . getValue ( 'application-settings' ) ) ; } saveApplicationSettings ( settings ) { return from ( ElectronDataStorageRepositoryService . saveValue ( 'application-settings' , settings ) ) ; } }