import React from 'react' import {StyleSheet, View} from 'react-native' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {Link} from '../util/Link' import {Text} from './text/Text' import {PostDropdownBtn} from './forms/DropdownButton' import {s} from '../../lib/styles' import {ago} from '../../../lib/strings' interface PostMetaOpts { itemHref: string itemTitle: string authorHref: string authorHandle: string authorDisplayName: string | undefined timestamp: string isAuthor: boolean onCopyPostText: () => void onDeletePost: () => void } export function PostMeta(opts: PostMetaOpts) { let displayName = opts.authorDisplayName || opts.authorHandle let handle = opts.authorHandle // HACK // Android simply cannot handle the truncation case we need // so we have to do it manually here // -prf if (displayName.length + handle.length > 26) { if (displayName.length > 26) { displayName = displayName.slice(0, 23) + '...' } else { handle = handle.slice(0, 23 - displayName.length) + '...' if (handle.endsWith('....')) { handle = handle.slice(0, -4) + '...' } } } return ( {displayName} {handle ? (  {handle} ) : undefined} · {ago(opts.timestamp)} ) } const styles = StyleSheet.create({ meta: { flexDirection: 'row', alignItems: 'center', paddingTop: 2, paddingBottom: 2, }, metaItem: { paddingRight: 5, }, })