UNPKG

fastcomments-react-native-sdk

Version:

React Native FastComments Components. Add live commenting to any React Native application.

19 lines (18 loc) 1.12 kB
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; import { Text, TouchableOpacity } from "react-native"; import { iterateCommentsTreeMut } from "../services/comment-trees"; import { incChangeCounter } from "../services/comment-render-determination"; function showHiddenComments(comment) { iterateCommentsTreeMut([comment], (comment) => { if (comment.hidden) { comment.hidden = false; incChangeCounter(comment); } }); comment.hiddenChildrenCount = 0; incChangeCounter(comment); } export function ShowNewChildLiveCommentsButton({ comment, translations, styles }) { const hiddenChildrenCount = comment.hiddenChildrenCount; return _jsxs(TouchableOpacity, { style: styles.showNewLiveComments?.button, onPress: () => showHiddenComments(comment), children: [_jsx(Text, { style: styles.showNewLiveComments?.count, children: Number(hiddenChildrenCount).toLocaleString() }), _jsx(Text, { style: styles.showNewLiveComments?.text, children: hiddenChildrenCount > 1 ? translations.NEW_COMMENTS_CLICK_SHOW : translations.NEW_COMMENT_CLICK_SHOW })] }); }