From ce3ea47826a13779d80b3e19117de5c47c4935a8 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Thu, 24 Mar 2022 12:42:17 -0300 Subject: [PATCH] CategoryModel typing --- app/components/channel_list/categories/categories.tsx | 11 +++++++++-- app/screens/home/channel_list/channel_list.tsx | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/app/components/channel_list/categories/categories.tsx b/app/components/channel_list/categories/categories.tsx index 5718fd42b..972078791 100644 --- a/app/components/channel_list/categories/categories.tsx +++ b/app/components/channel_list/categories/categories.tsx @@ -1,7 +1,7 @@ // Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. // See LICENSE.txt for license information. -import React, {useCallback} from 'react'; +import React, {useCallback, useEffect, useRef} from 'react'; import {useIntl} from 'react-intl'; import {FlatList, StyleSheet} from 'react-native'; @@ -15,6 +15,7 @@ type Props = { categories: CategoryModel[]; currentChannelId: string; currentUserId: string; + currentTeamId: string; } const styles = StyleSheet.create({ @@ -25,8 +26,9 @@ const styles = StyleSheet.create({ const extractKey = (item: CategoryModel) => item.id; -const Categories = ({categories, currentChannelId, currentUserId}: Props) => { +const Categories = ({categories, currentChannelId, currentUserId, currentTeamId}: Props) => { const intl = useIntl(); + const listRef = useRef(null); const renderCategory = useCallback((data: {item: CategoryModel}) => { return ( @@ -42,6 +44,10 @@ const Categories = ({categories, currentChannelId, currentUserId}: Props) => { ); }, [categories, currentChannelId, intl.locale]); + useEffect(() => { + listRef.current?.scrollToOffset({animated: false, offset: 0}); + }, [currentTeamId]); + // Sort Categories categories.sort((a, b) => a.sortOrder - b.sortOrder); @@ -52,6 +58,7 @@ const Categories = ({categories, currentChannelId, currentUserId}: Props) => { return ( { teamsCount={props.teamsCount} />