[lib] Use queue when processing inbound messages from the DB
Summary:
Use the queue instead of processing operations in a loop.
https://linear.app/comm/issue/ENG-9470/mitigate-risks-of-effects-running-on-outdated-data
Test Plan:
Disabled inbound messages processing by commenting out handleOlmMessageToDevice in usePeerToPeerMessageHandler.
On one device, created a thread, changed its name, and then its description. These operations weren't processed on another device. Refreshed the app so that the operations are read from the DB and processed. Made sure that the result is correct.
Checked what was the behavior before this diff. Surprisingly, it was the same. Using the queue here sounds more correct and feels safer, but the previous approach also works correctly.
Reviewers: kamil, inka
Reviewed By: kamil
Subscribers: ashoat
Differential Revision: https://phab.comm.dev/D13623