refactor: split search requests from LeftSidebar#18686
Conversation
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
- introduce new composable with search-related methods and refs - improve promises handling (single toast for errors, GC for cancel functions) - extendable to search-messages feature Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
| if ( | ||
| cancelSearchListedConversations !== null | ||
| || cancelSearchPossibleConversations !== null | ||
| ) { | ||
| // New search request was triggered, do not proceed | ||
| return | ||
| } |
There was a problem hiding this comment.
It means that the current search is more recent and hence the cancel of the previous search should be cancelled instead of skipping the current one
There was a problem hiding this comment.
Recent search triggers cancel for previous one. Here we catching the case "previous request cancelled, promises resolved, proceeding with this function" - but we should not proceed for previous one
Or comment itself is confusing?
| let cancelSearchListedConversations: ReturnType<typeof CancelableRequest>['cancel'] | null = null | ||
| let cancelSearchPossibleConversations: ReturnType<typeof CancelableRequest>['cancel'] | null = null |
There was a problem hiding this comment.
This seems part of the composable state, do we want a shared state across all search instances that's why they are outside?
There was a problem hiding this comment.
We don't need more than one instance, but agreed that this might be the limitation, fixed if we put it inside
☑️ Resolves
AI (if applicable)
🖌️ UI Checklist
🏁 Checklist