Medialist / medialist-app

Mission: Increase PR team productivity 10x
0 stars 1 forks source link

Update twitter if avatar fails to load #249

Closed olizilla closed 8 years ago

olizilla commented 8 years ago

Load a placeholder avatar. In the background load the real avatar. If it succeeds, swap out the placeholder for the real one. If it fails, inform the server.

On the server, we check to see if we can load the image. If so, we ignore the update request. If not, we go update the twitter user data on for that twitterId. A observer on TwitterUsers then updates the Contact info with a new avatar / bio update / screen_name

Fixes #236

richsilv commented 8 years ago

:eyeglasses:

olizilla commented 8 years ago

Of note, reactive loading of contacts is disabled, so avatar updates are only seen when you navigate away and come back.

olizilla commented 8 years ago

Also of note, the hot avatar swap is only done for the tables at the moment. If this PR passes muster then we can decided how to generalise it for user and contacts and other areas where avatars appear. This PR solves the core problem of kicking the server to go replace broken contact avatars.

richsilv commented 8 years ago

I'm just digging into the lack of reactivity. The big problem is that when you add a new contact, they don't get an avatar until you reload the page, which isn't really acceptable from a UI perspective as you've just shown them the avatar in the modal.

The avatar is present in the contact object on the client, and is updated automatically in master, so I'm just trying to work out what it is in this branch which is preventing that from happening any more.

richsilv commented 8 years ago

Okay, my final musing on this:

If the Contact avatar is out of date, we're starting a process to update the TwitterUser avatar if necessary and only then update the Contact avatar.

So if the Contact avatar becomes wrong for some reason, but the associated TwitterUser object is still fine, nothing happens.

The circumstances under which this would occur appear to be where a user has selected another avatar for that contact, like from LinkedIn or something. In that case, if the alternative image becomes no good, should we still be updating the contact avatar with the twitter avatar, if it's good?

It's one for the future, but it just seems faintly odd that a bad Contact avatar tells the server to check the TwitterUser doc, but not necessarily update the Contact doc as a result.

olizilla commented 8 years ago

Yep. I think that's one to tackle as part of the "bio is from twitter, not editable, and keep in sync" work. While working on this I became increasingly sure that we need a strategy for managing local view of the contact vs the additional info provided by socials, and one day, by the medialist jounro db.

richsilv commented 8 years ago

All good, works very nicely.