Refactoring
This commit is contained in:
parent
6a790cc5bd
commit
383f70f7f3
|
@ -120,6 +120,7 @@ html, body {
|
|||
display: flex;
|
||||
flex-direction: row;
|
||||
padding: 10px;
|
||||
flex: 3;
|
||||
}
|
||||
|
||||
.edit .left-menu {
|
||||
|
@ -132,7 +133,7 @@ html, body {
|
|||
.edit .item-form {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex: 1;
|
||||
flex: 2;
|
||||
}
|
||||
|
||||
.edit .apps-list .icon-theme-selector > select {
|
||||
|
|
|
@ -51,7 +51,7 @@ var TreeNode = React.createClass({
|
|||
var ProfileTree = React.createClass({
|
||||
|
||||
componentDidMount: function() {
|
||||
this.props.dispatch(actions.launcher.loadProfile('./default-profile.json'));
|
||||
this.props.dispatch(actions.common.loadProfile('./default-profile.json'));
|
||||
},
|
||||
|
||||
render: function() {
|
||||
|
|
|
@ -21,7 +21,7 @@ var LauncherView = React.createClass({
|
|||
|
||||
componentDidMount: function() {
|
||||
var profilePath = this.props.processOpts.profile || DEFAULT_PROFILE;
|
||||
this.props.dispatch(actions.launcher.loadProfile(profilePath));
|
||||
this.props.dispatch(actions.common.loadProfile(profilePath));
|
||||
},
|
||||
|
||||
componentWillReceiveProps: function(nextProps) {
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
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 });
|
||||
|
||||
return Util.System.loadJSONFile(profilePath)
|
||||
.then(function(profile) {
|
||||
dispatch({ type: LOAD_PROFILE_SUCCESS, profile: profile });
|
||||
return profile;
|
||||
})
|
||||
.catch(function(err) {
|
||||
dispatch({ type: LOAD_PROFILE_FAILED, error: err });
|
||||
return err;
|
||||
})
|
||||
;
|
||||
|
||||
};
|
||||
|
||||
};
|
|
@ -5,6 +5,11 @@ var path = require('path');
|
|||
var LOAD_DESKTOP_APPS = exports.LOAD_PROFILE = 'LOAD_DESKTOP_APPS';
|
||||
var LOAD_DESKTOP_APPS_SUCCESS = exports.LOAD_DESKTOP_APPS_SUCCESS = 'LOAD_DESKTOP_APPS_SUCCESS';
|
||||
var LOAD_DESKTOP_APPS_FAILED = exports.LOAD_DESKTOP_APPS_FAILED = 'LOAD_DESKTOP_APPS_FAILED';
|
||||
|
||||
var SAVE_PROFILE = exports.SAVE_PROFILE = 'SAVE_PROFILE';
|
||||
var SAVE_PROFILE_SUCCESS = exports.SAVE_PROFILE_SUCCESS = 'SAVE_PROFILE_SUCCESS';
|
||||
var SAVE_PROFILE_FAILED = exports.SAVE_PROFILE_FAILED = 'SAVE_PROFILE_FAILED';
|
||||
|
||||
var MOVE_PROFILE_ITEM = exports.MOVE_PROFILE_ITEM = 'MOVE_PROFILE_ITEM';
|
||||
var ADD_PROFILE_ITEM = exports.ADD_PROFILE_ITEM = 'ADD_PROFILE_ITEM';
|
||||
var USE_ICON_THEME = exports.USE_ICON_THEME = 'USE_ICON_THEME';
|
||||
|
@ -34,6 +39,14 @@ exports.loadDesktopApps = function() {
|
|||
};
|
||||
};
|
||||
|
||||
exports.saveProfile = function(profile) {
|
||||
return function(dispatch, getState) {
|
||||
|
||||
|
||||
|
||||
};
|
||||
};
|
||||
|
||||
exports.useIconTheme = function(theme) {
|
||||
return {
|
||||
type: USE_ICON_THEME,
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
exports.launcher = require('./launcher');
|
||||
exports.edit = require('./edit');
|
||||
exports.common = require('./common');
|
||||
|
|
|
@ -1,34 +1,9 @@
|
|||
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';
|
||||
|
||||
var RUN_APP = exports.RUN_APP = 'RUN_APP';
|
||||
var RUN_APP_SUCCESS = exports.RUN_APP_SUCCESS = 'RUN_APP_SUCCESS';
|
||||
var RUN_APP_FAILED = exports.RUN_APP_FAILED = 'RUN_APP_FAILED';
|
||||
|
||||
exports.loadProfile = function(profilePath) {
|
||||
|
||||
return function(dispatch, getState) {
|
||||
|
||||
dispatch({ type: LOAD_PROFILE, profilePath: profilePath });
|
||||
|
||||
return Util.System.loadJSONFile(profilePath)
|
||||
.then(function(profile) {
|
||||
dispatch({ type: LOAD_PROFILE_SUCCESS, profile: profile });
|
||||
return profile;
|
||||
})
|
||||
.catch(function(err) {
|
||||
dispatch({ type: LOAD_PROFILE_FAILED, error: err });
|
||||
return err;
|
||||
})
|
||||
;
|
||||
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
exports.runApp = function(execPath) {
|
||||
|
||||
return function(dispatch, getState) {
|
||||
|
|
|
@ -6,7 +6,7 @@ module.exports = function(oldProfile, action) {
|
|||
|
||||
switch(action.type) {
|
||||
|
||||
case actions.launcher.LOAD_PROFILE_SUCCESS:
|
||||
case actions.common.LOAD_PROFILE_SUCCESS:
|
||||
var newProfile = _.cloneDeep(action.profile);
|
||||
tree.walk(newProfile, ensureItemKey);
|
||||
return newProfile;
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
var crypto = require('crypto');
|
||||
|
||||
function Cache() {
|
||||
this._store = {};
|
||||
|
@ -20,14 +21,9 @@ Cache.prototype._serialize = function(mixedKey) {
|
|||
};
|
||||
|
||||
Cache.prototype._hash = function(str) {
|
||||
var hash = 0, i, chr, len;
|
||||
if (str.length === 0) return hash;
|
||||
for (i = 0, len = str.length; i < len; i++) {
|
||||
chr = str.charCodeAt(i);
|
||||
hash = ((hash << 5) - hash) + chr;
|
||||
hash |= 0; // Convert to 32bit integer
|
||||
}
|
||||
return hash;
|
||||
var shasum = crypto.createHash('md5');
|
||||
shasum.update(str);
|
||||
return shasum.digest('hex');
|
||||
};
|
||||
|
||||
module.exports = Cache;
|
||||
|
|
Loading…
Reference in New Issue