anitab-org / mentorship-android

Mentorship System is an application that matches women in tech to mentor each other, on career development, through 1:1 relations during a certain period of time. This is the Android application of this project.
https://github.com/anitab-org/mentorship-android/raw/apk/app-debug.apk
GNU General Public License v3.0
164 stars 379 forks source link

Locally store user profile info #714

Open Priyansh-Kedia opened 4 years ago

Priyansh-Kedia commented 4 years ago

In the current app, whenever the profile section is opened, an API call is made. This kind of API calling abuses the use of API. As the profile info is just small texts, they can be stored locally so that every time profile is opened, there is no API call

Describe the solution you'd like Store profile information locally and update it accordingly

Priyansh-Kedia commented 4 years ago

@isabelcosta @m-murad May I work on this

Also as this is related to calls to the backend API, @mtreacy002 your reviews would be helpful

devptyagi commented 4 years ago

@isabelcosta @foongminwong If this one's available, I'd like to work on it.

Priyansh-Kedia commented 4 years ago

@devptyagi I was waiting for approval on this issue Nevertheless, can you discuss the approach?

mtreacy002 commented 4 years ago

Can you share your thoughts on how you'll store it locally, @Priyansh-Kedia?

Priyansh-Kedia commented 4 years ago

Hello @mtreacy002 I was thinking of storing the profile info you preferences in android

Priyansh-Kedia commented 4 years ago

The thing is At this time, whenever we open the profile fragment, API call is made. I think that it is a wrong use of API calling as the information does not change

mtreacy002 commented 4 years ago

That makes sense. Are you thinking of using cache or something like that?

Priyansh-Kedia commented 4 years ago

Yes In the local caches

mtreacy002 commented 4 years ago

sounds good to me, but we need maintainers or @anitab-org/coding-team approval first so you can start working on it.

Priyansh-Kedia commented 4 years ago

Yeah Thanks for your reviews @mtreacy002

aditmehta9 commented 4 years ago

@Priyansh-Kedia do you want to work on this issue?

Priyansh-Kedia commented 4 years ago

Yes

aditmehta9 commented 4 years ago

Assigned.

Priyansh-Kedia commented 4 years ago

Thanks @aditmehta9

ahk4815 commented 3 years ago

is this issue available @isabelcosta ? I am interested to work on it to implement storing the user info in local cache(Android SharedPreferences) .

aditmehta9 commented 3 years ago

is this issue available @isabelcosta ? I am interested to work on it to implement storing the user info in local cache(Android SharedPreferences) .

Sure, this issue can be assigned to you, but Priyansh had asked to re-assign this issue to him on his PR so the decision is up to Isabel or Vaishnavi who should work on this issue?

vj-codes commented 3 years ago

@aditmehta9 hey @Priyansh-Kedia has contributed here before, but @ahk4815 hasn't so it'll be nice to assign it to @ahk4815 . What say, sounds good?

Priyansh-Kedia commented 3 years ago

Sure @vj-codes

vj-codes commented 3 years ago

Assigning you @ahk4815 Happy coding!

ahk4815 commented 3 years ago

solving this issue will take some more time. Can it get extended to a couple of days more?

Priyansh-Kedia commented 3 years ago

solving this issue will take some more time. Can it get extended to a couple of days more?

How are you planning to do it @ahk4815

ahk4815 commented 3 years ago

solving this issue will take some more time. Can it get extended to a couple of days more?

How are you planning to do it @ahk4815

Thanks @Priyansh-Kedia for asking .A PreferenceManager class is already present in the project. I would be adding the functions of updating and fetching user's profile details in the preferenceManager class. Since the profile data is of custom class, it would be required to convert this into json string and upload in the shared preference according to this Custom Object in preference . In the getProfile() function of ProfileViewModel class i will fetch the user details from the shared preference. In case the details are NULL or not set it will get fetched by api call and updated in the preference. In the updateProfile() of the same class, updation in the shared preference for profile details will be done besides the api calls which are being made. I hope i am clear in this explanation?

Priyansh-Kedia commented 3 years ago

Don't you think datastore should be used instead of preference manager, as datastore provides type safety and is main thread safe. Also shared preferences has been deprecated.

What do you think @vj-codes @isabelcosta

ahk4815 commented 3 years ago

Don't you think datastore should be used instead of preference manager, as datastore provides type safety and is main thread safe. Also shared preferences has been deprecated.

What do you think @vj-codes @isabelcosta

Yeah Shared Preference is depreciated. A Preference Manager class for SharedPreference was already present in the current project for authorization related work. So i thought of implementing the same for this issue. But datastore is currently preferred over sharedPreference for the reason stated by @Priyansh-Kedia. So i can work with the same for this issue.

Priyansh-Kedia commented 3 years ago

Don't you think datastore should be used instead of preference manager, as datastore provides type safety and is main thread safe. Also shared preferences has been deprecated.

What do you think @vj-codes @isabelcosta

Yeah Shared Preference is depreciated. A Preference Manager class for SharedPreference was already present in the current project for authorization related work. So i thought of implementing the same for this issue. But datastore is currently preferred over sharedPreference for the reason stated by @Priyansh-Kedia. So i can work with the same for this issue.

Sounds good What do you think @vj-codes

epicadk commented 3 years ago

Don't you think datastore should be used instead of preference manager, as datastore provides type safety and is main thread safe. Also shared preferences has been deprecated.

What do you think @vj-codes @isabelcosta

Datastore is still in alpha ,I think we should wait for a stable release before using it. Also I don't see the deprecation warning for shared preferences in the docs can you share the link where you saw the shared preference deprecated warning? Are you talking about the PreferenceManager class ,because that has been deprecated.

ahk4815 commented 3 years ago

Don't you think datastore should be used instead of preference manager, as datastore provides type safety and is main thread safe. Also shared preferences has been deprecated. What do you think @vj-codes @isabelcosta

Datastore is still in alpha ,I think we should wait for a stable release before using it. Also I don't see the deprecation warning for shared preferences in the docs can you share the link where you saw the shared preference deprecated warning? Are you talking about the PreferenceManager class ,because that has been deprecated.

For updating the user's profile, two tasks needs to be performed: Firstly, an API call which is updating the details Secondly, the user's data in the Shared Preference needs to be updated as well.

The API call feature is already implemented in the current project. Incase the device is offline(not connected to internet) the API call will fail but the shared preference feature will store the info in the local cache. So now a discrepancy of data will be present in the cache ( having updated info) and the database(having previous version of data). This error will happen only if the user tries to edit the profile while device is offline. So far i have implemented the fetching and updating of user profile from the shared preference in the app. One simple solution i have thought is that is the device is offline, the updating operation will not take place in Shared Preference. Is it okay @vj-codes @isabelcosta

kartikeysaran commented 3 years ago

I am working on this issue