import { action , computed , makeObservable , observable } from 'mobx' ; import { persist } from 'mobx-persist' ; import { rootStore } from '..' ; import { ICurrency } from '../interfaces/currency.interface' ; import { electronService } from '../services/electron.service' ; import { RootStore } from './rootStore' ; export type ReleaseChannel = 'latest' | 'beta' ; export type AppExitTypes = 'minimize-to-tray' | 'exit' ; export class SettingStore { @ persist @ observable lowConfidencePricing : boolean = false ; @ persist @ observable autoSnapshotting : boolean = false ; @ persist @ observable isHardwareAccelerationEnabled : boolean = electronService . localSettings ?. isHardwareAccelerationEnabled || true ; @ persist @ observable releaseChannel : ReleaseChannel = electronService . localSettings ?. releaseChannel || 'latest' ; @ persist @ observable priceThreshold : number = 0 ; @ persist @ observable totalPriceThreshold : number = 0 ; @ persist @ observable showPriceInExalt = false ; @ persist @ observable autoSnapshotInterval : number = 60 * 20 * 1000 ; @ persist @ observable uiScale : number = electronService . webFrame . getZoomFactor ( ) * 100 ; @ persist @ observable logPath : string = 'C:/Program Files (x86)/Grinding Gear Games/Path of Exile/logs/Client.txt' ; @ persist @ observable appExitAction : AppExitTypes = electronService . localSettings ?. appExitAction || 'minimize-to-tray' ; constructor ( private rootStore ) { makeObservable ( this ) ; } @ computed get activeCurrency ( ) : ICurrency { return this . showPriceInExalt ? { name : 'exalted' , short : 'ex' } : { name : 'chaos' , short : 'c' } ; } @ action setUiScale ( factor ) { if ( typeof factor === 'string' ) { return ; } if ( Array . isArray ( factor ) ) { factor = factor [ factor . length - 1 ] ; } this . uiScale = factor ; electronService . webFrame . setZoomFactor ( factor / 100 ) ; } @ action setShowPriceInExalt ( value ) { this . showPriceInExalt = value ; rootStore . accountStore . getSelectedAccount ?. activeProfile ?. updateNetWorthOverlay ( ) ; } @ action setLowConfidencePricing ( value ) { this . lowConfidencePricing = value ; } @ action setAutoSnapshotting ( value ) { if ( ! value ) { this . rootStore . accountStore . getSelectedAccount . dequeueSnapshot ( ) ; } else { this . rootStore . accountStore . getSelectedAccount . queueSnapshot ( ) ; } this . autoSnapshotting = value ; } @ action setReleaseChannel ( value ) { this . releaseChannel = value ; electronService . ipcRenderer . send ( 'release-channel' , value ) ; } @ action setHardwareAcceleration ( value ) { this . isHardwareAccelerationEnabled = value ; electronService . ipcRenderer . send ( 'hardware-acceleration' , value ) ; } @ action setPriceThreshold ( value ) { this . priceThreshold = value ; } @ action setTotalPriceThreshold ( value ) { this . totalPriceThreshold = value ; } @ action setAutoSnapshotInterval ( value ) { this . autoSnapshotInterval = value * 60 * 1000 ; this . rootStore . accountStore . getSelectedAccount . dequeueSnapshot ( ) ; this . rootStore . accountStore . getSelectedAccount . queueSnapshot ( ) ; } @ action setLogPath ( path ) { this . logPath = path ; } @ action setAppExitAction ( appExitAction ) { this . appExitAction = appExitAction ; electronService . ipcRenderer . send ( 'app-exit-action' , appExitAction ) ; } }