Reset follow button after blocking a user

This commit is contained in:
Karina Kwiatek 2022-06-11 23:08:41 +02:00 committed by Karina Kwiatek
parent c173c4a17d
commit a48a187086
1 changed files with 9 additions and 4 deletions

View File

@ -56,16 +56,14 @@ export function userActionHandler(event: Event): void {
button.classList.add('btn-default'); button.classList.add('btn-default');
break; break;
case 'unfollow': case 'unfollow':
button.dataset.action = 'follow'; resetFollowButton(button);
button.innerText = I18n.translate('views.actions.follow');
button.classList.remove('btn-default');
button.classList.add('btn-primary');
break; break;
case 'block': case 'block':
button.dataset.action = 'unblock'; button.dataset.action = 'unblock';
button.querySelector('span').innerText = I18n.translate('views.actions.unblock'); button.querySelector('span').innerText = I18n.translate('views.actions.unblock');
button.classList.remove('btn-primary'); button.classList.remove('btn-primary');
button.classList.add('btn-default'); button.classList.add('btn-default');
resetFollowButton(document.querySelector<HTMLButtonElement>('button[data-action="unfollow"]'));
break; break;
case 'unblock': case 'unblock':
button.dataset.action = 'block'; button.dataset.action = 'block';
@ -76,4 +74,11 @@ export function userActionHandler(event: Event): void {
} }
} }
}); });
}
function resetFollowButton(button: HTMLButtonElement) {
button.dataset.action = 'follow';
button.innerText = I18n.translate('views.actions.follow');
button.classList.remove('btn-default');
button.classList.add('btn-primary');
} }