native: render post plaintext preview from intermediate PostContent
fixes TLON-4168
🧞 Hidden in this PR is a design proposition... This PR promotes the app model
PostContent(different fromapi.PostContent) as the canonical intermediate representation for post content. https://github.com/tloncorp/tlon-apps/blob/dd0972daaca2272341cc3696030f88f03543aa72/packages/shared/src/logic/postContent.ts#L143 If accepted, we'll use thisPostContentwhenever interpreting a post's content; then, we'll move the API post schema to matchPostContent.
What changed?
The big change here is in how the notifications render text: Black icon notification is from this PR's changes, white icon is current Testflight without this PR. iPhone/desktop in-app renderings are included for reference, since some formatting is not consistent (iPhone screenshots include this PR's change, but the screenshotted surfaces should not have been affected).
| iPhone | Desktop | |
|---|---|---|
The plaintext renderer is also used in the "latest post" summary:
| Before this change | After this change |
|---|---|
The renderer is a little bit configurable (in case we want to e.g. use a double space for newlines): https://github.com/tloncorp/tlon-apps/blob/6b38d5abc05ce72d33054d7e2c3afdf24608bfee/packages/shared/src/logic/postContent.ts#L145-L164
Why not update the existing getTextContent?
ub.getTextContent operated directly off of the API's post.content – part of this PR is moving to using the in-app PostContent as the canonical intermediate representation (which means we get to share logic like automatically turning list items into block-level items, and eventually having a conversion layer for different post content schemas).
How did I test?
I added a toggle to the ChatMessage.All fixture to preview how posts are rendered into plaintext:
https://github.com/user-attachments/assets/6f02c259-46b9-4ea6-9d3c-cd87233ca669
other stuff for reviewers:
- [wip] Move post content utils to shared/ is marked
wipbecause the project will not build without the subsequent commit, but combining the commits seemed like it'd be noisy - Delete unused code was intended to only remove the dead
getTextContentand its helpers, but turned out to be a more aggressive cleanup – I did this by deleting all unused functions, including those which wereexported and not imported somewhere else, which ended up removing a handful of other unused members.
End results look great, will leave the code review to others. Nice work!
Merge 1ca53e5 was a little hairy – I tested by sending **bold** *italic* as a post, and then checked the chat list "latest post" preview to ensure there was no double spacing.