[lib] Extend RobotextParams to include parentThreadInfo
Summary:
Currently, the app will crash if you attempt to create a sidebar from a CHANGE_ROLE robotext message. This is because when attempting to create the role, the threadInfo passed into robotextForMessageInfo from chat-selectors.js is undefined. The reason for this is in a pending sidebar, if you check the threadID, it is something like pending/sidebar/256|90231. Here, the 256|90231 corresponds to the source message that the sidebar is being created from, i.e. the message that the user clicks 'create thread' on.
To resolve this, we want to extend the RobotextParams to include a potentially null parentThreadInfo, and modify the call site in chat-selectors.js. To get the parentThreadInfo, we'd do the following:
- Parse out the source message ID from the pending sidebar thread ID
- Access messageStore.messages for the source message
- Read the threadID from the source message info
- Access the ThreadInfo from the threadInfos object using the newly found threadID
With this, we will now be able to access either the regular threadInfo or the parentThreadInfo in the CHANGE_ROLE message spec, no longer crashing the app. We can now re-allow sidebars to be created from CHANGE_ROLE messages as well.
One thing to note is the other callsite for robotextForMessageInfo is in getMessageTitle. Though when looking into what threadInfo is passed into it, it already receives the parentThreadInfo from createPendingSidebar. So I don't think we should have to update anything there.
This is @ashoat's suggestion (#5) addressing ENG-4981.
Test Plan:
- Sending messages in parent threads still works
- Creating sidebars from non-robotext messages still works
- Creating sidebars from CHANGE_ROLE messages now works and no longer crashes
- Reloaded the app during the process of making a sidebar from a CHANGE_ROLE message (while it's pending) and it doesn't crash
Reviewers: ashoat, atul, ginsu
Reviewed By: ashoat
Subscribers: tomek, ashoat
Differential Revision: https://phab.comm.dev/D9249