foivz / pop-app-flutter

Mobile application for the course Entrepreneurial venture.
2 stars 0 forks source link

Store user in a singleton User object #19

Closed mislavmatijevic closed 1 year ago

mislavmatijevic commented 1 year ago

Currently on the 'main' branch logged in user's info is saved only in the SecureStorage. While that is good for reading their basic info, it does not help to achieve simple getting of user's info wrapped in a User class when needed (e.g. API calls).

This error became visible to me when I tried implement the Wallet option (#6), but had not user object of the currently logged in user. Hence, I had to add a TODO comment in 'wallet_screen.dart' just like I did previously (when first recognizing this potential problem) in 'login_screen.dart'.

// TODO: Think about using the User class for storing all user info.

Also, this would do wonders for the "Profile" screen.

I guess a simple Auth singleton class or even a static attribute of the User class would do well to fix this. All that we need to achieve is being able to access the logged in user's username at all times!

jfletcher20 commented 1 year ago

I moved the SecureStorage calls for storing user data during login to the user class (commit https://github.com/foivz/pop-app/commit/7ece184905bfc41dca1fbd17617c8df037f6cef8) and made some simple modifications to the constructors to make them use named parameters instead for additional clarity.

Furthermore, the profile screen has been reduced to a simple logout option for now.

mislavmatijevic commented 1 year ago

Implemented refactoring was not tested. Although it shouldn't introduce any bugs, we should probably wait the event to pass before closing the #35, and only then continue to actually test and maintain the app even further.