Update all necessary follow buttons on click (#433)

This commit is contained in:
AshWhitear 2018-08-29 05:34:09 +10:00 committed by Mac Siri
parent 41db1db19d
commit ce45d0ef81

View file

@ -94,7 +94,27 @@ function handleOptimisticButtRender(butt) {
showModal('follow-button');
} else {
// Handles actual following of tags/users
assignState(butt, butt.dataset.verb);
try {
//lets try grab the event buttons info data attribute user id
var evFabUserId = JSON.parse(butt.dataset.info).id;
var requestVerb = butt.dataset.verb;
//now for all follow action buttons
document.querySelectorAll('.follow-action-button').forEach(function(fab){
try{
//lets check they have info data attributes
if( fab.dataset.info ){
//and attempt to parse those, to grab that buttons info user id
var fabUserId = JSON.parse(fab.dataset.info).id;
//now does that user id match our event buttons user id?
if ( fabUserId && fabUserId === evFabUserId ) {
//yes - time to assign the same state!
assignState(fab, requestVerb);
}
}
}catch (err) {return}
});
}catch (err) {return}
handleFollowButtPress(butt);
}
}