Ajout d'un délai minimum de 2s entre deux clics pour éviter des lancements intempestifs d'applications. Fixes #4

This commit is contained in:
wpetit 2016-04-07 17:53:42 +02:00
parent 8ad1c3055a
commit 3ded369d09
1 changed files with 12 additions and 1 deletions

View File

@ -8,9 +8,11 @@ var connect = require('react-redux').connect;
var logger = require('../../util/logger'); var logger = require('../../util/logger');
var CrossfadeImage = require('../common/crossfade-image'); var CrossfadeImage = require('../common/crossfade-image');
var path = require('path'); var path = require('path');
var _ = require('lodash');
var DEFAULT_PROFILE = path.join(__dirname, '..', '..', '..', 'default-profile.json'); var DEFAULT_PROFILE = path.join(__dirname, '..', '..', '..', 'default-profile.json');
var DEFAULT_BACKGROUND = ''; var DEFAULT_BACKGROUND = '';
var MIN_CLICK_DELTATIME = 2000;
var LauncherView = React.createClass({ var LauncherView = React.createClass({
@ -19,7 +21,8 @@ var LauncherView = React.createClass({
getInitialState: function() { getInitialState: function() {
return { return {
currentItemPath: '', currentItemPath: '',
currentItem: null currentItem: null,
lastClickTimestamp: 0
}; };
}, },
@ -90,6 +93,12 @@ var LauncherView = React.createClass({
logger.debug(item); logger.debug(item);
var clickDeltaTime = Date.now() - this.state.lastClickTimestamp;
if( clickDeltaTime < MIN_CLICK_DELTATIME ) {
logger.debug('Item clicked within %sms. No action.', MIN_CLICK_DELTATIME);
return;
}
if(item.items) { if(item.items) {
this.play(this.refs.appList, 'slide-out-left 250ms ease-in-out') this.play(this.refs.appList, 'slide-out-left 250ms ease-in-out')
@ -117,6 +126,8 @@ var LauncherView = React.createClass({
logger.info('No action associated with item "'+item.label+'".'); logger.info('No action associated with item "'+item.label+'".');
} }
this.setState({ lastClickTimestamp: Date.now() });
}, },
_getItemByPath: function(itemPath, rootItem) { _getItemByPath: function(itemPath, rootItem) {