-
Notifications
You must be signed in to change notification settings - Fork 78
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
feat: threads 2.0 #1204
feat: threads 2.0 #1204
Conversation
Size Change: +10.9 kB (+3%) Total Size: 343 kB
|
e63fbef
to
d0a6309
Compare
} from './types'; | ||
import { addToMessageList, formatMessage } from './utils'; | ||
|
||
type ThreadReadStatus<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Record< |
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.
Where is the thread read status updated / based on what WS event?
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.
hmm right now I am delegating this part to SDK implementation. But I will think about it for 2nd round, maybe we can handle it by default within js client.
id: string; | ||
latestReplies: FormatMessageResponse<StreamChatGenerics>[] = []; | ||
participants: ThreadResponse['thread_participants'] = []; | ||
message: FormatMessageResponse<StreamChatGenerics>; |
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.
Is this the thread parent message?
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.
yes
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.
don't we want to call it parentMessage as the thread reply contains parent_id?
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 actually called it parentMessage
before, but somehow felt it easier to just call it a message. I mean it is assumed that thread will have 1 message and multiple replies.
But feel free to change it later during sdk integration if everyone agrees on it. :)
src/client.ts
Outdated
@@ -2595,6 +2599,85 @@ export class StreamChat<StreamChatGenerics extends ExtendableGenerics = DefaultG | |||
); | |||
} | |||
|
|||
async queryThreads(options?: { |
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.
Is there a plan to update client.activeChannels[key].state.threads with the latest date with this query or with any other API call in this class?
How will we then update the state of activeChannels if we let's say click on a message that should take us to that thread in a given channel?
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.
latest date?
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.
sorry latest data - typo
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.
Good point. If needed we can, didn't feel any need at the moment.
20b4726
9f03a62
to
34c8a89
Compare
@MartinCupela I have made the suggested changes and I am going to merge this one to unblock backend PR. But feel free to suggest more changes, happy to do them on a separate PR. During SDK integration we will need probably bunch new methods and logic for event handlign. |
In general I think we will need to
|
Yeah thats correct. I think one more challenging part is to build a wrapper component similar to |
CLA
Description of the changes, What, Why and How?
So we are introducing threads 2.0, which will help SDKs build "Threads" section like slack.
Basic Usage
QA Tests for thread list might be helpful to understand the usage as well
Basic usage of queryThreads in sdk:
client.queryThreads
endpoint returns list of threads sorted in descending order of latest reply date time.watch
param to this endpoint. This will subscribe the user to corresponding channels of the threads that are returned. So channel may not exist in ChannelList but user will be watching this channel due to threads endpoint.Handling a new reply on thread
Only participants of the thread receive an event whenever there is a new reply on the thread -
notification.thread_message_new
Handling message updated on thread
Updates to messages should be handled as usual via
message.updated
andmessage.deleted
event:Changelog