[web][native] Extract common fetching logic
Summary:
This logic is the same on both platforms and can be reused. Later in the stack I'm going to introduce the logic for thick thread fetching to this hook.
https://linear.app/comm/issue/ENG-8706/modify-message-lists-to-call-the-new-function
Depends on D13142
Test Plan: Tested on both native and web whether threads with less than 20 messages are displayed correctly and fetching all the messages, in batches, works for longer threads.
Reviewers: kamil, inka
Reviewed By: kamil
Subscribers: ashoat
Differential Revision: https://phab.comm.dev/D13147