nextcloud / android

📱 Nextcloud Android app
https://play.google.com/store/apps/details?id=com.nextcloud.client
GNU General Public License v2.0
4.32k stars 1.78k forks source link

Multiple instances of UploadsStorageManager #5487

Open tobiasKaminsky opened 4 years ago

tobiasKaminsky commented 4 years ago

Bug:

  • have 3 images in Camera
  • upload them
  • install this branch
  • enable "upload previously"
  • enable upload for folder "Camera"
  • see that three items as conflict in upload list view +1
  • click on one, select "keep server"
  • still see three items --> it should be two

This is a display bug, if you refresh up to date list is displayed.

FileDownloader L645 and UploadsStorageManager L238 -> UploadListAdapter doesn't register as an Observer of UploadsStorageManager. But there are multiple instances (see screenshot) of UploadsStorageManager so it doesn't work anyway. I need your help @tobiasKaminsky on how you would make this class an effective singleton; else there is no way to properly update the view.

image

@tobiasKaminsky up on my answers to your comments btw.

Originally posted by @ArisuOngaku in https://github.com/nextcloud/android/pull/4788#issuecomment-586173105

tobiasKaminsky commented 4 years ago

But there are multiple instances (see screenshot) of UploadsStorageManager so it doesn't work anyway.

This should per se be no problem, as all queries are against a database, which synchronizes it. I guess that we just do not have a callback (or obsverable, as you said) to detect that we have to reload the list.

ashpieboop commented 4 years ago

Registering a ContentObserver on the database means we have to unregister it once we're done with the instance of UploadsStorageManager. A new instance of this almost every time an activity is opened (and more), this gets hard to be tracked.

Making this a singleton (should be fine) means that there's only one ContentObserver on the db.

Anyway UploadListAdapter has to either:

See #5488 for 1st solution