nazrinharris / pecunia

Massively ambitious personal finance app.
1 stars 0 forks source link

On logout, the database connection should be reset #149

Closed nazrinharris closed 7 months ago

nazrinharris commented 7 months ago

When logout, the database connection is not closed, so it uses the previous users database. Maybe just invalidate the provider or dispose of it.

Simply invalidating it is probably not sufficient. I tried it and drift gave this warning:

flutter: WARNING (drift): It looks like you've created the database class PecuniaDB 
multiple times. When these two databases use the same QueryExecutor, race 
conditions will occur and might corrupt the database. 

Whenever I needed to initialize the database (like in EntryScreen, Login/RegisterScreen, I simply invalidated the provider and watched it again. It seems to work as intended, but may lead to corrupted databases.

Then again, everytime I create a PecuniaDB instance, it most likely uses another database. And whenever a new one comes along, the old one should be inaccessible (courtesy of ref.invalidate).

nazrinharris commented 7 months ago

Should be completed with 5fabd37 in #132