Browse Source

[RN] Change default WelcomeScreen tab and persist user choice (coding style)

master
Lyubo Marinov 6 years ago
parent
commit
0d3fac7c0f

+ 3
- 3
ios/app/src/Info.plist View File

@@ -56,13 +56,13 @@
56 56
 		</dict>
57 57
 	</dict>
58 58
 	<key>NSCalendarsUsageDescription</key>
59
-	<string>See your scheduled conferences in the app.</string>
59
+	<string>See your scheduled meetings in the app.</string>
60 60
 	<key>NSCameraUsageDescription</key>
61
-	<string>Participate in conferences with video.</string>
61
+	<string>Participate in meetings with video.</string>
62 62
 	<key>NSLocationWhenInUseUsageDescription</key>
63 63
 	<string></string>
64 64
 	<key>NSMicrophoneUsageDescription</key>
65
-	<string>Participate in conferences with voice.</string>
65
+	<string>Participate in meetings with voice.</string>
66 66
 	<key>UIBackgroundModes</key>
67 67
 	<array>
68 68
 		<string>audio</string>

+ 1
- 1
lang/main.json View File

@@ -608,7 +608,7 @@
608 608
         "now": "Now",
609 609
         "ongoingMeeting": "ongoing meeting",
610 610
         "permissionButton": "Open settings",
611
-        "permissionMessage": "Calendar permission is required to list your meetings in the app."
611
+        "permissionMessage": "The Calendar permission is required to see your meetings in the app."
612 612
     },
613 613
     "recentList": {
614 614
         "today": "Today",

+ 43
- 44
react/features/base/react/components/native/AbstractPagedList.js View File

@@ -5,11 +5,14 @@ import { View } from 'react-native';
5 5
 
6 6
 import styles from './styles';
7 7
 
8
+/**
9
+ * The type of the React {@code Component} props of {@link AbstractPagedList}.
10
+ */
8 11
 type Props = {
9 12
 
10 13
     /**
11
-     * The index (starting from 0) of the page that should be rendered
12
-     * active as default.
14
+     * The zero-based index of the page that should be rendered (selected) by
15
+     * default.
13 16
      */
14 17
     defaultPage: number,
15 18
 
@@ -30,16 +33,20 @@ type Props = {
30 33
 
31 34
     /**
32 35
      * The pages of the PagedList component to be rendered.
33
-     * Note: page.component may be undefined and then they don't need to be
34
-     * rendered.
36
+     *
37
+     * Note: An element's {@code component} may be {@code undefined} and then it
38
+     * won't need to be rendered.
35 39
      */
36 40
     pages: Array<{
37
-        component: Object,
41
+        component: ?Object,
38 42
         icon: string | number,
39 43
         title: string
40 44
     }>
41 45
 };
42 46
 
47
+/**
48
+ * The type of the React {@code Component} state of {@link AbstractPagedList}.
49
+ */
43 50
 type State = {
44 51
 
45 52
     /**
@@ -53,7 +60,7 @@ type State = {
53 60
  */
54 61
 export default class AbstractPagedList extends Component<Props, State> {
55 62
     /**
56
-     * Constructor of the component.
63
+     * Initializes a new {@code AbstractPagedList} instance.
57 64
      *
58 65
      * @inheritdoc
59 66
      */
@@ -63,15 +70,19 @@ export default class AbstractPagedList extends Component<Props, State> {
63 70
         this.state = {
64 71
             pageIndex: this._validatePageIndex(props.defaultPage)
65 72
         };
73
+
74
+        // Bind event handlers so they are only bound once per instance.
75
+        this._maybeRefreshSelectedPage
76
+            = this._maybeRefreshSelectedPage.bind(this);
66 77
     }
67 78
 
68 79
     /**
69
-     * Implements React's {@code Component} componentDidMount.
80
+     * Implements React's {@link Component#componentDidMount}.
70 81
      *
71 82
      * @inheritdoc
72 83
      */
73 84
     componentDidMount() {
74
-        this._maybeRefreshActivePage();
85
+        this._maybeRefreshSelectedPage();
75 86
     }
76 87
 
77 88
     /**
@@ -80,8 +91,8 @@ export default class AbstractPagedList extends Component<Props, State> {
80 91
      * @inheritdoc
81 92
      */
82 93
     render() {
83
-        const { disabled, pages } = this.props;
84
-        const enabledPages = pages.filter(page => page.component);
94
+        const { disabled } = this.props;
95
+        const pages = this.props.pages.filter(({ component }) => component);
85 96
 
86 97
         return (
87 98
             <View
@@ -90,35 +101,24 @@ export default class AbstractPagedList extends Component<Props, State> {
90 101
                     disabled ? styles.pagedListContainerDisabled : null
91 102
                 ] }>
92 103
                 {
93
-                    enabledPages.length > 1
104
+                    pages.length > 1
94 105
                         ? this._renderPagedList(disabled)
95
-                        : enabledPages.length === 1
106
+                        : pages.length === 1
96 107
                             ? React.createElement(
97
-                                /* type */ enabledPages[0].component,
108
+
109
+                                // $FlowExpectedError
110
+                                /* type */ pages[0].component,
98 111
                                 /* props */ {
99 112
                                     disabled,
100 113
                                     style: styles.pagedList
101
-                                }) : null
114
+                                })
115
+                            : null
102 116
                 }
103 117
             </View>
104 118
         );
105 119
     }
106 120
 
107
-    _platformSpecificPageSelect: number => void
108
-
109
-    /**
110
-     * Method to be overriden by the components implementing this abstract class
111
-     * to handle platform specific actions on page select.
112
-     *
113
-     * @protected
114
-     * @param {number} pageIndex - The selected page index.
115
-     * @returns {void}
116
-     */
117
-    _platformSpecificPageSelect(pageIndex) {
118
-        this._selectPage(pageIndex);
119
-    }
120
-
121
-    _maybeRefreshActivePage: () => void
121
+    _maybeRefreshSelectedPage: () => void;
122 122
 
123 123
     /**
124 124
      * Components that this PagedList displays may have a refresh function to
@@ -128,13 +128,15 @@ export default class AbstractPagedList extends Component<Props, State> {
128 128
      * @private
129 129
      * @returns {void}
130 130
      */
131
-    _maybeRefreshActivePage() {
131
+    _maybeRefreshSelectedPage() {
132 132
         const selectedPage = this.props.pages[this.state.pageIndex];
133
+        let component;
133 134
 
134
-        if (selectedPage && selectedPage.component) {
135
-            const { refresh } = selectedPage.component;
135
+        if (selectedPage && (component = selectedPage.component)) {
136
+            const { refresh } = component;
136 137
 
137
-            typeof refresh === 'function' && refresh(this.props.dispatch);
138
+            typeof refresh === 'function'
139
+                && refresh.call(component, this.props.dispatch);
138 140
         }
139 141
     }
140 142
 
@@ -145,25 +147,22 @@ export default class AbstractPagedList extends Component<Props, State> {
145 147
     /**
146 148
      * Sets the selected page.
147 149
      *
148
-     * @param {number} pageIndex - The index of the active page.
150
+     * @param {number} pageIndex - The index of the selected page.
149 151
      * @protected
150 152
      * @returns {void}
151 153
      */
152 154
     _selectPage(pageIndex: number) {
153
-        const validatedPageIndex = this._validatePageIndex(pageIndex);
155
+        // eslint-disable-next-line no-param-reassign
156
+        pageIndex = this._validatePageIndex(pageIndex);
154 157
 
155 158
         const { onSelectPage } = this.props;
156 159
 
157
-        if (typeof onSelectPage === 'function') {
158
-            onSelectPage(validatedPageIndex);
159
-        }
160
+        typeof onSelectPage === 'function' && onSelectPage(pageIndex);
160 161
 
161
-        this.setState({
162
-            pageIndex: validatedPageIndex
163
-        }, () => this._maybeRefreshActivePage());
162
+        this.setState({ pageIndex }, this._maybeRefreshSelectedPage);
164 163
     }
165 164
 
166
-    _validatePageIndex: number => number
165
+    _validatePageIndex: number => number;
167 166
 
168 167
     /**
169 168
      * Validates the requested page index and returns a safe value.
@@ -173,10 +172,10 @@ export default class AbstractPagedList extends Component<Props, State> {
173 172
      * @returns {number}
174 173
      */
175 174
     _validatePageIndex(pageIndex) {
176
-        // pageIndex may point to a non existing page if some of the pages are
175
+        // pageIndex may point to a non-existing page if some of the pages are
177 176
         // disabled (their component property is undefined).
178 177
         const maxPageIndex
179
-            = this.props.pages.filter(page => page.component).length - 1;
178
+            = this.props.pages.filter(({ component }) => component).length - 1;
180 179
 
181 180
         return Math.max(0, Math.min(maxPageIndex, pageIndex));
182 181
     }

+ 0
- 12
react/features/base/react/components/native/PagedList.android.js View File

@@ -86,18 +86,6 @@ class PagedList extends AbstractPagedList {
86 86
         }
87 87
     }
88 88
 
89
-    /**
90
-     * Platform specific actions to run on page select.
91
-     *
92
-     * @private
93
-     * @param {number} pageIndex - The selected page index.
94
-     * @returns {void}
95
-     */
96
-    _platformSpecificPageSelect(pageIndex) {
97
-        this._viewPager.setPage(pageIndex);
98
-        this._selectPage(pageIndex);
99
-    }
100
-
101 89
     /**
102 90
      * Renders a single page of the page list.
103 91
      *

+ 2
- 2
react/features/calendar-sync/actions.js View File

@@ -1,9 +1,9 @@
1 1
 // @flow
2 2
 
3 3
 import {
4
+    REFRESH_CALENDAR,
4 5
     SET_CALENDAR_AUTHORIZATION,
5
-    SET_CALENDAR_EVENTS,
6
-    REFRESH_CALENDAR
6
+    SET_CALENDAR_EVENTS
7 7
 } from './actionTypes';
8 8
 
9 9
 /**

+ 41
- 39
react/features/calendar-sync/components/MeetingList.native.js View File

@@ -21,7 +21,7 @@ type Props = {
21 21
     /**
22 22
      * The current state of the calendar access permission.
23 23
      */
24
-    _authorization: string,
24
+    _authorization: ?string,
25 25
 
26 26
     /**
27 27
      * The calendar event list.
@@ -73,7 +73,7 @@ class MeetingList extends Component<Props> {
73 73
     }
74 74
 
75 75
     /**
76
-     * Constructor of the MeetingList component.
76
+     * Initializes a new {@code MeetingList} instance.
77 77
      *
78 78
      * @inheritdoc
79 79
      */
@@ -85,32 +85,26 @@ class MeetingList extends Component<Props> {
85 85
             = this._getRenderListEmptyComponent.bind(this);
86 86
         this._onPress = this._onPress.bind(this);
87 87
         this._onRefresh = this._onRefresh.bind(this);
88
+        this._toDateString = this._toDateString.bind(this);
88 89
         this._toDisplayableItem = this._toDisplayableItem.bind(this);
89 90
         this._toDisplayableList = this._toDisplayableList.bind(this);
90
-        this._toDateString = this._toDateString.bind(this);
91 91
     }
92 92
 
93 93
     /**
94
-     * Implements the React Components's render.
94
+     * Implements React's {@link Component#render}.
95 95
      *
96 96
      * @inheritdoc
97 97
      */
98 98
     render() {
99
-        const { _authorization, disabled } = this.props;
99
+        const { disabled } = this.props;
100 100
 
101 101
         return (
102 102
             <NavigateSectionList
103 103
                 disabled = { disabled }
104 104
                 onPress = { this._onPress }
105 105
                 onRefresh = { this._onRefresh }
106
-
107
-                // If we don't provide a list specific renderListEmptyComponent,
108
-                // then the default empty component of the NavigateSectionList
109
-                // will be rendered, which (atm) is a simple "Pull to refresh"
110
-                // message.
111 106
                 renderListEmptyComponent
112
-                    = { _authorization === 'denied'
113
-                        ? this._getRenderListEmptyComponent() : undefined }
107
+                    = { this._getRenderListEmptyComponent() }
114 108
                 sections = { this._toDisplayableList() } />
115 109
         );
116 110
     }
@@ -122,10 +116,17 @@ class MeetingList extends Component<Props> {
122 116
      * of the default one in the {@link NavigateSectionList}.
123 117
      *
124 118
      * @private
125
-     * @returns {Function}
119
+     * @returns {?React$Component}
126 120
      */
127 121
     _getRenderListEmptyComponent() {
128
-        const { t } = this.props;
122
+        const { _authorization, t } = this.props;
123
+
124
+        // If we don't provide a list specific renderListEmptyComponent, then
125
+        // the default empty component of the NavigateSectionList will be
126
+        // rendered, which (atm) is a simple "Pull to refresh" message.
127
+        if (_authorization !== 'denied') {
128
+            return undefined;
129
+        }
129 130
 
130 131
         return (
131 132
             <View style = { styles.noPermissionMessageView }>
@@ -168,6 +169,24 @@ class MeetingList extends Component<Props> {
168 169
         this.props.dispatch(refreshCalendar(true));
169 170
     }
170 171
 
172
+    _toDateString: Object => string;
173
+
174
+    /**
175
+     * Generates a date (interval) string for a given event.
176
+     *
177
+     * @param {Object} event - The event.
178
+     * @private
179
+     * @returns {string}
180
+     */
181
+    _toDateString(event) {
182
+        const startDateTime
183
+            = getLocalizedDateFormatter(event.startDate).format('lll');
184
+        const endTime
185
+            = getLocalizedDateFormatter(event.endDate).format('LT');
186
+
187
+        return `${startDateTime} - ${endTime}`;
188
+    }
189
+
171 190
     _toDisplayableItem: Object => Object;
172 191
 
173 192
     /**
@@ -199,7 +218,9 @@ class MeetingList extends Component<Props> {
199 218
      */
200 219
     _toDisplayableList() {
201 220
         const { _eventList, t } = this.props;
221
+
202 222
         const now = Date.now();
223
+
203 224
         const { createSection } = NavigateSectionList;
204 225
         const nowSection = createSection(t('calendarSync.now'), 'now');
205 226
         const nextSection = createSection(t('calendarSync.next'), 'next');
@@ -227,31 +248,11 @@ class MeetingList extends Component<Props> {
227 248
             nextSection,
228 249
             laterSection
229 250
         ]) {
230
-            if (section.data.length) {
231
-                sectionList.push(section);
232
-            }
251
+            section.data.length && sectionList.push(section);
233 252
         }
234 253
 
235 254
         return sectionList;
236 255
     }
237
-
238
-    _toDateString: Object => string;
239
-
240
-    /**
241
-     * Generates a date (interval) string for a given event.
242
-     *
243
-     * @param {Object} event - The event.
244
-     * @private
245
-     * @returns {string}
246
-     */
247
-    _toDateString(event) {
248
-        const startDateTime
249
-            = getLocalizedDateFormatter(event.startDate).format('lll');
250
-        const endTime
251
-            = getLocalizedDateFormatter(event.endDate).format('LT');
252
-
253
-        return `${startDateTime} - ${endTime}`;
254
-    }
255 256
 }
256 257
 
257 258
 /**
@@ -259,15 +260,16 @@ class MeetingList extends Component<Props> {
259 260
  *
260 261
  * @param {Object} state - The redux state.
261 262
  * @returns {{
262
- *     _eventList: Array
263
+ *     _authorization: ?string,
264
+ *     _eventList: Array<Object>
263 265
  * }}
264 266
  */
265 267
 function _mapStateToProps(state: Object) {
266
-    const calendarSyncState = state['features/calendar-sync'];
268
+    const { authorization, events } = state['features/calendar-sync'];
267 269
 
268 270
     return {
269
-        _authorization: calendarSyncState.authorization,
270
-        _eventList: calendarSyncState.events
271
+        _authorization: authorization,
272
+        _eventList: events
271 273
     };
272 274
 }
273 275
 

+ 2
- 1
react/features/calendar-sync/components/styles.js View File

@@ -34,7 +34,8 @@ export default createStyleSheet({
34 34
      */
35 35
     noPermissionMessageText: {
36 36
         backgroundColor: 'transparent',
37
-        color: 'rgba(255, 255, 255, 0.6)'
37
+        color: 'rgba(255, 255, 255, 0.6)',
38
+        textAlign: 'center'
38 39
     },
39 40
 
40 41
     /**

+ 2
- 8
react/features/calendar-sync/reducer.js View File

@@ -43,16 +43,10 @@ CALENDAR_ENABLED
43 43
             break;
44 44
 
45 45
         case SET_CALENDAR_AUTHORIZATION:
46
-            return {
47
-                ...state,
48
-                authorization: action.authorization
49
-            };
46
+            return set(state, 'authorization', action.authorization);
50 47
 
51 48
         case SET_CALENDAR_EVENTS:
52
-            return {
53
-                ...state,
54
-                events: action.events
55
-            };
49
+            return set(state, 'events', action.events);
56 50
         }
57 51
 
58 52
         return state;

+ 4
- 4
react/features/welcome/actionTypes.js View File

@@ -12,13 +12,13 @@
12 12
 export const SET_SIDEBAR_VISIBLE = Symbol('SET_SIDEBAR_VISIBLE');
13 13
 
14 14
 /**
15
- * Action to update the default page index of the {@code WelcomePageLists}
16
- * component.
15
+ * The type of (redux) action to set the default page index of
16
+ * {@link WelcomePageLists}.
17 17
  *
18 18
  * {
19
- *     type: SET_WELCOME_PAGE_LIST_DEFAULT_PAGE,
19
+ *     type: SET_WELCOME_PAGE_LISTS_DEFAULT_PAGE,
20 20
  *     pageIndex: number
21 21
  * }
22 22
  */
23
-export const SET_WELCOME_PAGE_LIST_DEFAULT_PAGE
23
+export const SET_WELCOME_PAGE_LISTS_DEFAULT_PAGE
24 24
     = Symbol('SET_WELCOME_PAGE_LIST_DEFAULT_PAGE');

+ 16
- 17
react/features/welcome/actions.js View File

@@ -2,39 +2,38 @@
2 2
 
3 3
 import {
4 4
     SET_SIDEBAR_VISIBLE,
5
-    SET_WELCOME_PAGE_LIST_DEFAULT_PAGE
5
+    SET_WELCOME_PAGE_LISTS_DEFAULT_PAGE
6 6
 } from './actionTypes';
7 7
 
8 8
 /**
9
- * Action to update the default page index of the {@code WelcomePageLists}
10
- * component.
9
+ * Sets the visibility of {@link WelcomePageSideBar}.
11 10
  *
12
- * @param {number} pageIndex - The index of the selected page.
11
+ * @param {boolean} visible - If the {@code WelcomePageSideBar} is to be made
12
+ * visible, {@code true}; otherwise, {@code false}.
13 13
  * @returns {{
14
- *     type: SET_WELCOME_PAGE_LIST_DEFAULT_PAGE,
15
- *     pageIndex: number
14
+ *     type: SET_SIDEBAR_VISIBLE,
15
+ *     visible: boolean
16 16
  * }}
17 17
  */
18
-export function setWelcomePageListDefaultPage(pageIndex: number) {
18
+export function setSideBarVisible(visible: boolean) {
19 19
     return {
20
-        type: SET_WELCOME_PAGE_LIST_DEFAULT_PAGE,
21
-        pageIndex
20
+        type: SET_SIDEBAR_VISIBLE,
21
+        visible
22 22
     };
23 23
 }
24 24
 
25 25
 /**
26
- * Sets the visibility of {@link WelcomePageSideBar}.
26
+ * Sets the default page index of {@link WelcomePageLists}.
27 27
  *
28
- * @param {boolean} visible - If the {@code WelcomePageSideBar} is to be made
29
- * visible, {@code true}; otherwise, {@code false}.
28
+ * @param {number} pageIndex - The index of the default page.
30 29
  * @returns {{
31
- *     type: SET_SIDEBAR_VISIBLE,
32
- *     visible: boolean
30
+ *     type: SET_WELCOME_PAGE_LISTS_DEFAULT_PAGE,
31
+ *     pageIndex: number
33 32
  * }}
34 33
  */
35
-export function setSideBarVisible(visible: boolean) {
34
+export function setWelcomePageListsDefaultPage(pageIndex: number) {
36 35
     return {
37
-        type: SET_SIDEBAR_VISIBLE,
38
-        visible
36
+        type: SET_WELCOME_PAGE_LISTS_DEFAULT_PAGE,
37
+        pageIndex
39 38
     };
40 39
 }

+ 41
- 32
react/features/welcome/components/WelcomePageLists.js View File

@@ -9,8 +9,11 @@ import { PagedList } from '../../base/react';
9 9
 import { MeetingList } from '../../calendar-sync';
10 10
 import { RecentList } from '../../recent-list';
11 11
 
12
-import { setWelcomePageListDefaultPage } from '../actions';
12
+import { setWelcomePageListsDefaultPage } from '../actions';
13 13
 
14
+/**
15
+ * The type of the React {@code Component} props of {@link WelcomePageLists}.
16
+ */
14 17
 type Props = {
15 18
 
16 19
     /**
@@ -50,17 +53,19 @@ const IOS_RECENT_LIST_ICON = require('../../../../images/history.png');
50 53
 class WelcomePageLists extends Component<Props> {
51 54
     /**
52 55
      * The pages to be rendered.
53
-     * Note: The component field may be undefined if a feature (such as
54
-     * Calendar) is disabled, and that means that the page must not be rendered.
56
+     *
57
+     * Note: An element's  {@code component} may be {@code undefined} if a
58
+     * feature (such as Calendar) is disabled, and that means that the page must
59
+     * not be rendered.
55 60
      */
56 61
     pages: Array<{
57
-        component: Object,
62
+        component: ?Object,
58 63
         icon: string | number,
59 64
         title: string
60
-    }>
65
+    }>;
61 66
 
62 67
     /**
63
-     * Component contructor.
68
+     * Initializes a new {@code WelcomePageLists} instance.
64 69
      *
65 70
      * @inheritdoc
66 71
      */
@@ -68,28 +73,32 @@ class WelcomePageLists extends Component<Props> {
68 73
         super(props);
69 74
 
70 75
         const { t } = props;
71
-        const isAndroid = Platform.OS === 'android';
72
-
73
-        this.pages = [ {
74
-            component: RecentList,
75
-            icon: isAndroid ? 'restore' : IOS_RECENT_LIST_ICON,
76
-            title: t('welcomepage.recentList')
77
-        }, {
78
-            component: MeetingList,
79
-            icon: isAndroid ? 'event_note' : IOS_CALENDAR_ICON,
80
-            title: t('welcomepage.calendar')
81
-        } ];
82
-
76
+        const android = Platform.OS === 'android';
77
+
78
+        this.pages = [
79
+            {
80
+                component: RecentList,
81
+                icon: android ? 'restore' : IOS_RECENT_LIST_ICON,
82
+                title: t('welcomepage.recentList')
83
+            },
84
+            {
85
+                component: MeetingList,
86
+                icon: android ? 'event_note' : IOS_CALENDAR_ICON,
87
+                title: t('welcomepage.calendar')
88
+            }
89
+        ];
90
+
91
+        // Bind event handlers so they are only bound once per instance.
83 92
         this._onSelectPage = this._onSelectPage.bind(this);
84 93
     }
85 94
 
86 95
     /**
87
-     * Implements React Component's render.
96
+     * Implements React's {@link Component#render}.
88 97
      *
89 98
      * @inheritdoc
90 99
      */
91 100
     render() {
92
-        const { disabled, _defaultPage } = this.props;
101
+        const { _defaultPage } = this.props;
93 102
 
94 103
         if (typeof _defaultPage === 'undefined') {
95 104
             return null;
@@ -98,13 +107,13 @@ class WelcomePageLists extends Component<Props> {
98 107
         return (
99 108
             <PagedList
100 109
                 defaultPage = { _defaultPage }
101
-                disabled = { disabled }
110
+                disabled = { this.props.disabled }
102 111
                 onSelectPage = { this._onSelectPage }
103 112
                 pages = { this.pages } />
104 113
         );
105 114
     }
106 115
 
107
-    _onSelectPage: number => void
116
+    _onSelectPage: number => void;
108 117
 
109 118
     /**
110 119
      * Callback for the {@code PagedList} page select action.
@@ -114,9 +123,7 @@ class WelcomePageLists extends Component<Props> {
114 123
      * @returns {void}
115 124
      */
116 125
     _onSelectPage(pageIndex) {
117
-        const { dispatch } = this.props;
118
-
119
-        dispatch(setWelcomePageListDefaultPage(pageIndex));
126
+        this.props.dispatch(setWelcomePageListsDefaultPage(pageIndex));
120 127
     }
121 128
 }
122 129
 
@@ -127,18 +134,20 @@ class WelcomePageLists extends Component<Props> {
127 134
  * @param {Object} state - The redux state.
128 135
  * @protected
129 136
  * @returns {{
130
- *     _hasRecentListEntries: boolean
137
+ *     _defaultPage: number
131 138
  * }}
132 139
  */
133 140
 function _mapStateToProps(state: Object) {
134
-    const { defaultPage } = state['features/welcome'];
135
-    const recentList = state['features/recent-list'];
136
-    const _hasRecentListEntries = Boolean(recentList && recentList.length);
141
+    let { defaultPage } = state['features/welcome'];
142
+
143
+    if (typeof defaultPage === 'undefined') {
144
+        const recentList = state['features/recent-list'];
145
+
146
+        defaultPage = recentList && recentList.length ? 0 : 1;
147
+    }
137 148
 
138 149
     return {
139
-        _defaultPage: defaultPage === 'undefined'
140
-            ? _hasRecentListEntries ? 0 : 1
141
-            : defaultPage
150
+        _defaultPage: defaultPage
142 151
     };
143 152
 }
144 153
 

+ 12
- 17
react/features/welcome/reducer.js View File

@@ -1,42 +1,37 @@
1 1
 // @flow
2 2
 
3
-import { ReducerRegistry } from '../base/redux';
3
+import { ReducerRegistry, set } from '../base/redux';
4 4
 import { PersistenceRegistry } from '../base/storage';
5
+
5 6
 import {
6 7
     SET_SIDEBAR_VISIBLE,
7
-    SET_WELCOME_PAGE_LIST_DEFAULT_PAGE
8
+    SET_WELCOME_PAGE_LISTS_DEFAULT_PAGE
8 9
 } from './actionTypes';
9 10
 
10 11
 /**
11
- * The Redux store name this feature uses.
12
+ * The name of the redux store/state property which is the root of the redux
13
+ * state of the feature {@code welcome}.
12 14
  */
13 15
 const STORE_NAME = 'features/welcome';
14 16
 
15 17
 /**
16
- * Sets up the persistence of the feature {@code features/welcome}.
18
+ * Sets up the persistence of the feature {@code welcome}.
17 19
  */
18 20
 PersistenceRegistry.register(STORE_NAME, {
19 21
     defaultPage: true
20 22
 });
21 23
 
22 24
 /**
23
- * Reduces redux actions for the purposes of {@code features/welcome}.
25
+ * Reduces redux actions for the purposes of the feature {@code welcome}.
24 26
  */
25 27
 ReducerRegistry.register(STORE_NAME, (state = {}, action) => {
26 28
     switch (action.type) {
27 29
     case SET_SIDEBAR_VISIBLE:
28
-        return {
29
-            ...state,
30
-            sideBarVisible: action.visible
31
-        };
32
-
33
-    case SET_WELCOME_PAGE_LIST_DEFAULT_PAGE:
34
-        return {
35
-            ...state,
36
-            defaultPage: action.pageIndex
37
-        };
30
+        return set(state, 'sideBarVisible', action.visible);
38 31
 
39
-    default:
40
-        return state;
32
+    case SET_WELCOME_PAGE_LISTS_DEFAULT_PAGE:
33
+        return set(state, 'defaultPage', action.pageIndex);
41 34
     }
35
+
36
+    return state;
42 37
 });

Loading…
Cancel
Save