Pārlūkot izejas kodu

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

master
Lyubo Marinov 7 gadus atpakaļ
vecāks
revīzija
0d3fac7c0f

+ 3
- 3
ios/app/src/Info.plist Parādīt failu

56
 		</dict>
56
 		</dict>
57
 	</dict>
57
 	</dict>
58
 	<key>NSCalendarsUsageDescription</key>
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
 	<key>NSCameraUsageDescription</key>
60
 	<key>NSCameraUsageDescription</key>
61
-	<string>Participate in conferences with video.</string>
61
+	<string>Participate in meetings with video.</string>
62
 	<key>NSLocationWhenInUseUsageDescription</key>
62
 	<key>NSLocationWhenInUseUsageDescription</key>
63
 	<string></string>
63
 	<string></string>
64
 	<key>NSMicrophoneUsageDescription</key>
64
 	<key>NSMicrophoneUsageDescription</key>
65
-	<string>Participate in conferences with voice.</string>
65
+	<string>Participate in meetings with voice.</string>
66
 	<key>UIBackgroundModes</key>
66
 	<key>UIBackgroundModes</key>
67
 	<array>
67
 	<array>
68
 		<string>audio</string>
68
 		<string>audio</string>

+ 1
- 1
lang/main.json Parādīt failu

608
         "now": "Now",
608
         "now": "Now",
609
         "ongoingMeeting": "ongoing meeting",
609
         "ongoingMeeting": "ongoing meeting",
610
         "permissionButton": "Open settings",
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
     "recentList": {
613
     "recentList": {
614
         "today": "Today",
614
         "today": "Today",

+ 43
- 44
react/features/base/react/components/native/AbstractPagedList.js Parādīt failu

5
 
5
 
6
 import styles from './styles';
6
 import styles from './styles';
7
 
7
 
8
+/**
9
+ * The type of the React {@code Component} props of {@link AbstractPagedList}.
10
+ */
8
 type Props = {
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
     defaultPage: number,
17
     defaultPage: number,
15
 
18
 
30
 
33
 
31
     /**
34
     /**
32
      * The pages of the PagedList component to be rendered.
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
     pages: Array<{
40
     pages: Array<{
37
-        component: Object,
41
+        component: ?Object,
38
         icon: string | number,
42
         icon: string | number,
39
         title: string
43
         title: string
40
     }>
44
     }>
41
 };
45
 };
42
 
46
 
47
+/**
48
+ * The type of the React {@code Component} state of {@link AbstractPagedList}.
49
+ */
43
 type State = {
50
 type State = {
44
 
51
 
45
     /**
52
     /**
53
  */
60
  */
54
 export default class AbstractPagedList extends Component<Props, State> {
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
      * @inheritdoc
65
      * @inheritdoc
59
      */
66
      */
63
         this.state = {
70
         this.state = {
64
             pageIndex: this._validatePageIndex(props.defaultPage)
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
      * @inheritdoc
82
      * @inheritdoc
72
      */
83
      */
73
     componentDidMount() {
84
     componentDidMount() {
74
-        this._maybeRefreshActivePage();
85
+        this._maybeRefreshSelectedPage();
75
     }
86
     }
76
 
87
 
77
     /**
88
     /**
80
      * @inheritdoc
91
      * @inheritdoc
81
      */
92
      */
82
     render() {
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
         return (
97
         return (
87
             <View
98
             <View
90
                     disabled ? styles.pagedListContainerDisabled : null
101
                     disabled ? styles.pagedListContainerDisabled : null
91
                 ] }>
102
                 ] }>
92
                 {
103
                 {
93
-                    enabledPages.length > 1
104
+                    pages.length > 1
94
                         ? this._renderPagedList(disabled)
105
                         ? this._renderPagedList(disabled)
95
-                        : enabledPages.length === 1
106
+                        : pages.length === 1
96
                             ? React.createElement(
107
                             ? React.createElement(
97
-                                /* type */ enabledPages[0].component,
108
+
109
+                                // $FlowExpectedError
110
+                                /* type */ pages[0].component,
98
                                 /* props */ {
111
                                 /* props */ {
99
                                     disabled,
112
                                     disabled,
100
                                     style: styles.pagedList
113
                                     style: styles.pagedList
101
-                                }) : null
114
+                                })
115
+                            : null
102
                 }
116
                 }
103
             </View>
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
      * Components that this PagedList displays may have a refresh function to
124
      * Components that this PagedList displays may have a refresh function to
128
      * @private
128
      * @private
129
      * @returns {void}
129
      * @returns {void}
130
      */
130
      */
131
-    _maybeRefreshActivePage() {
131
+    _maybeRefreshSelectedPage() {
132
         const selectedPage = this.props.pages[this.state.pageIndex];
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
     /**
147
     /**
146
      * Sets the selected page.
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
      * @protected
151
      * @protected
150
      * @returns {void}
152
      * @returns {void}
151
      */
153
      */
152
     _selectPage(pageIndex: number) {
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
         const { onSelectPage } = this.props;
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
      * Validates the requested page index and returns a safe value.
168
      * Validates the requested page index and returns a safe value.
173
      * @returns {number}
172
      * @returns {number}
174
      */
173
      */
175
     _validatePageIndex(pageIndex) {
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
         // disabled (their component property is undefined).
176
         // disabled (their component property is undefined).
178
         const maxPageIndex
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
         return Math.max(0, Math.min(maxPageIndex, pageIndex));
180
         return Math.max(0, Math.min(maxPageIndex, pageIndex));
182
     }
181
     }

+ 0
- 12
react/features/base/react/components/native/PagedList.android.js Parādīt failu

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
      * Renders a single page of the page list.
90
      * Renders a single page of the page list.
103
      *
91
      *

+ 2
- 2
react/features/calendar-sync/actions.js Parādīt failu

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

+ 41
- 39
react/features/calendar-sync/components/MeetingList.native.js Parādīt failu

21
     /**
21
     /**
22
      * The current state of the calendar access permission.
22
      * The current state of the calendar access permission.
23
      */
23
      */
24
-    _authorization: string,
24
+    _authorization: ?string,
25
 
25
 
26
     /**
26
     /**
27
      * The calendar event list.
27
      * The calendar event list.
73
     }
73
     }
74
 
74
 
75
     /**
75
     /**
76
-     * Constructor of the MeetingList component.
76
+     * Initializes a new {@code MeetingList} instance.
77
      *
77
      *
78
      * @inheritdoc
78
      * @inheritdoc
79
      */
79
      */
85
             = this._getRenderListEmptyComponent.bind(this);
85
             = this._getRenderListEmptyComponent.bind(this);
86
         this._onPress = this._onPress.bind(this);
86
         this._onPress = this._onPress.bind(this);
87
         this._onRefresh = this._onRefresh.bind(this);
87
         this._onRefresh = this._onRefresh.bind(this);
88
+        this._toDateString = this._toDateString.bind(this);
88
         this._toDisplayableItem = this._toDisplayableItem.bind(this);
89
         this._toDisplayableItem = this._toDisplayableItem.bind(this);
89
         this._toDisplayableList = this._toDisplayableList.bind(this);
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
      * @inheritdoc
96
      * @inheritdoc
97
      */
97
      */
98
     render() {
98
     render() {
99
-        const { _authorization, disabled } = this.props;
99
+        const { disabled } = this.props;
100
 
100
 
101
         return (
101
         return (
102
             <NavigateSectionList
102
             <NavigateSectionList
103
                 disabled = { disabled }
103
                 disabled = { disabled }
104
                 onPress = { this._onPress }
104
                 onPress = { this._onPress }
105
                 onRefresh = { this._onRefresh }
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
                 renderListEmptyComponent
106
                 renderListEmptyComponent
112
-                    = { _authorization === 'denied'
113
-                        ? this._getRenderListEmptyComponent() : undefined }
107
+                    = { this._getRenderListEmptyComponent() }
114
                 sections = { this._toDisplayableList() } />
108
                 sections = { this._toDisplayableList() } />
115
         );
109
         );
116
     }
110
     }
122
      * of the default one in the {@link NavigateSectionList}.
116
      * of the default one in the {@link NavigateSectionList}.
123
      *
117
      *
124
      * @private
118
      * @private
125
-     * @returns {Function}
119
+     * @returns {?React$Component}
126
      */
120
      */
127
     _getRenderListEmptyComponent() {
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
         return (
131
         return (
131
             <View style = { styles.noPermissionMessageView }>
132
             <View style = { styles.noPermissionMessageView }>
168
         this.props.dispatch(refreshCalendar(true));
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
     _toDisplayableItem: Object => Object;
190
     _toDisplayableItem: Object => Object;
172
 
191
 
173
     /**
192
     /**
199
      */
218
      */
200
     _toDisplayableList() {
219
     _toDisplayableList() {
201
         const { _eventList, t } = this.props;
220
         const { _eventList, t } = this.props;
221
+
202
         const now = Date.now();
222
         const now = Date.now();
223
+
203
         const { createSection } = NavigateSectionList;
224
         const { createSection } = NavigateSectionList;
204
         const nowSection = createSection(t('calendarSync.now'), 'now');
225
         const nowSection = createSection(t('calendarSync.now'), 'now');
205
         const nextSection = createSection(t('calendarSync.next'), 'next');
226
         const nextSection = createSection(t('calendarSync.next'), 'next');
227
             nextSection,
248
             nextSection,
228
             laterSection
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
         return sectionList;
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
  *
260
  *
260
  * @param {Object} state - The redux state.
261
  * @param {Object} state - The redux state.
261
  * @returns {{
262
  * @returns {{
262
- *     _eventList: Array
263
+ *     _authorization: ?string,
264
+ *     _eventList: Array<Object>
263
  * }}
265
  * }}
264
  */
266
  */
265
 function _mapStateToProps(state: Object) {
267
 function _mapStateToProps(state: Object) {
266
-    const calendarSyncState = state['features/calendar-sync'];
268
+    const { authorization, events } = state['features/calendar-sync'];
267
 
269
 
268
     return {
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 Parādīt failu

34
      */
34
      */
35
     noPermissionMessageText: {
35
     noPermissionMessageText: {
36
         backgroundColor: 'transparent',
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 Parādīt failu

43
             break;
43
             break;
44
 
44
 
45
         case SET_CALENDAR_AUTHORIZATION:
45
         case SET_CALENDAR_AUTHORIZATION:
46
-            return {
47
-                ...state,
48
-                authorization: action.authorization
49
-            };
46
+            return set(state, 'authorization', action.authorization);
50
 
47
 
51
         case SET_CALENDAR_EVENTS:
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
         return state;
52
         return state;

+ 4
- 4
react/features/welcome/actionTypes.js Parādīt failu

12
 export const SET_SIDEBAR_VISIBLE = Symbol('SET_SIDEBAR_VISIBLE');
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
  *     pageIndex: number
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
     = Symbol('SET_WELCOME_PAGE_LIST_DEFAULT_PAGE');
24
     = Symbol('SET_WELCOME_PAGE_LIST_DEFAULT_PAGE');

+ 16
- 17
react/features/welcome/actions.js Parādīt failu

2
 
2
 
3
 import {
3
 import {
4
     SET_SIDEBAR_VISIBLE,
4
     SET_SIDEBAR_VISIBLE,
5
-    SET_WELCOME_PAGE_LIST_DEFAULT_PAGE
5
+    SET_WELCOME_PAGE_LISTS_DEFAULT_PAGE
6
 } from './actionTypes';
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
  * @returns {{
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
     return {
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
  * @returns {{
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
     return {
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 Parādīt failu

9
 import { MeetingList } from '../../calendar-sync';
9
 import { MeetingList } from '../../calendar-sync';
10
 import { RecentList } from '../../recent-list';
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
 type Props = {
17
 type Props = {
15
 
18
 
16
     /**
19
     /**
50
 class WelcomePageLists extends Component<Props> {
53
 class WelcomePageLists extends Component<Props> {
51
     /**
54
     /**
52
      * The pages to be rendered.
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
     pages: Array<{
61
     pages: Array<{
57
-        component: Object,
62
+        component: ?Object,
58
         icon: string | number,
63
         icon: string | number,
59
         title: string
64
         title: string
60
-    }>
65
+    }>;
61
 
66
 
62
     /**
67
     /**
63
-     * Component contructor.
68
+     * Initializes a new {@code WelcomePageLists} instance.
64
      *
69
      *
65
      * @inheritdoc
70
      * @inheritdoc
66
      */
71
      */
68
         super(props);
73
         super(props);
69
 
74
 
70
         const { t } = props;
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
         this._onSelectPage = this._onSelectPage.bind(this);
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
      * @inheritdoc
98
      * @inheritdoc
90
      */
99
      */
91
     render() {
100
     render() {
92
-        const { disabled, _defaultPage } = this.props;
101
+        const { _defaultPage } = this.props;
93
 
102
 
94
         if (typeof _defaultPage === 'undefined') {
103
         if (typeof _defaultPage === 'undefined') {
95
             return null;
104
             return null;
98
         return (
107
         return (
99
             <PagedList
108
             <PagedList
100
                 defaultPage = { _defaultPage }
109
                 defaultPage = { _defaultPage }
101
-                disabled = { disabled }
110
+                disabled = { this.props.disabled }
102
                 onSelectPage = { this._onSelectPage }
111
                 onSelectPage = { this._onSelectPage }
103
                 pages = { this.pages } />
112
                 pages = { this.pages } />
104
         );
113
         );
105
     }
114
     }
106
 
115
 
107
-    _onSelectPage: number => void
116
+    _onSelectPage: number => void;
108
 
117
 
109
     /**
118
     /**
110
      * Callback for the {@code PagedList} page select action.
119
      * Callback for the {@code PagedList} page select action.
114
      * @returns {void}
123
      * @returns {void}
115
      */
124
      */
116
     _onSelectPage(pageIndex) {
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
  * @param {Object} state - The redux state.
134
  * @param {Object} state - The redux state.
128
  * @protected
135
  * @protected
129
  * @returns {{
136
  * @returns {{
130
- *     _hasRecentListEntries: boolean
137
+ *     _defaultPage: number
131
  * }}
138
  * }}
132
  */
139
  */
133
 function _mapStateToProps(state: Object) {
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
     return {
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 Parādīt failu

1
 // @flow
1
 // @flow
2
 
2
 
3
-import { ReducerRegistry } from '../base/redux';
3
+import { ReducerRegistry, set } from '../base/redux';
4
 import { PersistenceRegistry } from '../base/storage';
4
 import { PersistenceRegistry } from '../base/storage';
5
+
5
 import {
6
 import {
6
     SET_SIDEBAR_VISIBLE,
7
     SET_SIDEBAR_VISIBLE,
7
-    SET_WELCOME_PAGE_LIST_DEFAULT_PAGE
8
+    SET_WELCOME_PAGE_LISTS_DEFAULT_PAGE
8
 } from './actionTypes';
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
 const STORE_NAME = 'features/welcome';
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
 PersistenceRegistry.register(STORE_NAME, {
20
 PersistenceRegistry.register(STORE_NAME, {
19
     defaultPage: true
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
 ReducerRegistry.register(STORE_NAME, (state = {}, action) => {
27
 ReducerRegistry.register(STORE_NAME, (state = {}, action) => {
26
     switch (action.type) {
28
     switch (action.type) {
27
     case SET_SIDEBAR_VISIBLE:
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
 });

Notiek ielāde…
Atcelt
Saglabāt