fastcomments-react-native-sdk
Version:
React Native FastComments Components. Add live commenting to any React Native application.
16 lines (15 loc) • 997 B
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { Text, TouchableOpacity } from "react-native";
import { iterateCommentsTreeState } from "../services/comment-trees";
function showHiddenComments(state) {
iterateCommentsTreeState(state.commentsTree, (comment) => {
if (comment.hidden.get()) {
comment.hidden.set(false);
}
});
state.newRootCommentCount.set(0);
}
export function ShowNewLiveCommentsButton({ state, styles }) {
const newRootCommentCount = state.newRootCommentCount.get();
return _jsxs(TouchableOpacity, { style: styles.showNewLiveComments?.button, onPress: () => showHiddenComments(state), children: [_jsx(Text, { style: styles.showNewLiveComments?.count, children: Number(newRootCommentCount).toLocaleString() }), _jsx(Text, { style: styles.showNewLiveComments?.text, children: newRootCommentCount > 1 ? state.translations.NEW_COMMENTS_CLICK_SHOW.get() : state.translations.NEW_COMMENT_CLICK_SHOW.get() })] });
}