import { inject , injectable } from 'inversify' ; import * as apid from '../../../../../../api' ; import DateUtil from '../../../../util/DateUtil' ; import IRecordedApiModel from '../../../api/recorded/IRecordedApiModel' ; import IChannelModel from '../../../channels/IChannelModel' ; import { ISettingStorageModel } from '../../../storage/setting/ISettingStorageModel' ; import IWatchRecordedInfoState , { DsiplayWatchInfo } from './IWatchRecordedInfoState' ; @ injectable ( ) export default class WatchRecordedInfoState implements IWatchRecordedInfoState { private recordedApiModel : IRecordedApiModel ; private channelModel : IChannelModel ; private settingModel : ISettingStorageModel ; private displayInfo : DsiplayWatchInfo | null = null ; constructor ( @ inject ( 'IRecordedApiModel' ) recordedApiModel , @ inject ( 'IChannelModel' ) channelModel , @ inject ( 'ISettingStorageModel' ) settingModel ) { this . recordedApiModel = recordedApiModel ; this . channelModel = channelModel ; this . settingModel = settingModel ; } /**
     * 表示情報をクリア
     */ public clear ( ) { this . displayInfo = null ; } param recordedId return public async update ( recordedId ) { const isHalfWidth = this . settingModel . getSavedValue ( ) . isHalfWidthDisplayed ; const recordedInfo = await this . recordedApiModel . get ( recordedId , isHalfWidth ) ; const channel = this . channelModel . findChannel ( recordedInfo . channelId , isHalfWidth ) ; const startAt = DateUtil . getJaDate ( new Date ( recordedInfo . startAt ) ) ; const endAt = DateUtil . getJaDate ( new Date ( recordedInfo . endAt ) ) ; this . displayInfo = { channelName : channel === null ? recordedInfo . channelId . toString ( 10 ) : channel . name , time : DateUtil . format ( startAt , 'MM/dd(w) hh:mm ~ ' ) + DateUtil . format ( endAt , 'hh:mm' ) , name : recordedInfo . name , description : recordedInfo . description , } ; } return public getInfo ( ) { return this . displayInfo ; } }