Favorites get sometimes appended into the current view, likely race condition
- Dominant language
- Kotlin
- Stars
- 5.6k
- Forks
- 2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 92
Description
### ⚠️ Before posting ⚠️
- [X] This is a **bug**, not a question or an enhancement.
- [X] I've [searched for similar issues](https://github.com/nextcloud/android/issues) and didn't find a duplicate.
- [X] I've written a clear and descriptive title for this issue, not just "Bug" or "Crash".
- [X] I agree to follow Nextcloud's [Code of Conduct](https://nextcloud.com/contribute/code-of-conduct/).
### Steps to reproduce
1. Mark a 5 folders as favorite in the web UI, make sure these are NOT in the current folder
1. Kill the app and start from scratch, just to be sure
1. Switch repeatedly between the "Favorites" section, sometimes click on a favorite folder, go back sometimes with back button, sometimes with the arrow on the top (sorry, I couldn't find accurate steps, it seems to be timing related)
1. Be unlucky :four_leaf_clover:
### Expected behaviour
The root folder list always only contains root folder entries.
The favorite section only contains one instance of the favorites.
### Actual behaviour
### Sometimes 1
I see the favorite getting appended into the root folder list and then it quickly disappears.
### Sometimes 2
Same as 1, and all the favorites stay in the root folder list, even though they don't belong here.
### Sometimes 3
I see replication of favorite entries within the favorite section

### Android version
12
### Device brand and model
Samsung Galaxy A52s 5G
### Stock or custom OS?
Stock
### Nextcloud android app version
3.21.0
### Nextcloud server version
24.0.4
### Using a reverse proxy?
No
### Android logs
_No response_
### Server error logs
_No response_
### Additional information
I use favorites a lot and tend to trigger that issue by chance quite often.
It's only when I purposefully want to reproduce this that it doesn't happen... :four_leaf_clover:
Considering the clues (see "Actual result") and the fact that it's timing related, it looks like maybe the favorite list is being loaded in the background (sometimes the spinner is missing btw) and when the user switches, they get appended into whatever view is currently opened.
There is likely a check in the code where such entries get quickly discarded in case they don't fit (see "Sometimes 1"), I guess that the check itself sometimes runs too early or not at all, given the symptoms.
Contributor guide
Assessment
This issue has not been assessed yet.