2015-09-17 17:29:59 +02:00
|
|
|
var Util = require('../../util');
|
|
|
|
|
|
|
|
var LOAD_PROFILE = exports.LOAD_PROFILE = 'LOAD_PROFILE';
|
|
|
|
var LOAD_PROFILE_SUCCESS = exports.LOAD_PROFILE_SUCCESS = 'LOAD_PROFILE_SUCCESS';
|
|
|
|
var LOAD_PROFILE_FAILED = exports.LOAD_PROFILE_FAILED = 'LOAD_PROFILE_FAILED';
|
|
|
|
|
|
|
|
exports.loadProfile = function(profilePath) {
|
|
|
|
|
|
|
|
return function(dispatch, getState) {
|
|
|
|
|
|
|
|
dispatch({ type: LOAD_PROFILE, profilePath: profilePath });
|
|
|
|
|
2015-09-18 12:13:24 +02:00
|
|
|
return Util.System.loadJSON(profilePath)
|
2015-09-17 17:29:59 +02:00
|
|
|
.then(function(profile) {
|
|
|
|
dispatch({ type: LOAD_PROFILE_SUCCESS, profile: profile });
|
|
|
|
return profile;
|
|
|
|
})
|
|
|
|
.catch(function(err) {
|
|
|
|
dispatch({ type: LOAD_PROFILE_FAILED, error: err });
|
|
|
|
return err;
|
|
|
|
})
|
|
|
|
;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|