@ -4,6 +4,7 @@ import PersistentSettingRepository
import SettingRepository from '../repositories/SettingRepository' ;
import SettingRepository from '../repositories/SettingRepository' ;
import { DefaultSettingData } from '../../shared/SettingData' ;
import { DefaultSettingData } from '../../shared/SettingData' ;
import Settings from '../../shared/Settings' ;
import Settings from '../../shared/Settings' ;
import NotifyPresenter from '../presenters/NotifyPresenter' ;
@injectable ( )
@injectable ( )
export default class SettingUseCase {
export default class SettingUseCase {
@ -11,6 +12,7 @@ export default class SettingUseCase {
constructor (
constructor (
private persistentSettingRepository : PersistentSettingRepository ,
private persistentSettingRepository : PersistentSettingRepository ,
private settingRepository : SettingRepository ,
private settingRepository : SettingRepository ,
private notifyPresenter : NotifyPresenter ,
) {
) {
}
}
@ -24,8 +26,14 @@ export default class SettingUseCase {
data = DefaultSettingData ;
data = DefaultSettingData ;
}
}
let value = data . toSettings ( ) ;
let value : Settings ;
this . settingRepository . update ( value ) ;
try {
value = data . toSettings ( ) ;
} catch ( e ) {
this . notifyPresenter . notifyInvalidSettings ( ( ) = > { } ) ;
value = DefaultSettingData . toSettings ( ) ;
}
this . settingRepository . update ( value ! ! ) ;
return value ;
return value ;
}
}
}
}