Browse Source

fix(toolbar) Fix toolbar always visible; refactors

- deprecate `INITIAL_TOOLBAR_TIMEOUT`, `TOOLBAR_ALWAYS_VISIBLE`, `TOOLBAR_TIMEOUT`
master
hmuresan 3 years ago
parent
commit
cd4c940107

+ 13
- 0
config.js View File

545
     //    '__end'
545
     //    '__end'
546
     // ],
546
     // ],
547
 
547
 
548
+    // Holds values related to toolbar visibility control.
549
+    // toolbarConfig: {
550
+    //     // Moved from interfaceConfig.INITIAL_TOOLBAR_TIMEOUT
551
+    //     // The initial numer of miliseconds for the toolbar buttons to be visible on screen.
552
+    //     initialTimeout: 20000,
553
+    //     // Moved from interfaceConfig.TOOLBAR_TIMEOUT
554
+    //     // Number of miliseconds for the toolbar buttons to be visible on screen.
555
+    //     timeout: 4000,
556
+    //     // Moved from interfaceConfig.TOOLBAR_ALWAYS_VISIBLE
557
+    //     // Whether toolbar should be always visible or should hide after x miliseconds.
558
+    //     alwaysVisible: false
559
+    // },
560
+
548
     // Toolbar buttons which have their click event exposed through the API on
561
     // Toolbar buttons which have their click event exposed through the API on
549
     // `toolbarButtonClicked` event instead of executing the normal click routine.
562
     // `toolbarButtonClicked` event instead of executing the normal click routine.
550
     // buttonsWithNotifyClick: [
563
     // buttonsWithNotifyClick: [

+ 13
- 3
interface_config.js View File

97
      */
97
      */
98
     HIDE_INVITE_MORE_HEADER: false,
98
     HIDE_INVITE_MORE_HEADER: false,
99
 
99
 
100
-    INITIAL_TOOLBAR_TIMEOUT: 20000,
100
+    /**
101
+     * DEPRECATED! Moved to config.js as `toolbarConfig.initialTimeout`.
102
+     */
103
+    // INITIAL_TOOLBAR_TIMEOUT: 20000,
104
+
101
     JITSI_WATERMARK_LINK: 'https://jitsi.org',
105
     JITSI_WATERMARK_LINK: 'https://jitsi.org',
102
 
106
 
103
     LANG_DETECTION: true, // Allow i18n to detect the system language
107
     LANG_DETECTION: true, // Allow i18n to detect the system language
183
      */
187
      */
184
     SUPPORT_URL: 'https://community.jitsi.org/',
188
     SUPPORT_URL: 'https://community.jitsi.org/',
185
 
189
 
186
-    TOOLBAR_ALWAYS_VISIBLE: false,
190
+    /**
191
+     * DEPRECATED! Moved to config.js as `toolbarConfig.alwaysVisible`.
192
+     */
193
+    // TOOLBAR_ALWAYS_VISIBLE: false,
187
 
194
 
188
     /**
195
     /**
189
      * DEPRECATED!
196
      * DEPRECATED!
191
      */
198
      */
192
     // TOOLBAR_BUTTONS: [],
199
     // TOOLBAR_BUTTONS: [],
193
 
200
 
194
-    TOOLBAR_TIMEOUT: 4000,
201
+    /**
202
+     * DEPRECATED! Moved to config.js as `toolbarConfig.timeout`.
203
+     */
204
+    // TOOLBAR_TIMEOUT: 4000,
195
 
205
 
196
     // Browsers, in addition to those which do not fully support WebRTC, that
206
     // Browsers, in addition to those which do not fully support WebRTC, that
197
     // are not supported and should show the unsupported browser page.
207
     // are not supported and should show the unsupported browser page.

+ 1
- 0
react/features/base/config/configWhitelist.js View File

188
     'subject',
188
     'subject',
189
     'testing',
189
     'testing',
190
     'toolbarButtons',
190
     'toolbarButtons',
191
+    'toolbarConfig',
191
     'useHostPageLocalStorage',
192
     'useHostPageLocalStorage',
192
     'useTurnUdp',
193
     'useTurnUdp',
193
     'videoQuality.persist',
194
     'videoQuality.persist',

+ 22
- 0
react/features/base/config/reducer.js View File

227
         newValue.toolbarButtons = interfaceConfig.TOOLBAR_BUTTONS;
227
         newValue.toolbarButtons = interfaceConfig.TOOLBAR_BUTTONS;
228
     }
228
     }
229
 
229
 
230
+    if (!oldValue.toolbarConfig) {
231
+        oldValue.toolbarConfig = {};
232
+    }
233
+
234
+    if (typeof oldValue.toolbarConfig.alwaysVisible !== 'boolean'
235
+        && typeof interfaceConfig === 'object'
236
+        && typeof interfaceConfig.TOOLBAR_ALWAYS_VISIBLE === 'boolean') {
237
+        newValue.toolbarConfig.alwaysVisible = interfaceConfig.TOOLBAR_ALWAYS_VISIBLE;
238
+    }
239
+
240
+    if (typeof oldValue.toolbarConfig.initialTimeout !== 'number'
241
+        && typeof interfaceConfig === 'object'
242
+        && typeof interfaceConfig.INITIAL_TOOLBAR_TIMEOUT === 'number') {
243
+        newValue.toolbarConfig.initialTimeout = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
244
+    }
245
+
246
+    if (typeof oldValue.toolbarConfig.timeout !== 'number'
247
+        && typeof interfaceConfig === 'object'
248
+        && typeof interfaceConfig.TOOLBAR_TIMEOUT === 'number') {
249
+        newValue.toolbarConfig.timeout = interfaceConfig.TOOLBAR_TIMEOUT;
250
+    }
251
+
230
     const filteredConferenceInfo = Object.keys(CONFERENCE_HEADER_MAPPING).filter(key => oldValue[key]);
252
     const filteredConferenceInfo = Object.keys(CONFERENCE_HEADER_MAPPING).filter(key => oldValue[key]);
231
 
253
 
232
     if (filteredConferenceInfo.length) {
254
     if (filteredConferenceInfo.length) {

+ 0
- 21
react/features/toolbox/actionTypes.js View File

55
  */
55
  */
56
 export const SET_TOOLBAR_HOVERED = 'SET_TOOLBAR_HOVERED';
56
 export const SET_TOOLBAR_HOVERED = 'SET_TOOLBAR_HOVERED';
57
 
57
 
58
-/**
59
- * The type of the action which sets the permanent visibility of the Toolbox.
60
- *
61
- * {
62
- *     type: SET_TOOLBOX_ALWAYS_VISIBLE,
63
- *     alwaysVisible: boolean
64
- * }
65
- */
66
-export const SET_TOOLBOX_ALWAYS_VISIBLE = 'SET_TOOLBOX_ALWAYS_VISIBLE';
67
-
68
 /**
58
 /**
69
  * The type of the (redux) action which enables/disables the Toolbox.
59
  * The type of the (redux) action which enables/disables the Toolbox.
70
  *
60
  *
87
  */
77
  */
88
 export const SET_TOOLBOX_TIMEOUT = 'SET_TOOLBOX_TIMEOUT';
78
 export const SET_TOOLBOX_TIMEOUT = 'SET_TOOLBOX_TIMEOUT';
89
 
79
 
90
-/**
91
- * The type of the action which sets the delay in milliseconds after which
92
- * the Toolbox visibility is to be changed.
93
- *
94
- * {
95
- *     type: SET_TOOLBOX_TIMEOUT_MS,
96
- *     timeoutMS: number
97
- * }
98
- */
99
-export const SET_TOOLBOX_TIMEOUT_MS = 'SET_TOOLBOX_TIMEOUT_MS';
100
-
101
 /**
80
 /**
102
  * The type of the (redux) action which shows/hides the Toolbox.
81
  * The type of the (redux) action which shows/hides the Toolbox.
103
  *
82
  *

+ 14
- 24
react/features/toolbox/actions.any.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
+import type { Dispatch } from 'redux';
4
+
3
 import {
5
 import {
4
-    SET_TOOLBOX_ALWAYS_VISIBLE,
5
     SET_TOOLBOX_ENABLED,
6
     SET_TOOLBOX_ENABLED,
6
     SET_TOOLBOX_VISIBLE
7
     SET_TOOLBOX_VISIBLE
7
 } from './actionTypes';
8
 } from './actionTypes';
8
 
9
 
9
-/**
10
- * Signals that always visible toolbars value should be changed.
11
- *
12
- * @param {boolean} alwaysVisible - Value to be set in redux store.
13
- * @returns {{
14
- *     type: SET_TOOLBOX_ALWAYS_VISIBLE,
15
- *     alwaysVisible: boolean
16
- * }}
17
- */
18
-export function setToolboxAlwaysVisible(alwaysVisible: boolean): Object {
19
-    return {
20
-        type: SET_TOOLBOX_ALWAYS_VISIBLE,
21
-        alwaysVisible
22
-    };
23
-}
24
-
25
 /**
10
 /**
26
  * Enables/disables the toolbox.
11
  * Enables/disables the toolbox.
27
  *
12
  *
42
  * Shows/hides the toolbox.
27
  * Shows/hides the toolbox.
43
  *
28
  *
44
  * @param {boolean} visible - True to show the toolbox or false to hide it.
29
  * @param {boolean} visible - True to show the toolbox or false to hide it.
45
- * @returns {{
46
- *     type: SET_TOOLBOX_VISIBLE,
47
- *     visible: boolean
48
- * }}
30
+ * @returns {Function}
49
  */
31
  */
50
 export function setToolboxVisible(visible: boolean): Object {
32
 export function setToolboxVisible(visible: boolean): Object {
51
-    return {
52
-        type: SET_TOOLBOX_VISIBLE,
53
-        visible
33
+    return (dispatch: Dispatch<any>, getState: Function) => {
34
+        const { toolbarConfig: { alwaysVisible } } = getState()['features/base/config'];
35
+
36
+        if (!visible && alwaysVisible) {
37
+            return;
38
+        }
39
+
40
+        dispatch({
41
+            type: SET_TOOLBOX_VISIBLE,
42
+            visible
43
+        });
54
     };
44
     };
55
 }
45
 }

+ 15
- 5
react/features/toolbox/actions.native.js View File

1
 // @flow
1
 // @flow
2
 
2
 
3
+import type { Dispatch } from 'redux';
4
+
3
 import { TOGGLE_TOOLBOX_VISIBLE } from './actionTypes';
5
 import { TOGGLE_TOOLBOX_VISIBLE } from './actionTypes';
4
 
6
 
5
 export * from './actions.any';
7
 export * from './actions.any';
7
 /**
9
 /**
8
  * Action to toggle the toolbox visibility.
10
  * Action to toggle the toolbox visibility.
9
  *
11
  *
10
- * @returns {{
11
- *     type: TOGGLE_TOOLBOX_VISIBLE
12
- * }}
12
+ * @returns {Function}
13
  */
13
  */
14
 export function toggleToolboxVisible() {
14
 export function toggleToolboxVisible() {
15
-    return {
16
-        type: TOGGLE_TOOLBOX_VISIBLE
15
+    return (dispatch: Dispatch<any>, getState: Function) => {
16
+        const state = getState();
17
+        const { toolbarConfig: { alwaysVisible } } = state['features/base/config'];
18
+        const { visible } = state['features/toolbox'];
19
+
20
+        if (visible && alwaysVisible) {
21
+            return;
22
+        }
23
+
24
+        dispatch({
25
+            type: TOGGLE_TOOLBOX_VISIBLE
26
+        });
17
     };
27
     };
18
 }
28
 }

+ 26
- 32
react/features/toolbox/actions.web.js View File

2
 
2
 
3
 import type { Dispatch } from 'redux';
3
 import type { Dispatch } from 'redux';
4
 
4
 
5
+import { overwriteConfig } from '../base/config';
5
 import { isLayoutTileView } from '../video-layout';
6
 import { isLayoutTileView } from '../video-layout';
6
 
7
 
7
 import {
8
 import {
11
     SET_OVERFLOW_DRAWER,
12
     SET_OVERFLOW_DRAWER,
12
     SET_OVERFLOW_MENU_VISIBLE,
13
     SET_OVERFLOW_MENU_VISIBLE,
13
     SET_TOOLBAR_HOVERED,
14
     SET_TOOLBAR_HOVERED,
14
-    SET_TOOLBOX_TIMEOUT,
15
-    SET_TOOLBOX_TIMEOUT_MS
15
+    SET_TOOLBOX_TIMEOUT
16
 } from './actionTypes';
16
 } from './actionTypes';
17
-import { setToolboxVisible } from './actions.any';
18
-
19
-declare var interfaceConfig: Object;
17
+import { setToolboxVisible } from './actions';
18
+import { getToolbarTimeout } from './functions';
20
 
19
 
21
 export * from './actions.any';
20
 export * from './actions.any';
22
 
21
 
28
  */
27
  */
29
 export function dockToolbox(dock: boolean): Function {
28
 export function dockToolbox(dock: boolean): Function {
30
     return (dispatch: Dispatch<any>, getState: Function) => {
29
     return (dispatch: Dispatch<any>, getState: Function) => {
31
-        const { timeoutMS, visible } = getState()['features/toolbox'];
30
+        const state = getState();
31
+        const { visible } = state['features/toolbox'];
32
+        const toolbarTimeout = getToolbarTimeout(state);
32
 
33
 
33
         if (dock) {
34
         if (dock) {
34
             // First make sure the toolbox is shown.
35
             // First make sure the toolbox is shown.
39
             dispatch(
40
             dispatch(
40
                 setToolboxTimeout(
41
                 setToolboxTimeout(
41
                     () => dispatch(hideToolbox()),
42
                     () => dispatch(hideToolbox()),
42
-                    timeoutMS));
43
+                    toolbarTimeout));
43
         } else {
44
         } else {
44
             dispatch(showToolbox());
45
             dispatch(showToolbox());
45
         }
46
         }
73
 export function hideToolbox(force: boolean = false): Function {
74
 export function hideToolbox(force: boolean = false): Function {
74
     return (dispatch: Dispatch<any>, getState: Function) => {
75
     return (dispatch: Dispatch<any>, getState: Function) => {
75
         const state = getState();
76
         const state = getState();
76
-        const {
77
-            alwaysVisible,
78
-            hovered,
79
-            timeoutMS
80
-        } = state['features/toolbox'];
77
+        const { toolbarConfig: { alwaysVisible } } = state['features/base/config'];
78
+        const { hovered } = state['features/toolbox'];
79
+        const toolbarTimeout = getToolbarTimeout(state);
81
 
80
 
82
         if (alwaysVisible) {
81
         if (alwaysVisible) {
83
             return;
82
             return;
95
             dispatch(
94
             dispatch(
96
                 setToolboxTimeout(
95
                 setToolboxTimeout(
97
                     () => dispatch(hideToolbox()),
96
                     () => dispatch(hideToolbox()),
98
-                    timeoutMS));
97
+                    toolbarTimeout));
99
         } else {
98
         } else {
100
             dispatch(setToolboxVisible(false));
99
             dispatch(setToolboxVisible(false));
101
         }
100
         }
128
     return (dispatch: Dispatch<any>, getState: Function) => {
127
     return (dispatch: Dispatch<any>, getState: Function) => {
129
         const state = getState();
128
         const state = getState();
130
         const {
129
         const {
131
-            alwaysVisible,
130
+            toolbarConfig: { initialTimeout, alwaysVisible },
131
+            toolbarConfig
132
+        } = state['features/base/config'];
133
+        const toolbarTimeout = getToolbarTimeout(state);
134
+
135
+        const {
132
             enabled,
136
             enabled,
133
-            timeoutMS,
134
             visible,
137
             visible,
135
             overflowDrawer
138
             overflowDrawer
136
         } = state['features/toolbox'];
139
         } = state['features/toolbox'];
143
             // If the Toolbox is always visible, there's no need for a timeout
146
             // If the Toolbox is always visible, there's no need for a timeout
144
             // to toggle its visibility.
147
             // to toggle its visibility.
145
             if (!alwaysVisible) {
148
             if (!alwaysVisible) {
149
+                if (typeof initialTimeout === 'number') {
150
+                    // reset `initialTimeout` once it is consumed once
151
+                    dispatch(overwriteConfig({ toolbarConfig: {
152
+                        ...toolbarConfig,
153
+                        initialTimeout: null
154
+                    } }));
155
+                }
146
                 dispatch(
156
                 dispatch(
147
                     setToolboxTimeout(
157
                     setToolboxTimeout(
148
                         () => dispatch(hideToolbox()),
158
                         () => dispatch(hideToolbox()),
149
-                        timeout || timeoutMS));
150
-                dispatch(setToolboxTimeoutMS(interfaceConfig.TOOLBAR_TIMEOUT));
159
+                        timeout || initialTimeout || toolbarTimeout));
151
             }
160
             }
152
         }
161
         }
153
     };
162
     };
250
     };
259
     };
251
 }
260
 }
252
 
261
 
253
-/**
254
- * Dispatches an action which sets new toolbox timeout value.
255
- *
256
- * @param {number} timeoutMS - Delay.
257
- * @returns {{
258
- *     type: SET_TOOLBOX_TIMEOUT_MS,
259
- *     timeoutMS: number
260
- * }}
261
- */
262
-export function setToolboxTimeoutMS(timeoutMS: number): Object {
263
-    return {
264
-        type: SET_TOOLBOX_TIMEOUT_MS,
265
-        timeoutMS
266
-    };
267
-}

+ 2
- 0
react/features/toolbox/constants.js View File

29
 ];
29
 ];
30
 
30
 
31
 export const NOT_APPLICABLE = 'N/A';
31
 export const NOT_APPLICABLE = 'N/A';
32
+
33
+export const TOOLBAR_TIMEOUT = 4000;

+ 4
- 2
react/features/toolbox/functions.native.js View File

60
  */
60
  */
61
 export function isToolboxVisible(stateful: Object | Function) {
61
 export function isToolboxVisible(stateful: Object | Function) {
62
     const state = toState(stateful);
62
     const state = toState(stateful);
63
-    const { alwaysVisible, enabled, visible } = state['features/toolbox'];
63
+    const { toolbarConfig: { alwaysVisible } } = state['features/base/config'];
64
+    const { enabled, visible } = state['features/toolbox'];
64
     const participantCount = getParticipantCountWithFake(state);
65
     const participantCount = getParticipantCountWithFake(state);
65
     const alwaysVisibleFlag = getFeatureFlag(state, TOOLBOX_ALWAYS_VISIBLE, false);
66
     const alwaysVisibleFlag = getFeatureFlag(state, TOOLBOX_ALWAYS_VISIBLE, false);
66
     const enabledFlag = getFeatureFlag(state, TOOLBOX_ENABLED, true);
67
     const enabledFlag = getFeatureFlag(state, TOOLBOX_ENABLED, true);
67
 
68
 
68
-    return enabledFlag && enabled && (alwaysVisible || visible || participantCount === 1 || alwaysVisibleFlag);
69
+    return enabledFlag && enabled
70
+        && (alwaysVisible || visible || participantCount === 1 || alwaysVisibleFlag);
69
 }
71
 }
70
 
72
 
71
 /**
73
 /**

+ 15
- 2
react/features/toolbox/functions.web.js View File

3
 import { getToolbarButtons } from '../base/config';
3
 import { getToolbarButtons } from '../base/config';
4
 import { hasAvailableDevices } from '../base/devices';
4
 import { hasAvailableDevices } from '../base/devices';
5
 
5
 
6
+import { TOOLBAR_TIMEOUT } from './constants';
7
+
6
 /**
8
 /**
7
  * Helper for getting the height of the toolbox.
9
  * Helper for getting the height of the toolbox.
8
  *
10
  *
37
  * otherwise.
39
  * otherwise.
38
  */
40
  */
39
 export function isToolboxVisible(state: Object) {
41
 export function isToolboxVisible(state: Object) {
40
-    const { iAmSipGateway } = state['features/base/config'];
42
+    const { iAmSipGateway, toolbarConfig: { alwaysVisible } } = state['features/base/config'];
41
     const {
43
     const {
42
-        alwaysVisible,
43
         timeoutID,
44
         timeoutID,
44
         visible
45
         visible
45
     } = state['features/toolbox'];
46
     } = state['features/toolbox'];
101
 export function isToolboxEnabled(state: Object) {
102
 export function isToolboxEnabled(state: Object) {
102
     return state['features/toolbox'].enabled;
103
     return state['features/toolbox'].enabled;
103
 }
104
 }
105
+
106
+/**
107
+ * Returns the toolbar timeout from config or the default value.
108
+ *
109
+ * @param {Object} state - The state from the Redux store.
110
+ * @returns {number} - Toolbar timeout in miliseconds.
111
+ */
112
+export function getToolbarTimeout(state: Object) {
113
+    const { toolbarConfig: { timeout } } = state['features/base/config'];
114
+
115
+    return timeout || TOOLBAR_TIMEOUT;
116
+}

+ 52
- 121
react/features/toolbox/reducer.js View File

8
     SET_OVERFLOW_DRAWER,
8
     SET_OVERFLOW_DRAWER,
9
     SET_OVERFLOW_MENU_VISIBLE,
9
     SET_OVERFLOW_MENU_VISIBLE,
10
     SET_TOOLBAR_HOVERED,
10
     SET_TOOLBAR_HOVERED,
11
-    SET_TOOLBOX_ALWAYS_VISIBLE,
12
     SET_TOOLBOX_ENABLED,
11
     SET_TOOLBOX_ENABLED,
13
     SET_TOOLBOX_TIMEOUT,
12
     SET_TOOLBOX_TIMEOUT,
14
-    SET_TOOLBOX_TIMEOUT_MS,
15
     SET_TOOLBOX_VISIBLE,
13
     SET_TOOLBOX_VISIBLE,
16
     TOGGLE_TOOLBOX_VISIBLE
14
     TOGGLE_TOOLBOX_VISIBLE
17
 } from './actionTypes';
15
 } from './actionTypes';
18
 
16
 
19
-declare var interfaceConfig: Object;
20
-
21
 /**
17
 /**
22
- * Returns initial state for toolbox's part of Redux store.
23
- *
24
- * @private
25
- * @returns {{
26
- *     alwaysVisible: boolean,
27
- *     enabled: boolean,
28
- *     hovered: boolean,
29
- *     overflowDrawer: boolean,
30
- *     overflowMenuVisible: boolean,
31
- *     timeoutID: number,
32
- *     timeoutMS: number,
33
- *     visible: boolean
34
- * }}
18
+ * Initial state of toolbox's part of Redux store.
35
  */
19
  */
36
-function _getInitialState() {
37
-    // Does the toolbar eventually fade out, or is it always visible?
38
-    let alwaysVisible = false;
39
-
40
-    // Toolbar (initial) visibility.
41
-    let visible = false;
42
-
43
-    // Default toolbox timeout for mobile app.
44
-    let timeoutMS = 5000;
45
-
46
-    if (typeof interfaceConfig !== 'undefined') {
47
-        if (interfaceConfig.INITIAL_TOOLBAR_TIMEOUT) {
48
-            timeoutMS = interfaceConfig.INITIAL_TOOLBAR_TIMEOUT;
49
-        }
50
-        if (typeof interfaceConfig.TOOLBAR_ALWAYS_VISIBLE !== 'undefined') {
51
-            alwaysVisible = interfaceConfig.TOOLBAR_ALWAYS_VISIBLE;
52
-        }
53
-    }
54
-
55
-    // When the toolbar is always visible, it must initially be visible too.
56
-    if (alwaysVisible === true) {
57
-        visible = true;
58
-    }
59
-
60
-    return {
61
-        /**
62
-         * The indicator which determines whether the Toolbox should always be
63
-         * visible. When false, the toolbar will fade out after timeoutMS.
64
-         *
65
-         * @type {boolean}
66
-         */
67
-        alwaysVisible,
68
-
69
-        /**
70
-         * The indicator which determines whether the Toolbox is enabled.
71
-         *
72
-         * @type {boolean}
73
-         */
74
-        enabled: true,
75
-
76
-        /**
77
-         * The indicator which determines whether a Toolbar in the Toolbox is
78
-         * hovered.
79
-         *
80
-         * @type {boolean}
81
-         */
82
-        hovered: false,
83
-
84
-        /**
85
-         * The indicator which determines whether the overflow menu(s) are to be displayed as drawers.
86
-         *
87
-         * @type {boolean}
88
-         */
89
-        overflowDrawer: false,
90
-
91
-        /**
92
-         * The indicator which determines whether the OverflowMenu is visible.
93
-         *
94
-         * @type {boolean}
95
-         */
96
-        overflowMenuVisible: false,
97
-
98
-        /**
99
-         * A number, non-zero value which identifies the timer created by a call
100
-         * to setTimeout() with timeoutMS.
101
-         *
102
-         * @type {number|null}
103
-         */
104
-        timeoutID: null,
105
-
106
-        /**
107
-         * The delay in milliseconds before timeoutID executes (after its
108
-         * initialization).
109
-         *
110
-         * @type {number}
111
-         */
112
-        timeoutMS,
113
-
114
-        /**
115
-         * The indicator that determines whether the Toolbox is visible.
116
-         *
117
-         * @type {boolean}
118
-         */
119
-        visible
120
-    };
121
-}
20
+const INITIAL_STATE = {
21
+
22
+    /**
23
+     * The indicator which determines whether the Toolbox is enabled.
24
+     *
25
+     * @type {boolean}
26
+     */
27
+    enabled: true,
28
+
29
+    /**
30
+     * The indicator which determines whether a Toolbar in the Toolbox is
31
+     * hovered.
32
+     *
33
+     * @type {boolean}
34
+     */
35
+    hovered: false,
36
+
37
+    /**
38
+     * The indicator which determines whether the overflow menu(s) are to be displayed as drawers.
39
+     *
40
+     * @type {boolean}
41
+     */
42
+    overflowDrawer: false,
43
+
44
+    /**
45
+     * The indicator which determines whether the OverflowMenu is visible.
46
+     *
47
+     * @type {boolean}
48
+     */
49
+    overflowMenuVisible: false,
50
+
51
+    /**
52
+     * A number, non-zero value which identifies the timer created by a call
53
+     * to setTimeout().
54
+     *
55
+     * @type {number|null}
56
+     */
57
+    timeoutID: null,
58
+
59
+
60
+    /**
61
+     * The indicator that determines whether the Toolbox is visible.
62
+     *
63
+     * @type {boolean}
64
+     */
65
+    visible: false
66
+};
122
 
67
 
123
 ReducerRegistry.register(
68
 ReducerRegistry.register(
124
     'features/toolbox',
69
     'features/toolbox',
125
-    (state: Object = _getInitialState(), action: Object) => {
70
+    (state: Object = INITIAL_STATE, action: Object) => {
126
         switch (action.type) {
71
         switch (action.type) {
127
         case CLEAR_TOOLBOX_TIMEOUT:
72
         case CLEAR_TOOLBOX_TIMEOUT:
128
             return {
73
             return {
154
                 hovered: action.hovered
99
                 hovered: action.hovered
155
             };
100
             };
156
 
101
 
157
-        case SET_TOOLBOX_ALWAYS_VISIBLE:
158
-            return {
159
-                ...state,
160
-                alwaysVisible: action.alwaysVisible,
161
-                visible: action.alwaysVisible === true ? true : state.visible
162
-            };
163
-
164
         case SET_TOOLBOX_ENABLED:
102
         case SET_TOOLBOX_ENABLED:
165
             return {
103
             return {
166
                 ...state,
104
                 ...state,
170
         case SET_TOOLBOX_TIMEOUT:
108
         case SET_TOOLBOX_TIMEOUT:
171
             return {
109
             return {
172
                 ...state,
110
                 ...state,
173
-                timeoutID: action.timeoutID,
174
-                timeoutMS: action.timeoutMS
175
-            };
176
-
177
-        case SET_TOOLBOX_TIMEOUT_MS:
178
-            return {
179
-                ...state,
180
-                timeoutMS: action.timeoutMS
111
+                timeoutID: action.timeoutID
181
             };
112
             };
182
 
113
 
183
         case SET_TOOLBOX_VISIBLE:
114
         case SET_TOOLBOX_VISIBLE:
184
-            return set(state, 'visible', state.alwaysVisible || action.visible);
115
+            return set(state, 'visible', action.visible);
185
 
116
 
186
         case TOGGLE_TOOLBOX_VISIBLE:
117
         case TOGGLE_TOOLBOX_VISIBLE:
187
-            return set(state, 'visible', state.alwaysVisible || !state.visible);
118
+            return set(state, 'visible', !state.visible);
188
         }
119
         }
189
 
120
 
190
         return state;
121
         return state;

Loading…
Cancel
Save