diff --git a/src/components/launcher/app-item.js b/src/components/launcher/app-item.js index 0734d03..ea27a25 100644 --- a/src/components/launcher/app-item.js +++ b/src/components/launcher/app-item.js @@ -1,8 +1,17 @@ var React = require('react'); +var logger = require('../../util/logger'); var AppIcon = require('../common/app-icon.js'); +var MIN_CLICK_DELTATIME = 2000; + module.exports = React.createClass({ + getInitialState: function() { + return { + lastClickTimestamp: 0 + }; + }, + propTypes: { item: React.PropTypes.object.isRequired, itemPath: React.PropTypes.oneOfType([ @@ -13,7 +22,15 @@ module.exports = React.createClass({ }, _onItemClick: function(evt) { + + var clickDeltaTime = Date.now() - this.state.lastClickTimestamp; + if( clickDeltaTime < MIN_CLICK_DELTATIME ) { + logger.debug('Item "%s" clicked within %sms. No action.', this.props.itemPath, MIN_CLICK_DELTATIME); + return; + } + evt.preventDefault(); + this.setState({ lastClickTimestamp: Date.now() }); this.props.onItemClick(evt, this.props.itemPath, this.props.item); }, diff --git a/src/components/launcher/launcher-view.js b/src/components/launcher/launcher-view.js index c6dea96..2530f9d 100644 --- a/src/components/launcher/launcher-view.js +++ b/src/components/launcher/launcher-view.js @@ -8,11 +8,9 @@ var connect = require('react-redux').connect; var logger = require('../../util/logger'); var CrossfadeImage = require('../common/crossfade-image'); var path = require('path'); -var _ = require('lodash'); var DEFAULT_PROFILE = path.join(__dirname, '..', '..', '..', 'default-profile.json'); var DEFAULT_BACKGROUND = ''; -var MIN_CLICK_DELTATIME = 2000; var LauncherView = React.createClass({ @@ -93,12 +91,6 @@ var LauncherView = React.createClass({ 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) { this.play(this.refs.appList, 'slide-out-left 250ms ease-in-out') @@ -126,8 +118,6 @@ var LauncherView = React.createClass({ logger.info('No action associated with item "'+item.label+'".'); } - this.setState({ lastClickTimestamp: Date.now() }); - }, _getItemByPath: function(itemPath, rootItem) {