From 297664bfe202f16204f57e75ce0babfaf2f98785 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 20 Dec 2022 14:50:04 -0600 Subject: [PATCH] Fix post-meta truncation on android --- src/view/com/util/PostMeta.tsx | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) diff --git a/src/view/com/util/PostMeta.tsx b/src/view/com/util/PostMeta.tsx index 42c725a60d..77dfbb4857 100644 --- a/src/view/com/util/PostMeta.tsx +++ b/src/view/com/util/PostMeta.tsx @@ -20,6 +20,24 @@ interface PostMetaOpts { } 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 ( - {opts.authorDisplayName || opts.authorHandle} - -  {opts.authorHandle} - + {displayName} + {handle ? ( + +  {handle} + + ) : undefined} @@ -38,7 +58,7 @@ export function PostMeta(opts: PostMetaOpts) {