Skip to content

Commit

Permalink
fix: cannot unfollow user who blocks following (#38)
Browse files Browse the repository at this point in the history
  • Loading branch information
imorland authored Feb 12, 2024
1 parent ffcb4bb commit f5c187c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
23 changes: 21 additions & 2 deletions js/src/forum/addFollowControls.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,29 @@ function openFollowLevelModal(user) {

export default function addFollowControls() {
extend(UserControls, 'userControls', function (items, user) {
const followingBlockingUser = !user.canBeFollowed() && user.followed();
const icon = 'fas fa-user-friends';

if (followingBlockingUser) {
items.add(
'unfollow',
<Button
icon={icon}
onclick={async () => {
const x = await user.save({ followUsers: null });
m.redraw();
}}
>
{app.translator.trans('ianm-follow-users.forum.user_controls.unfollow_button')}
</Button>
);
}

if (
!app.session.user ||
app.session.user === user ||
!user.canBeFollowed() ||
followingBlockingUser ||
(app.forum.attribute('ianm-follow-users.button-on-profile') &&
!(app.current.data.routeName === 'fof_user_directory' && app.forum.attribute('userDirectorySmallCards')))
) {
Expand All @@ -32,8 +51,8 @@ export default function addFollowControls() {

items.add(
'follow',
<Button icon="fas fa-user-friends" onclick={openFollowLevelModal.bind(this, user)}>
{app.translator.trans(`ianm-follow-users.forum.user_controls.${user.followed() ? 'unfollow_button' : 'follow_button'}`)}
<Button icon={icon} onclick={openFollowLevelModal.bind(this, user)}>
{app.translator.trans(`ianm-follow-users.forum.user_controls.${user.followed() ? 'change_button' : 'follow_button'}`)}
</Button>
);
});
Expand Down
4 changes: 3 additions & 1 deletion resources/locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ ianm-follow-users:

user_controls:
follow_button: => ianm-follow-users.lib.follow
unfollow_button: => ianm-follow-users.lib.change_follow_type
unfollow_button: => ianm-follow-users.lib.unfollow
change_button: => ianm-follow-users.lib.change_follow_type

settings:
notify_new_follower_label: Someone follows me
Expand Down Expand Up @@ -113,6 +114,7 @@ ianm-follow-users:

follow: Follow
change_follow_type: Change follow type
unfollow: Unfollow

follow_levels:
unfollow:
Expand Down

0 comments on commit f5c187c

Please sign in to comment.