Anki-Android icon indicating copy to clipboard operation
Anki-Android copied to clipboard

ChangeManager: not undoable operation should also notifies

Open Arthur-Milchior opened this issue 6 months ago • 5 comments

Right now, notifySubscribers is called on any undoable operation and on new day. (Funnily enough "undo" is an undoableOp too, so "undo" also notifies the subscriber) It's not yet done on undoable operations. Which means that, for example, the widget does not get notified that there its content should be updated.

So, this issue has two tasks:

  • find all operation that change the database and can't be undone.
  • ensure that all such operations calls notifySubscribers.

If there are actions that you find that can't be undone, and you can't easily find how to create the notification, you can simply create a new issue. Otherwise, you can directly create a PR to add the notification.

Right now, the operations I know of are:

  • syncing
  • full sync
  • check card
  • check database

I should note that those four operations are done in the deck picker, and we hard coded the deck picker to update when those operations are done. Previously, no other views could be opened while the deck picker was on screen, so it was never necessary to notify subscribers, because the only subscriber is the deck picker, and it was already listening.

Now that we are introducing widgets that display the state of the collection, it'll be necessary to notify the observers.

I think the object sent for notification should be simply OpChanges with all fields set to true, given that it's too hard to know what actually was changed.

Honestly, I don't even know how to find all tasks that need to be updated. I assume most of those tasks are in GeneratedBackend.kt. But it contains 445 functions, and there is no way to read all of them and be certain that we won't miss any function that change the collection and is not undoable.

Arthur-Milchior avatar Aug 24 '24 02:08 Arthur-Milchior