Commit 6ee450c
Avoid duplicated fetches when opening a chat (also calms down the loading bar)
Fix 1:
When entering a chat, in onResume in ChatViewModel,
fetchNewMessagesWithRetry was called.
This is too aggressive pulling and should only be used when waiting for uploads to be finished.
It is also not satisfied when the response is empty and will try again.
UX wise this caused that the loading bar was shown for a long time.
fetchNewMessagesWithRetry was replaced with chatRepository.fetchNewMessages() which does a single fetch which is enough in this case.
Fix 2:
As onResume is executed on every opening of a chat, it added unnecessary requests on top of the loadInitialMessages handling. As a guard to only execute it when coming back from background, isReturningFromBackground was introduced.
In this way the scenario from #6313 is still fulfilled but too many requests on startup are avoided.
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>1 parent 697fdfb commit 6ee450c
1 file changed
Lines changed: 6 additions & 1 deletion
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
221 | 221 | | |
222 | 222 | | |
223 | 223 | | |
| 224 | + | |
224 | 225 | | |
225 | 226 | | |
226 | 227 | | |
227 | 228 | | |
228 | | - | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
229 | 234 | | |
230 | 235 | | |
231 | 236 | | |
| |||
0 commit comments