Browse Source

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

William Petit 3 years ago
parent
commit
3ded369d09
1 changed files with 12 additions and 1 deletions
  1. 12
    1
      src/components/launcher/launcher-view.js

+ 12
- 1
src/components/launcher/launcher-view.js View File

@@ -8,9 +8,11 @@ var connect = require('react-redux').connect;
8 8
 var logger = require('../../util/logger');
9 9
 var CrossfadeImage = require('../common/crossfade-image');
10 10
 var path = require('path');
11
+var _ = require('lodash');
11 12
 
12 13
 var DEFAULT_PROFILE = path.join(__dirname, '..', '..', '..', 'default-profile.json');
13 14
 var DEFAULT_BACKGROUND = '';
15
+var MIN_CLICK_DELTATIME = 2000;
14 16
 
15 17
 var LauncherView = React.createClass({
16 18
 
@@ -19,7 +21,8 @@ var LauncherView = React.createClass({
19 21
   getInitialState: function() {
20 22
     return {
21 23
       currentItemPath: '',
22
-      currentItem: null
24
+      currentItem: null,
25
+      lastClickTimestamp: 0
23 26
     };
24 27
   },
25 28
 
@@ -90,6 +93,12 @@ var LauncherView = React.createClass({
90 93
 
91 94
     logger.debug(item);
92 95
 
96
+    var clickDeltaTime = Date.now() - this.state.lastClickTimestamp;
97
+    if( clickDeltaTime < MIN_CLICK_DELTATIME ) {
98
+      logger.debug('Item clicked within %sms. No action.', MIN_CLICK_DELTATIME);
99
+      return;
100
+    }
101
+
93 102
     if(item.items) {
94 103
 
95 104
       this.play(this.refs.appList, 'slide-out-left 250ms ease-in-out')
@@ -117,6 +126,8 @@ var LauncherView = React.createClass({
117 126
       logger.info('No action associated with item "'+item.label+'".');
118 127
     }
119 128
 
129
+    this.setState({ lastClickTimestamp: Date.now() });
130
+
120 131
   },
121 132
 
122 133
   _getItemByPath: function(itemPath, rootItem) {