ucladevx / Bruin-Bite-iOS

Mozilla Public License 2.0
8 stars 1 forks source link

Rework networking code #102

Closed HirdayGupta closed 5 years ago

HirdayGupta commented 5 years ago

This issue is too large to document properly here, but @sjl1826 and I have discussed multiple facets of this in length at various meetings and we have notes that we will put here eventually.

Some of the things we discussed -

  1. A singleton implementation to globalize user state (stored in a struct UserModel) through a UserManager class - that handles asynchronous network calls using the Protocol-Delegate method.
  2. Persistent login techniques using the access & refresh tokens.
    • On app launch - attempt to login using cached (in UserDefaults) refresh token.
    • If signing up/logging back in, use the flow we discussed.
  3. Storage of all data (except accessToken) in UserDefaults to enable offline viewing of the app.
  4. Difference between a "failed login" and an "offline". - failed login should log out the user but an "offline" should allow the user to view the app in a "view only" mode - i.e. all API requests should fail with appropriate error messages that the UI code will then promise to handle.

This issue will be continuously updated as I get time to put more details down.

@sjl1826 I would love to have this completed by Sunday, November 18. Please plan to finish it by then.

HirdayGupta commented 5 years ago

Closed by #105