converse-desktop/app/services/app-state-service.js

22 lines
700 B
JavaScript
Raw Normal View History

2020-05-09 15:07:42 +00:00
let angApp = require(__dirname + '/../init')
angApp.factory('AppStateService', [ '$rootScope', ($rootScope) => {
let stateService = {}
stateService.APP_STATE_LOGIN = 'login'
stateService.APP_STATE_DEFAULT = 'default'
stateService.APP_STATE_SETTINGS = 'settings'
2020-05-11 19:39:11 +00:00
stateService.APP_STATE_ABOUT = 'about'
2020-05-09 15:07:42 +00:00
stateService.set = (state) => {
2020-05-12 15:06:16 +00:00
stateService.previousState = typeof stateService.state !== 'undefined' ?
stateService.state : stateService.APP_STATE_DEFAULT
2020-05-09 15:07:42 +00:00
stateService.state = state
2020-05-13 20:01:42 +00:00
$rootScope.$broadcast('app:state:changed', stateService.state)
2020-05-09 15:07:42 +00:00
}
stateService.set(stateService.APP_STATE_DEFAULT)
return stateService
}])