import { ReminderSettings } from '@ulangi/ulangi-common/interfaces' ; import { ObservableNotificationStore , ObservableUserStore , } from '@ulangi/ulangi-observable' ; import * as moment from 'moment' ; import { config } from '../../constants/config' ; export class ReminderSettingsDelegate { private userStore : ObservableUserStore ; private notificationStore : ObservableNotificationStore ; public constructor ( userStore , notificationStore ) { this . userStore = userStore ; this . notificationStore = notificationStore ; } public getCurrentSettings ( ) { const reminderSettings = typeof this . userStore . existingCurrentUser . globalReminder !== 'undefined' ? this . userStore . existingCurrentUser . globalReminder : config . user . defaultGlobalReminder ; return reminderSettings ; } public isReminderActive ( ) { return ( this . notificationStore . hasPermission === true && this . getCurrentSettings ( ) . reminderEnabled === true ) ; } public getReadableTime ( ) { const { hours , minutes } = this . getCurrentSettings ( ) ; return moment ( ) . hours ( hours ) . minutes ( minutes ) . format ( 'hh:mm a' ) ; } }