-
Notifications
You must be signed in to change notification settings - Fork 43
Chat: A how to guide for replies #2712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
@jamiehenson tagged you in relation to my temporary fix to add typescript support to the docs. |
11415a5
to
fb3b799
Compare
src/data/nav/chat.ts
Outdated
{ | ||
name: 'Replies', | ||
link: '/docs/guides/chat/replies', | ||
languages: [], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An unintended use for this, but this'll do the job for suppressing the language selector. Two thoughts from here:
- (more for @m-hulbert) we already have a condition where if there is no language content detected on the page (i.e. here), then it won't show the language selector. Is there something in changing that so we only show it if there are two or more languages? Even with one language, there's nothing to switch. It would mean we hide it on this new page as normal without an override as it only has TS.
- either way, if we would like to support TS as a language, then we need to add it with a version number to the language version data and language info (for the label), guessing it would be the same version as the JS lib but not for me to say.
TLDR, this override works but a better path forward would be to either not show the language selector for single language pages, or add TS to the language data so we get the selector working with TS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about removing it if there's only 1 language. I think we should remove the ability to click the dropdown, but I personally think it makes sense to keep it for consistency (though I'll check to get a UX perspective).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reads well. Left a few comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've just dropped some high-level comments for now on how I think we should position these types of features.
src/data/nav/chat.ts
Outdated
@@ -129,6 +129,11 @@ export default { | |||
name: 'Livestream chat', | |||
link: '/docs/guides/chat/build-livestream', | |||
}, | |||
{ | |||
name: 'Replies', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest referencing quotes here as well for completeness and scanning purposes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
meta_keywords: "ably chat, message replies, message quotes, chat replies, chat quotes, javascript chat replies, typescript chat replies, chat metadata, ably chat metadata, realtime chat replies" | ||
--- | ||
|
||
This guide will show you how you could implement a simple solution for things like replies and quotes in your Ably Chat application. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm going to make the same comment as I did for file uploads in that I think it's immaterial to an end-user that there isn't a dedicated API for handling this. I think this should just sit in the existing 'feature' docs and it isn't necessary to call it out as a guide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved to rooms and no longer call out here that it's a guide.
|
||
This guide will show you how you could implement a simple solution for things like replies and quotes in your Ably Chat application. | ||
While the two features have different applications, they share the same fundamental principle of referencing other messages in the chat. | ||
As such, we will cover only replies in this guide, but the same principles can be applied to quotes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid first person "we" please 🙂
|
||
While cross-room replies are possible, this guide will focus on providing replies within the same room for simplicity. | ||
|
||
## Understanding the current limitations <a id="limitations"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is starting out on a negative upfront. I don't think we need to be apologetic or mention there isn't a dedicated API. It's possible to do them and people just want to get to the how.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reworded things a bit now as you recommended :)
|
||
By storing the serial and creation time of a message you want to quote in the metadata of a new message, you can create a reference between messages that your application can interpret and display accordingly. | ||
|
||
## Implementing replies using message metadata <a id="implementing-replies"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd keep this active voice, so 'Implement replies using message metadata'.
|
||
When displaying a reply message, you might want to show a preview of the original message, the name of the original sender, or a visual indication that it's a reply. | ||
|
||
## Finding quoted messages that aren't in local state <a id="finding-quoted-messages"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We state at the top that we're only covering replies, but then we start referencing quotes here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could change this to Finding parent messages that have been replied to...
?
2. Include that information in the metadata when sending the reply. | ||
3. Process incoming messages to check for reply metadata. | ||
|
||
### Step 1: Store information about the message being replied to <a id="store-information"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should move away from making this step-based and just discuss the process as we normally would for another feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've reworked the headings and wordings a but, but are you suggesting it needs a wider refactor for the overall flow too?
|
||
Ably Chat doesn't provide built-in UI components or reply functionality **yet**, so you'll need to implement these aspects yourself using the metadata approach described in this guide. The steps outlined in the previous sections provide the foundation for building a complete reply system in your application. | ||
|
||
## Limitations and considerations <a id="limitations-and-considerations"/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the second section covering limitations 🙂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corrected that, thanks! :D
f7110e3
to
0570485
Compare
0570485
to
a6161fe
Compare
- Seems you cannot display react and javascript at the same time, so I've had to wrap the react code in a javascript tag.
… on the replies.mdx doc.
a6161fe
to
81a41c3
Compare
Context
Chat currently doesn't have native support for things like replies and quotes, so we need a short guide to give users an idea as to how they might implement a solution with the Chat SDK in the mean time.
As a temporary fix, I've added typescript to the langs list, I've had to override the langs for the replies page in the nav bar though, so it displays nothing. This is because the selection bar doesn't seem to support typescript yet - thats fine for my doc as there is only one language for the whole doc. Also, nowhere else uses typescript tag, so it shouldn't break other docs.
CHA-1016
Description
This PR adds a guide that covers a basic replies setup, using the Chat SDK, and sending message reply metadata in the metadata field of a chat message.