[lib] Introduce chat mention context
Summary:
In the previous implementation, we were correctly memoizing computations, but it was done using hooks, so in each component where these were used, we were doing the same computations again. In this approach, the memoization is moved to a new context, so that computations aren't repeated.
Depends on D9465
https://linear.app/comm/issue/ENG-5224/ashoats-js-thread-freezes-on-app-start-on-build-268
Test Plan:
Check if getChatMentionCandidates function invocations happen every time with new inputs (by adding code that saves the input to a global variable, compares new arguments with the previous ones, and console logs the result).
Check if chat mentioning works correctly on the web and native.
Reviewers: kamil, inka, atul, ashoat
Reviewed By: ashoat
Subscribers: wyilio
Differential Revision: https://phab.comm.dev/D9466