kfiroo / react-native-cached-image

CachedImage component for react-native
MIT License
938 stars 470 forks source link

Changing Profile Image #77

Open bexoss opened 6 years ago

bexoss commented 6 years ago

Thanks for sharing fantastic library. I got stuck with managing profile picture. The cached image looks like working well, but if the user change his profile picture the image won't be refreshed.

Let's suppose there is a profile screen using CachedImage.

<CachedImage source={{uri: 'http://myapp.com/user001'}} />

If a user change profile picture, server will get his picture and overwrite it. (Because it saved with user name).

At this point, local cached profile image and server's profile image is different. right? And then how can I notice to device

Please, the server's image changed. Cache fresh one again.

?

I tried when I success upload new image, remove cached image using cachedImageProvider, If I do that the image become empty. And without this, the image won't changed to latest one. How can I use it properly? It is because of redux problem?

Now I am using like this... <CachedImage source={{uri: this.props.user.profileImageRef}} />

kfiroo commented 6 years ago

Hey @bexoss What do you mean "the image become empty"? You get a blank image? Can you see that the new image is being downloaded?

Let's try to get more details so we can work this out

It's a bit hard to replicate this kind of thing without a server..

kfiroo commented 6 years ago

Also, this might be related https://github.com/kfiroo/react-native-cached-image/issues/47

redwind commented 6 years ago

@bexoss: i think you should manage user's profile image version by redux state in client. Then append suffix query in uri like http://myapp.com/user001?v=this.props.avatar_version When profile image changed, increase avatar_version value, image should recached

kfiroo commented 6 years ago

@bexoss @redwind This is indeed an issue with this lib right now, suggestions for handling this internally are most welcome!