<commit_before>// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import React, {useMemo} from 'react';
import {StyleSheet} from 'react-native';
import {Edge, SafeAreaView} from 'react-native-safe-area-context';

import PostList from '@components/post_list';
import {Screens} from '@constants';
import {useIsTablet} from '@hooks/device';

import type PostModel from '@typings/database/models/servers/post';

type Props = {
    channelId: string;
    currentTimezone: string | null;
    currentUsername: string;
    isTimezoneEnabled: boolean;
    lastViewedAt: number;
    nativeID: string;
    posts: PostModel[];
    rootPost: PostModel;
}

const edges: Edge[] = ['bottom'];

const styles = StyleSheet.create({
    container: {marginTop: 20},
    flex: {flex: 1},
});

const ThreadPostList = ({
    channelId, currentTimezone, currentUsername,
    isTimezoneEnabled, lastViewedAt, nativeID, posts, rootPost,
}: Props) => {
    const isTablet = useIsTablet();

    const threadPosts = useMemo(() => {
        return [...posts, rootPost];
    }, [posts, rootPost]);

    const postList = (
        <PostList
            channelId={channelId}
            contentContainerStyle={styles.container}
            currentTimezone={currentTimezone}
            currentUsername={currentUsername}
            isTimezoneEnabled={isTimezoneEnabled}
            lastViewedAt={lastViewedAt}
            location={Screens.THREAD}
            nativeID={nativeID}
            posts={threadPosts}
            rootId={rootPost.id}
            shouldShowJoinLeaveMessages={false}
            showMoreMessages={false}
            showNewMessageLine={false}
            testID='thread.post_list'
        />
    );

    if (isTablet) {
        return postList;
    }

    return (
        <SafeAreaView
            edges={edges}
            style={styles.flex}
        >
            {postList}
        </SafeAreaView>
    );
};

export default ThreadPostList;
<commit_msg>Fix thread_post_list to display first post completely<commit_after>// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.

import React, {useMemo} from 'react';
import {StyleSheet, View} from 'react-native';
import {Edge, SafeAreaView} from 'react-native-safe-area-context';

import PostList from '@components/post_list';
import {Screens} from '@constants';
import {useIsTablet} from '@hooks/device';

import type PostModel from '@typings/database/models/servers/post';

type Props = {
    channelId: string;
    currentTimezone: string | null;
    currentUsername: string;
    isTimezoneEnabled: boolean;
    lastViewedAt: number;
    nativeID: string;
    posts: PostModel[];
    rootPost: PostModel;
}

const edges: Edge[] = ['bottom'];

const styles = StyleSheet.create({
    container: {marginTop: 10},
    flex: {flex: 1},
    footer: {height: 20},
});

const ThreadPostList = ({
    channelId, currentTimezone, currentUsername,
    isTimezoneEnabled, lastViewedAt, nativeID, posts, rootPost,
}: Props) => {
    const isTablet = useIsTablet();

    const threadPosts = useMemo(() => {
        return [...posts, rootPost];
    }, [posts, rootPost]);

    const postList = (
        <PostList
            channelId={channelId}
            contentContainerStyle={styles.container}
            currentTimezone={currentTimezone}
            currentUsername={currentUsername}
            isTimezoneEnabled={isTimezoneEnabled}
            lastViewedAt={lastViewedAt}
            location={Screens.THREAD}
            nativeID={nativeID}
            posts={threadPosts}
            rootId={rootPost.id}
            shouldShowJoinLeaveMessages={false}
            showMoreMessages={false}
            showNewMessageLine={false}
            footer={<View style={styles.footer}/>}
            testID='thread.post_list'
        />
    );

    if (isTablet) {
        return postList;
    }

    return (
        <SafeAreaView
            edges={edges}
            style={styles.flex}
        >
            {postList}
        </SafeAreaView>
    );
};

export default ThreadPostList;

{'fraction_non_alphanumeric': 0.11531966224366706, 'fraction_numerical': 0.0038600723763570566, 'mean_word_length': 2.7050938337801607, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3868337', 'n_tokens_mistral': 1200, 'n_tokens_neox': 1173, 'n_words': 270}