diff --git a/app/views/DiscussionsView/DiscussionDetails.tsx b/app/views/DiscussionsView/DiscussionDetails.tsx index 5edca01d1..45635558f 100644 --- a/app/views/DiscussionsView/DiscussionDetails.tsx +++ b/app/views/DiscussionsView/DiscussionDetails.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { StyleSheet, Text, View, ViewStyle } from 'react-native'; +import { StyleSheet, Text, View } from 'react-native'; import { TThreadModel } from '../../definitions/IThread'; import { CustomIcon } from '../../lib/Icons'; @@ -10,6 +10,7 @@ import { useTheme } from '../../theme'; const styles = StyleSheet.create({ container: { flex: 1, + marginTop: 8, flexDirection: 'row', alignItems: 'center' }, @@ -31,23 +32,19 @@ const styles = StyleSheet.create({ interface IDiscussionDetails { item: TThreadModel; - user: { - id: string; - }; date: string; - style: ViewStyle; } -const DiscussionDetails = ({ item, date, style }: IDiscussionDetails) => { +const DiscussionDetails = ({ item, date }: IDiscussionDetails): JSX.Element => { const { theme } = useTheme(); let { dcount } = item; - if (dcount! >= 1000) { + if (dcount && dcount >= 1000) { dcount = '+999'; } return ( - + diff --git a/app/views/DiscussionsView/Item.tsx b/app/views/DiscussionsView/Item.tsx index 379bea085..af2e18a03 100644 --- a/app/views/DiscussionsView/Item.tsx +++ b/app/views/DiscussionsView/Item.tsx @@ -39,9 +39,6 @@ const styles = StyleSheet.create({ avatar: { marginRight: 8 }, - discussionDetails: { - marginTop: 8 - }, messageContainer: { flexDirection: 'row' }, @@ -53,21 +50,17 @@ const styles = StyleSheet.create({ interface IItem { item: TThreadModel; baseUrl: string; - user: { - id: string; - token: string; - }; onPress: { (...args: any[]): void; stop(): void; }; } -const Item = ({ item, baseUrl, user, onPress }: IItem): JSX.Element => { +const Item = ({ item, baseUrl, onPress }: IItem): JSX.Element => { const { theme } = useTheme(); const username = item?.u?.username; - let messageTime: string; - let messageDate: string; + let messageTime = ''; + let messageDate = ''; if (item?.ts) { messageTime = moment(item.ts).format('LT'); @@ -102,7 +95,7 @@ const Item = ({ item, baseUrl, user, onPress }: IItem): JSX.Element => { /> ) : null} - + {messageDate ? : null} diff --git a/app/views/DiscussionsView/index.tsx b/app/views/DiscussionsView/index.tsx index 85ba37032..419ecb203 100644 --- a/app/views/DiscussionsView/index.tsx +++ b/app/views/DiscussionsView/index.tsx @@ -5,7 +5,7 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { HeaderBackButton, StackNavigationOptions, StackNavigationProp } from '@react-navigation/stack'; import { RouteProp } from '@react-navigation/core'; -import { SubscriptionType } from '../../definitions'; +import { IApplicationState, SubscriptionType } from '../../definitions'; import { ChatsStackParamList } from '../../stacks/types'; import ActivityIndicator from '../../containers/ActivityIndicator'; import I18n from '../../i18n'; @@ -34,31 +34,11 @@ interface IDiscussionsViewProps { item: TThreadModel; } -interface IDiscussionsViewState { - login: { - user: { - id: string; - token: string; - }; - }; - server: { - server: string; - }; - settings: { - UI_Use_Real_Name: boolean; - Message_TimeFormat: string; - }; - app: { - isMasterDetail: boolean; - }; -} - const DiscussionsView = ({ navigation, route }: IDiscussionsViewProps): JSX.Element => { const rid = route.params?.rid; - const user = useSelector((state: IDiscussionsViewState) => state.login?.user); - const baseUrl = useSelector((state: IDiscussionsViewState) => state.server?.server); - const isMasterDetail = useSelector((state: IDiscussionsViewState) => state.app?.isMasterDetail); + const baseUrl = useSelector((state: IApplicationState) => state.server?.server); + const isMasterDetail = useSelector((state: IApplicationState) => state.app?.isMasterDetail); const [loading, setLoading] = useState(false); const [discussions, setDiscussions] = useState([]); @@ -187,7 +167,6 @@ const DiscussionsView = ({ navigation, route }: IDiscussionsViewProps): JSX.Elem (searchTotal || total) > API_FETCH_COUNT ?? load()} + onEndReached={() => (isSearching ? searchTotal : total) > API_FETCH_COUNT ?? load()} ItemSeparatorComponent={List.Separator} ListFooterComponent={loading ? : null} scrollIndicatorInsets={{ right: 1 }}