This diff refactors TypeaheadTooltip component on native to be more generic.
Depends on D8896.
patryk on Aug 22 2023, 1:56 AM.Authored by
Well, I had two options while writing solution for showing chats in typeahead tooltip:
Decided to take extra steps and made this component reusable in the future.
We use getTypeaheadTooltipActions to extract user info and getTypeaheadTooltipButtons as typeahead button renderer on web, so extracting typeaheadTooltipButton and typeaheadTooltipSuggestionTextExtractor to typeahead utils seems like a better idea.
I'm confused about your usage of parameters everywhere (<SuggestionItemType>). Is the tooltip ever rendering only one of TypeaheadUserSuggestionItem or TypeaheadChatSuggestionItem (as I'm guessing it will be called)? Why don't you just use TypeaheadSuggestionItem (that I'm guessing will be TypeaheadUserSuggestionItem | TypeaheadChatSuggestionItem)? Is it ever an incorrect type in any way?
Could you also explain what the execute in TypeaheadTooltipActionItem is?
TypeaheadSuggestionItem will be equal to (as you correctly guessed) TypeaheadUserSuggestionItem | TypeaheadChatSuggestionItem in the next diff: renderer function needs to decide what avatar to render since we use separate components to render user and thread avatars.
See this. execute is a onPress handler. TypeaheadTooltipActionItem is a copy of this type, which is moved to lib.
We discussed offline whether this diff is truly necessary. While I could refactor this component into MentionTypeaheadTooltip, doing so would also require changes to other elements, such as comments within this component. Given that this component effectively resolves numerous issues associated with displaying the typeahead tooltip, renaming all of its parts might not be worthwhile. Is there a possibility of future reuse? Well, I have an idea: we could introduce some commands in the input bar. For instance, by typing !kick inka, we could initiate the removal of the user inka from the chat. Upon typing ! in the input bar, all possible commands would become visible.
Adding @atul as a reviewer in case he has any comments about React performance here