From 38b2b0827865373bc40e3d0df9220af359b0ce0f Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Thu, 17 Mar 2022 22:37:10 -0400 Subject: [PATCH] Chore: Evaluate ActivityIndicator - TypeScript (#3914) * update: `BackgroundContainer` and `ActivityIndicator` * update: return type for `RCActivityIndicator` * update: return type for `BackgroundContainer` --- app/containers/ActivityIndicator.tsx | 14 +++++++------- app/containers/MessageBox/CommandsPreview/Item.tsx | 2 +- app/containers/TextInput.tsx | 3 +-- app/containers/UIKit/Overflow.tsx | 2 +- app/containers/message/Audio.tsx | 2 +- app/containers/message/Reply.tsx | 2 +- app/containers/message/Video.tsx | 6 +----- app/views/AttachmentView.tsx | 2 +- app/views/AuthenticationWebView.tsx | 4 ++-- app/views/CannedResponsesListView/index.tsx | 2 +- app/views/DirectoryView/index.tsx | 2 +- app/views/DiscussionsView/index.tsx | 2 +- app/views/JitsiMeetView.tsx | 4 ++-- app/views/MessagesView/index.tsx | 2 +- app/views/ModalBlockView.tsx | 2 +- app/views/RoomMembersView/index.tsx | 2 +- app/views/RoomView/List/index.tsx | 4 ++-- app/views/RoomsListView/index.tsx | 2 +- app/views/SearchMessagesView/index.tsx | 2 +- app/views/ShareListView/index.tsx | 2 +- app/views/TeamChannelsView.tsx | 3 +-- app/views/ThreadMessagesView/index.tsx | 2 +- .../UserNotificationPreferencesView/index.tsx | 3 +-- 23 files changed, 32 insertions(+), 39 deletions(-) diff --git a/app/containers/ActivityIndicator.tsx b/app/containers/ActivityIndicator.tsx index 69ef22ce..70192641 100644 --- a/app/containers/ActivityIndicator.tsx +++ b/app/containers/ActivityIndicator.tsx @@ -1,14 +1,11 @@ import React from 'react'; import { ActivityIndicator, ActivityIndicatorProps, StyleSheet } from 'react-native'; +import { useTheme } from '../theme'; import { themes } from '../constants/colors'; -type TTheme = 'light' | 'dark' | 'black' | string; - interface IActivityIndicator extends ActivityIndicatorProps { - theme?: TTheme; absolute?: boolean; - props?: object; } const styles = StyleSheet.create({ @@ -27,8 +24,11 @@ const styles = StyleSheet.create({ } }); -const RCActivityIndicator = ({ theme = 'light', absolute, ...props }: IActivityIndicator) => ( - -); +const RCActivityIndicator = ({ absolute, ...props }: IActivityIndicator): React.ReactElement => { + const { theme } = useTheme(); + return ( + + ); +}; export default RCActivityIndicator; diff --git a/app/containers/MessageBox/CommandsPreview/Item.tsx b/app/containers/MessageBox/CommandsPreview/Item.tsx index 33e3c4ff..3f18d2aa 100644 --- a/app/containers/MessageBox/CommandsPreview/Item.tsx +++ b/app/containers/MessageBox/CommandsPreview/Item.tsx @@ -34,7 +34,7 @@ const Item = ({ item, theme }: IMessageBoxCommandsPreviewItem) => { resizeMode={FastImage.resizeMode.cover} onLoadStart={() => setLoading(true)} onLoad={() => setLoading(false)}> - {loading ? : null} + {loading ? : null} ) : ( diff --git a/app/containers/TextInput.tsx b/app/containers/TextInput.tsx index f829bb90..1ec1f1e1 100644 --- a/app/containers/TextInput.tsx +++ b/app/containers/TextInput.tsx @@ -116,8 +116,7 @@ export default class RCTextInput extends React.PureComponent; + return ; } tooglePassword = () => { diff --git a/app/containers/UIKit/Overflow.tsx b/app/containers/UIKit/Overflow.tsx index 50d77920..a48fadd3 100644 --- a/app/containers/UIKit/Overflow.tsx +++ b/app/containers/UIKit/Overflow.tsx @@ -66,7 +66,7 @@ export const Overflow = ({ element, loading, action, parser, theme }: IOverflow) {!loading ? ( ) : ( - + )} ( hitSlop={BUTTON_HIT_SLOP} background={Touchable.SelectableBackgroundBorderless()}> {loading ? ( - + ) : ( )} diff --git a/app/containers/message/Reply.tsx b/app/containers/message/Reply.tsx index 7a708924..31284b06 100644 --- a/app/containers/message/Reply.tsx +++ b/app/containers/message/Reply.tsx @@ -258,7 +258,7 @@ const Reply = React.memo( styles.backdrop, { backgroundColor: themes[theme].bannerBackground, opacity: themes[theme].attachmentLoadingOpacity } ]}> - + ) : null} diff --git a/app/containers/message/Video.tsx b/app/containers/message/Video.tsx index 6fb823f8..51e8631a 100644 --- a/app/containers/message/Video.tsx +++ b/app/containers/message/Video.tsx @@ -77,11 +77,7 @@ const Video = React.memo( onPress={onPress} style={[styles.button, { backgroundColor: themes[theme].videoBackground }]} background={Touchable.Ripple(themes[theme].bannerBackground)}> - {loading ? ( - - ) : ( - - )} + {loading ? : } {content} - {loading ? : null} + {loading ? : null} ); } diff --git a/app/views/AuthenticationWebView.tsx b/app/views/AuthenticationWebView.tsx index ac304fbf..9a138108 100644 --- a/app/views/AuthenticationWebView.tsx +++ b/app/views/AuthenticationWebView.tsx @@ -175,7 +175,7 @@ class AuthenticationWebView extends React.PureComponent - {loading ? : null} + {loading ? : null} ); } diff --git a/app/views/CannedResponsesListView/index.tsx b/app/views/CannedResponsesListView/index.tsx index ef3d0d21..e9dec147 100644 --- a/app/views/CannedResponsesListView/index.tsx +++ b/app/views/CannedResponsesListView/index.tsx @@ -353,7 +353,7 @@ const CannedResponsesListView = ({ navigation, route }: ICannedResponsesListView onEndReached={onEndReached} onEndReachedThreshold={0.5} ItemSeparatorComponent={List.Separator} - ListFooterComponent={loading ? : null} + ListFooterComponent={loading ? : null} /> ); }; diff --git a/app/views/DirectoryView/index.tsx b/app/views/DirectoryView/index.tsx index 73e6a45c..1ad798ec 100644 --- a/app/views/DirectoryView/index.tsx +++ b/app/views/DirectoryView/index.tsx @@ -292,7 +292,7 @@ class DirectoryView extends React.Component { renderItem={this.renderItem} ItemSeparatorComponent={List.Separator} keyboardShouldPersistTaps='always' - ListFooterComponent={loading ? : null} + ListFooterComponent={loading ? : null} onEndReached={() => this.load({})} /> {showOptionsDropdown ? ( diff --git a/app/views/DiscussionsView/index.tsx b/app/views/DiscussionsView/index.tsx index 8a977a36..93963b0c 100644 --- a/app/views/DiscussionsView/index.tsx +++ b/app/views/DiscussionsView/index.tsx @@ -198,7 +198,7 @@ const DiscussionsView = ({ navigation, route }: IDiscussionsViewProps): JSX.Elem removeClippedSubviews={isIOS} onEndReached={() => (isSearching ? searchTotal : total) > API_FETCH_COUNT ?? load()} ItemSeparatorComponent={List.Separator} - ListFooterComponent={loading ? : null} + ListFooterComponent={loading ? : null} scrollIndicatorInsets={{ right: 1 }} /> diff --git a/app/views/JitsiMeetView.tsx b/app/views/JitsiMeetView.tsx index aa6658d2..9145f2e3 100644 --- a/app/views/JitsiMeetView.tsx +++ b/app/views/JitsiMeetView.tsx @@ -117,7 +117,7 @@ class JitsiMeetView extends React.Component - {loading ? : null} + {loading ? : null} ); } diff --git a/app/views/MessagesView/index.tsx b/app/views/MessagesView/index.tsx index 66070d1f..67ddffdd 100644 --- a/app/views/MessagesView/index.tsx +++ b/app/views/MessagesView/index.tsx @@ -369,7 +369,7 @@ class MessagesView extends React.Component { style={[styles.list, { backgroundColor: themes[theme].backgroundColor }]} keyExtractor={item => item._id} onEndReached={this.load} - ListFooterComponent={loading ? : null} + ListFooterComponent={loading ? : null} /> ); diff --git a/app/views/ModalBlockView.tsx b/app/views/ModalBlockView.tsx index 5167663d..c87a3fd9 100644 --- a/app/views/ModalBlockView.tsx +++ b/app/views/ModalBlockView.tsx @@ -277,7 +277,7 @@ class ModalBlockView extends React.Component - {loading ? : null} + {loading ? : null} ); } diff --git a/app/views/RoomMembersView/index.tsx b/app/views/RoomMembersView/index.tsx index 4212e785..2ad9a734 100644 --- a/app/views/RoomMembersView/index.tsx +++ b/app/views/RoomMembersView/index.tsx @@ -636,7 +636,7 @@ class RoomMembersView extends React.Component { if (isLoading) { - return ; + return ; } return null; }} diff --git a/app/views/RoomView/List/index.tsx b/app/views/RoomView/List/index.tsx index 6f136748..eb3e7c4e 100644 --- a/app/views/RoomView/List/index.tsx +++ b/app/views/RoomView/List/index.tsx @@ -319,9 +319,9 @@ class ListContainer extends React.Component { - const { rid, theme, loading } = this.props; + const { rid, loading } = this.props; if (loading && rid) { - return ; + return ; } return null; }; diff --git a/app/views/RoomsListView/index.tsx b/app/views/RoomsListView/index.tsx index ec375c23..24c6414d 100644 --- a/app/views/RoomsListView/index.tsx +++ b/app/views/RoomsListView/index.tsx @@ -1000,7 +1000,7 @@ class RoomsListView extends React.Component; + return ; } return ( diff --git a/app/views/SearchMessagesView/index.tsx b/app/views/SearchMessagesView/index.tsx index c2a48367..585bf76a 100644 --- a/app/views/SearchMessagesView/index.tsx +++ b/app/views/SearchMessagesView/index.tsx @@ -291,7 +291,7 @@ class SearchMessagesView extends React.Component item._id} onEndReached={this.onEndReached} - ListFooterComponent={loading ? : null} + ListFooterComponent={loading ? : null} onEndReachedThreshold={0.5} removeClippedSubviews={isIOS} {...scrollPersistTaps} diff --git a/app/views/ShareListView/index.tsx b/app/views/ShareListView/index.tsx index ced0badd..b8960324 100644 --- a/app/views/ShareListView/index.tsx +++ b/app/views/ShareListView/index.tsx @@ -450,7 +450,7 @@ class ShareListView extends React.Component { const { theme } = this.props; if (loading) { - return ; + return ; } if (needsPermission) { diff --git a/app/views/TeamChannelsView.tsx b/app/views/TeamChannelsView.tsx index b8b32cdd..330126f7 100644 --- a/app/views/TeamChannelsView.tsx +++ b/app/views/TeamChannelsView.tsx @@ -540,9 +540,8 @@ class TeamChannelsView extends React.Component { const { loadingMore } = this.state; - const { theme } = this.props; if (loadingMore) { - return ; + return ; } return null; }; diff --git a/app/views/ThreadMessagesView/index.tsx b/app/views/ThreadMessagesView/index.tsx index 5d17729d..2c6dcc6a 100644 --- a/app/views/ThreadMessagesView/index.tsx +++ b/app/views/ThreadMessagesView/index.tsx @@ -524,7 +524,7 @@ class ThreadMessagesView extends React.Component : null} + ListFooterComponent={loading ? : null} scrollIndicatorInsets={{ right: 1 }} // https://github.com/facebook/react-native/issues/26610#issuecomment-539843444 /> ); diff --git a/app/views/UserNotificationPreferencesView/index.tsx b/app/views/UserNotificationPreferencesView/index.tsx index a4d23291..1b9a5cd8 100644 --- a/app/views/UserNotificationPreferencesView/index.tsx +++ b/app/views/UserNotificationPreferencesView/index.tsx @@ -114,7 +114,6 @@ class UserNotificationPreferencesView extends React.Component< }; render() { - const { theme } = this.props; const { loading } = this.state; return ( @@ -159,7 +158,7 @@ class UserNotificationPreferencesView extends React.Component< ) : ( - + )}