dexie / Dexie.js

A Minimalistic Wrapper for IndexedDB
https://dexie.org
Apache License 2.0
11.5k stars 642 forks source link

Improve logout behavior #2019

Open b-straub opened 3 months ago

b-straub commented 3 months ago

Suggestions to improve logout behavior (version 4.0.7)

https://github.com/dexie/Dexie.js/blob/795f60c8104317f3b2d9ddcd0c20c84fb74fe83e/addons/dexie-cloud/src/authentication/logout.ts#L62

when not online an 'error in syncIfPossible()' exception will be thrown here https://github.com/dexie/Dexie.js/blob/795f60c8104317f3b2d9ddcd0c20c84fb74fe83e/addons/dexie-cloud/src/sync/syncIfPossible.ts#L93 but not propagated upstream in order to catch and inform user that logout is not possible.

dfahlander commented 3 months ago

Thanks!

Basically a logout should be a client action only - it deletes the database and then tries to do an initial sync based on anonymous user to get schema and public data in sync. If this sync fails, user is still technically logged out but hasn't got public data from the server yet. But as soon as the app goes online again it should do the initial sync.

Is the bug happening when client is offline, there are unsynced changes, and user choose to log out? Does it leave the db in a buggy state?

b-straub commented 3 months ago