android icon indicating copy to clipboard operation
android copied to clipboard

Multiple instances of UploadsStorageManager

Open tobiasKaminsky opened this issue 5 years ago • 2 comments

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 avatar Feb 18 '20 06:02 tobiasKaminsky

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.

tobiasKaminsky avatar Feb 18 '20 06:02 tobiasKaminsky

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:

  • register an observer on UploadsStorageManager because it currently doesn't get updated on notifyObservers()
  • receive an "upload message" in some way (through UploadMessagesReceiver)

See #5488 for 1st solution

ashpieboop avatar Feb 18 '20 08:02 ashpieboop