Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

Coding style: formatting, typos

Lyubo Marinov13e0e18f3725
diff --git a/react/features/base/react/components/native/NavigateSectionList.js b/react/features/base/react/components/native/NavigateSectionList.js
index d0449e8d72..96a5967ff6 100644
--- a/react/features/base/react/components/native/NavigateSectionList.js
+++ b/react/features/base/react/components/native/NavigateSectionList.js
@@ -1,4 +1,5 @@
// @flow
+
import React, { Component } from 'react';
import {
SafeAreaView,
@@ -8,11 +9,10 @@ import {
View
} from 'react-native';
-import styles, { UNDERLAY_COLOR } from './styles';
-
+import { Icon } from '../../../font-icons';
import { translate } from '../../../i18n';
-import { Icon } from '../../../font-icons';
+import styles, { UNDERLAY_COLOR } from './styles';
type Props = {
@@ -60,14 +60,30 @@ type Props = {
* ]
*/
sections: Array<Object>
-}
+};
/**
- * Implements a general section list to display items that have a URL
- * property and navigates to (probably) meetings, such as the recent list
- * or the meeting list components.
+ * Implements a general section list to display items that have a URL property
+ * and navigates to (probably) meetings, such as the recent list or the meeting
+ * list components.
*/
class NavigateSectionList extends Component<Props> {
+ /**
+ * Creates an empty section object.
+ *
+ * @param {string} title - The title of the section.
+ * @param {string} key - The key of the section. It must be unique.
+ * @private
+ * @returns {Object}
+ */
+ static createSection(title, key) {
+ return {
+ data: [],
+ key,
+ title
+ };
+ }
+
/**
* Constructor of the NavigateSectionList component.
*
@@ -89,23 +105,23 @@ class NavigateSectionList extends Component<Props> {
}
/**
- * Implements React's Component.render function.
+ * Implements React's Component.render.
* Note: we don't use the refreshing value yet, because refreshing of these
* lists is super quick, no need to complicate the code - yet.
*
* @inheritdoc
*/
render() {
- const { renderListEmptyComponent, sections } = this.props;
+ const {
+ renderListEmptyComponent = this._renderListEmptyComponent,
+ sections
+ } = this.props;
return (
<SafeAreaView
style = { styles.container } >
<SectionList
- ListEmptyComponent = {
- renderListEmptyComponent
- || this._renderListEmptyComponent
- }
+ ListEmptyComponent = { renderListEmptyComponent }
keyExtractor = { this._getItemKey }
onRefresh = { this._onRefresh }
refreshing = { false }
@@ -117,27 +133,11 @@ class NavigateSectionList extends Component<Props> {
);
}
- /**
- * Creates an empty section object.
- *
- * @private
- * @param {string} title - The title of the section.
- * @param {string} key - The key of the section. It must be unique.
- * @returns {Object}
- */
- static createSection(title, key) {
- return {
- data: [],
- key,
- title
- };
- }
-
- _getAvatarColor: string => Object
+ _getAvatarColor: string => Object;
/**
- * Returns a style (color) based on the string that determines the
- * color of the avatar.
+ * Returns a style (color) based on the string that determines the color of
+ * the avatar.
*
* @param {string} colorBase - The string that is the base of the color.
* @private
@@ -162,22 +162,22 @@ class NavigateSectionList extends Component<Props> {
/**
* Generates a unique id to every item.
*
- * @private
* @param {Object} item - The item.
* @param {number} index - The item index.
+ * @private
* @returns {string}
*/
_getItemKey(item, index) {
return `${index}-${item.key}`;
}
- _onPress: string => Function
+ _onPress: string => Function;
/**
* Returns a function that is used in the onPress callback of the items.
*
- * @private
* @param {string} url - The URL of the item to navigate to.
+ * @private
* @returns {Function}
*/
_onPress(url) {
@@ -188,7 +188,7 @@ class NavigateSectionList extends Component<Props> {
};
}
- _onRefresh: () => void
+ _onRefresh: () => void;
/**
* Invokes the onRefresh callback if present.
@@ -209,26 +209,35 @@ class NavigateSectionList extends Component<Props> {
/**
* Renders a single item in the list.
*
- * @private
* @param {Object} listItem - The item to render.
+ * @private
* @returns {Component}
*/
_renderItem(listItem) {
- const { item } = listItem;
+ const { item: { colorBase, lines, title, url } } = listItem;
+
+ // XXX The value of title cannot be undefined; otherwise, react-native
+ // will throw a TypeError: Cannot read property of undefined. While it's
+ // difficult to get an undefined title and very likely requires the
+ // execution of incorrect source code, it is undesirable to break the
+ // whole app because of an undefined string.
+ if (typeof title === 'undefined') {
+ return null;
+ }
return (
<TouchableHighlight
- onPress = { this._onPress(item.url) }
+ onPress = { this._onPress(url) }
underlayColor = { UNDERLAY_COLOR }>
<View style = { styles.listItem }>
<View style = { styles.avatarContainer } >
<View
style = { [
styles.avatar,
- this._getAvatarColor(item.colorBase)
+ this._getAvatarColor(colorBase)
] } >
<Text style = { styles.avatarContent }>
- { item.title.substr(0, 1).toUpperCase() }
+ { title.substr(0, 1).toUpperCase() }
</Text>
</View>
</View>
@@ -239,11 +248,9 @@ class NavigateSectionList extends Component<Props> {
styles.listItemText,
styles.listItemTitle
] }>
- { item.title }
+ { title }
</Text>
- {
- this._renderItemLines(item.lines)
- }
+ { this._renderItemLines(lines) }
</View>
</View>
</TouchableHighlight>
@@ -255,9 +262,9 @@ class NavigateSectionList extends Component<Props> {
/**
* Renders a single line from the additional lines.
*
- * @private
* @param {string} line - The line text.
* @param {number} index - The index of the line.
+ * @private
* @returns {React$Node}
*/
_renderItemLine(line, index) {
@@ -275,32 +282,26 @@ class NavigateSectionList extends Component<Props> {
);
}
- _renderItemLines: (Array<string>) => Array<React$Node>;
+ _renderItemLines: Array<string> => Array<React$Node>;
/**
* Renders the additional item lines, if any.
*
- * @private
* @param {Array<string>} lines - The lines to render.
+ * @private
* @returns {Array<React$Node>}
*/
_renderItemLines(lines) {
- if (lines && lines.length) {
- return lines.map((line, index) =>
- this._renderItemLine(line, index)
- );
- }
-
- return null;
+ return lines && lines.length ? lines.map(this._renderItemLine) : null;
}
- _renderListEmptyComponent: () => Object
+ _renderListEmptyComponent: () => Object;
/**
* Renders a component to display when the list is empty.
*
- * @private
* @param {Object} section - The section being rendered.
+ * @private
* @returns {React$Node}
*/
_renderListEmptyComponent() {
@@ -322,13 +323,13 @@ class NavigateSectionList extends Component<Props> {
return null;
}
- _renderSection: Object => Object
+ _renderSection: Object => Object;
/**
* Renders a section title.
*
- * @private
* @param {Object} section - The section being rendered.
+ * @private
* @returns {React$Node}
*/
_renderSection(section) {
diff --git a/react/features/calendar-sync/components/MeetingList.native.js b/react/features/calendar-sync/components/MeetingList.native.js
index 6f3a1acce7..dfa5fcbf71 100644
--- a/react/features/calendar-sync/components/MeetingList.native.js
+++ b/react/features/calendar-sync/components/MeetingList.native.js
@@ -83,7 +83,7 @@ class MeetingList extends Component<Props> {
}
/**
- * Implements React Component's componentWillReceiveProps function.
+ * Implements React Component's componentWillReceiveProps.
*
* @inheritdoc
*/
@@ -98,7 +98,7 @@ class MeetingList extends Component<Props> {
}
/**
- * Implements the React Components's render method.
+ * Implements the React Components's render.
*
* @inheritdoc
*/
@@ -115,7 +115,7 @@ class MeetingList extends Component<Props> {
);
}
- _getRenderListEmptyComponent: () => Object
+ _getRenderListEmptyComponent: () => Object;
/**
* Returns a list empty component if a custom one has to be rendered instead
@@ -147,7 +147,7 @@ class MeetingList extends Component<Props> {
return null;
}
- _onPress: string => Function
+ _onPress: string => Function;
/**
* Handles the list's navigate action.
@@ -160,7 +160,7 @@ class MeetingList extends Component<Props> {
this.props.dispatch(appNavigate(url));
}
- _onRefresh: () => void
+ _onRefresh: () => void;
/**
* Callback to execute when the list is doing a pull-to-refresh.
@@ -172,7 +172,7 @@ class MeetingList extends Component<Props> {
this.props.dispatch(refreshCalendar(true));
}
- _toDisplayableItem: Object => Object
+ _toDisplayableItem: Object => Object;
/**
* Creates a displayable object from an event.
@@ -193,7 +193,7 @@ class MeetingList extends Component<Props> {
};
}
- _toDisplayableList: () => Array<Object>
+ _toDisplayableList: () => Array<Object>;
/**
* Transforms the event list to a displayable list with sections.
@@ -204,18 +204,10 @@ class MeetingList extends Component<Props> {
_toDisplayableList() {
const { _eventList, t } = this.props;
const now = Date.now();
- const nowSection = NavigateSectionList.createSection(
- t('calendarSync.now'),
- 'now'
- );
- const nextSection = NavigateSectionList.createSection(
- t('calendarSync.next'),
- 'next'
- );
- const laterSection = NavigateSectionList.createSection(
- t('calendarSync.later'),
- 'later'
- );
+ const { createSection } = NavigateSectionList;
+ const nowSection = createSection(t('calendarSync.now'), 'now');
+ const nextSection = createSection(t('calendarSync.next'), 'next');
+ const laterSection = createSection(t('calendarSync.later'), 'later');
for (const event of _eventList) {
const displayableEvent = this._toDisplayableItem(event);
@@ -224,7 +216,7 @@ class MeetingList extends Component<Props> {
nowSection.data.push(displayableEvent);
} else if (event.startDate > now) {
if (nextSection.data.length
- && nextSection.data[0].startDate !== event.startDate) {
+ && nextSection.data[0].startDate !== event.startDate) {
laterSection.data.push(displayableEvent);
} else {
nextSection.data.push(displayableEvent);
@@ -247,7 +239,7 @@ class MeetingList extends Component<Props> {
return sectionList;
}
- _toDateString: Object => string
+ _toDateString: Object => string;
/**
* Generates a date (interval) string for a given event.
diff --git a/react/features/calendar-sync/middleware.js b/react/features/calendar-sync/middleware.js
index ceecaffdf1..7fb23ee18d 100644
--- a/react/features/calendar-sync/middleware.js
+++ b/react/features/calendar-sync/middleware.js
@@ -102,9 +102,8 @@ function _ensureCalendarAccess(promptForPermission, dispatch) {
* @returns {Promise}
*/
function _ensureDefaultServer({ dispatch, getState }) {
- const state = getState();
const defaultURL
- = parseURIString(state['features/app'].app._getDefaultURL());
+ = parseURIString(getState()['features/app'].app._getDefaultURL());
dispatch(addKnownDomain(defaultURL.host));
}
@@ -164,7 +163,7 @@ function _fetchCalendarEntries(
}
/**
- * Retreives a jitsi URL from an event if present.
+ * Retrieves a Jitsi Meet URL from an event if present.
*
* @param {Object} event - The event to parse.
* @param {Array<string>} knownDomains - The known domain names.
@@ -219,7 +218,7 @@ export function _isCalendarEnabled() {
}
/**
- * Retreives the domain name of a room upon join and stores it in the known
+ * Retrieves the domain name of a room upon join and stores it in the known
* domain list, if not present yet.
*
* @param {Object} store - The redux store.
diff --git a/react/features/recent-list/components/RecentList.native.js b/react/features/recent-list/components/RecentList.native.js
index 57a62f5f33..5cc4cb130c 100644
--- a/react/features/recent-list/components/RecentList.native.js
+++ b/react/features/recent-list/components/RecentList.native.js
@@ -78,7 +78,7 @@ class RecentList extends Component<Props> {
);
}
- _onPress: string => Function
+ _onPress: string => Function;
/**
* Handles the list's navigate action.
@@ -93,7 +93,7 @@ class RecentList extends Component<Props> {
dispatch(appNavigate(url));
}
- _toDisplayableItem: Object => Object
+ _toDisplayableItem: Object => Object;
/**
* Creates a displayable list item of a recent list entry.
@@ -121,7 +121,7 @@ class RecentList extends Component<Props> {
};
}
- _toDisplayableList: () => Array<Object>
+ _toDisplayableList: () => Array<Object>;
/**
* Transforms the history list to a displayable list
@@ -132,18 +132,12 @@ class RecentList extends Component<Props> {
*/
_toDisplayableList() {
const { _recentList, t } = this.props;
- const todaySection = NavigateSectionList.createSection(
- t('recentList.today'),
- 'today'
- );
- const yesterdaySection = NavigateSectionList.createSection(
- t('recentList.yesterday'),
- 'yesterday'
- );
- const earlierSection = NavigateSectionList.createSection(
- t('recentList.earlier'),
- 'earlier'
- );
+ const { createSection } = NavigateSectionList;
+ const todaySection = createSection(t('recentList.today'), 'today');
+ const yesterdaySection
+ = createSection(t('recentList.yesterday'), 'yesterday');
+ const earlierSection
+ = createSection(t('recentList.earlier'), 'earlier');
const today = new Date().toDateString();
const yesterdayDate = new Date();
@@ -182,7 +176,7 @@ class RecentList extends Component<Props> {
return displayableList;
}
- _toDateString: number => string
+ _toDateString: number => string;
/**
* Generates a date string for the item.
@@ -203,7 +197,7 @@ class RecentList extends Component<Props> {
return m.format('lll');
}
- _toDurationString: number => string
+ _toDurationString: number => string;
/**
* Generates a duration string for the item.
@@ -226,8 +220,8 @@ class RecentList extends Component<Props> {
*
* @param {Object} state - The redux state.
* @returns {{
- * _defaultServerURL: string,
- * _recentList: Array
+ * _defaultServerURL: string,
+ * _recentList: Array
* }}
*/
export function _mapStateToProps(state: Object) {