Skip to content

Commit

Permalink
fixed zClean freezing at "Done loading" and md5 hash issue
Browse files Browse the repository at this point in the history
  • Loading branch information
matortheeternal committed Jun 5, 2018
1 parent 5285181 commit 7bff393
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 38 deletions.
7 changes: 6 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -56,8 +56,9 @@
"font-awesome": "^4.7.0",
"fs-jetpack": "^0.10.5",
"marked": "^0.3.19",
"ui-router-extras": "^0.1.3",
"xelib": "github:matortheeternal/xelib"
"xelib": "github:matortheeternal/xelib",
"md5-file": "^4.0.0",
"ui-router-extras": "^0.1.3"
},
"devDependencies": {
"chai": "^3.5.0",
Expand Down
26 changes: 23 additions & 3 deletions src/javascripts/Directives/pluginLoader.js
Expand Up @@ -12,6 +12,10 @@ ngapp.controller('pluginLoaderController', function($rootScope, $scope, $timeout
let appMode = `z${$rootScope.appMode.capitalize()}`;
timerService.start('loader');

// initialization
$scope.loaded = false;
$scope.spinnerOpts = spinnerFactory.defaultOptions;

// helper functions
let logMessages = function() {
let str = xelib.GetMessages();
Expand All @@ -28,6 +32,11 @@ ngapp.controller('pluginLoaderController', function($rootScope, $scope, $timeout
logger.info(`Files loaded in ${secondsStr}`);
};

let ignore = function(e) {
e.stopPropagation();
e.preventDefault();
};

// scope functions
$scope.checkIfLoaded = function() {
logMessages();
Expand All @@ -43,9 +52,20 @@ ngapp.controller('pluginLoaderController', function($rootScope, $scope, $timeout
}
};

// initialization
$scope.loaded = false;
$scope.spinnerOpts = spinnerFactory.defaultOptions;
// event handlers
document.addEventListener('mousedown', ignore, true);
document.addEventListener('click', ignore, true);
document.addEventListener('mouseup', ignore, true);

$scope.$on('filesLoaded', function() {
$scope.loaded = true;
$timeout(() => {
logger.info('Allowing click events');
document.removeEventListener('mousedown', ignore, true);
document.removeEventListener('click', ignore, true);
document.removeEventListener('mouseup', ignore, true);
}, 500);
});

$scope.checkIfLoaded();
$scope.$emit('setTitle', `${appMode} - Loading Plugins`);
Expand Down
23 changes: 12 additions & 11 deletions src/javascripts/Views/clean.js
Expand Up @@ -131,17 +131,18 @@ ngapp.controller('cleanController', function ($rootScope, $scope, $timeout, $ele
};

$scope.getPlugins = function() {
$scope.plugins = xelib.GetElements().map(function(file) {
return {
handle: file,
filename: xelib.Name(file),
hash: xelib.MD5Hash(file),
status: 'Queued',
skip: false,
showContent: false
};
}).filter(function(plugin) {
return !$scope.ignorePlugin(plugin.filename);
let dataPath = xelib.GetGlobal('DataPath');
$scope.plugins = xelib.GetElements().map(file => ({
handle: file,
filename: xelib.Name(file),
status: 'Queued',
skip: false,
showContent: false
})).filter(plugin => {
if ($scope.ignorePlugin(plugin.filename)) return;
plugin.filePath = `${dataPath}\\${plugin.filename}`;
plugin.hash = md5File.sync(plugin.filePath);
return true;
});
};

Expand Down
21 changes: 0 additions & 21 deletions src/javascripts/Views/edit.js
Expand Up @@ -38,16 +38,6 @@ ngapp.controller('editController', function ($scope, $timeout, layoutService, ho
return filterView;
};

let ignore = function(e) {
e.stopPropagation();
e.preventDefault();
};

// event handlers
document.addEventListener('mousedown', ignore, true);
document.addEventListener('click', ignore, true);
document.addEventListener('mouseup', ignore, true);

$scope.onViewportRender = function() {
if (verbose) logger.info('Rendering viewport...');
};
Expand Down Expand Up @@ -85,17 +75,6 @@ ngapp.controller('editController', function ($scope, $timeout, layoutService, ho
layoutService.switchToView('log-view');
});

$scope.$on('filesLoaded', function() {
if (verbose) logger.info('Rendering editView');
$scope.loaded = true;
$timeout(() => {
logger.info('Allowing click events');
document.removeEventListener('mousedown', ignore, true);
document.removeEventListener('click', ignore, true);
document.removeEventListener('mouseup', ignore, true);
}, 500);
});

// handle hotkeys
hotkeyService.buildOnKeyDown($scope, 'onKeyDown', 'editView');

Expand Down
1 change: 1 addition & 0 deletions src/javascripts/app.js
Expand Up @@ -14,6 +14,7 @@ import logger from './helpers/logger.js';
import buildModuleService from './helpers/moduleService';
import './polyfills';
import './color';
window.md5File = require('md5-file');
window.xelib = require('xelib').wrapper;

// init logger
Expand Down

0 comments on commit 7bff393

Please sign in to comment.