The text messages in our chat system could have different types of content inside.
Simple text: 'Hello!!!'
Mention: '@alexjin'
Channel: '#general'
... (Possibly URL, email, and more which we should handle in different way than the simple text)
And we should handle each one in different ways. e.g., Mention with different style, URL which should copy it to clipboard when click it, email with href of mailto, ...
I don't think it's good way to figure out all of them in the text of current format, which is simple text.
Solution
Convert the simple text to the stringified JSON for the messages with MESSAGE_TYPES.TEXT of it's type.
{
type: MESSAGE_TYPES.TEXT,
text: '[{"type":"user","user_id":"z9brRu3VHLEtDhcpFpcAB6e1LC6DKZPq4B5iaKBeP2PEf7d87pV2"},{"type":"text","text":", how are you? Can you join this channel? "}, {"type":"channel","channel_id":"z9brRu3VSfDZF3KiJzqhSWAzZGPE26ruQkrzDQLQjDSKFMkz4L2e"}]'
}
Problem
The text messages in our chat system could have different types of content inside.
And we should handle each one in different ways. e.g., Mention with different style, URL which should copy it to clipboard when click it, email with href of mailto, ... I don't think it's good way to figure out all of them in the text of current format, which is simple text.
Solution
Convert the simple text to the stringified JSON for the messages with
MESSAGE_TYPES.TEXT
of it'stype
.Thanks to @corrideat who gave me a
Aha moment
with the message below. https://okturtles.slack.com/archives/C02QF71TK1Q/p1708946968977639?thread_ts=1708930845.615099&cid=C02QF71TK1Q