diff --git a/extensions/subscriptions/extend.php b/extensions/subscriptions/extend.php index 92bcc9883..97259d8e9 100644 --- a/extensions/subscriptions/extend.php +++ b/extensions/subscriptions/extend.php @@ -40,7 +40,7 @@ return [ (new Extend\ApiSerializer(DiscussionSerializer::class)) ->attribute('subscription', function (DiscussionSerializer $serializer, Discussion $discussion) { if ($state = $discussion->state) { - return $state->subscription ?: false; + return $state->subscription; } }), diff --git a/extensions/subscriptions/js/src/forum/addSubscriptionControls.js b/extensions/subscriptions/js/src/forum/addSubscriptionControls.js index 1e150c104..530ce7723 100644 --- a/extensions/subscriptions/js/src/forum/addSubscriptionControls.js +++ b/extensions/subscriptions/js/src/forum/addSubscriptionControls.js @@ -10,8 +10,8 @@ export default function addSubscriptionControls() { if (app.session.user && !(context instanceof DiscussionPage)) { const states = { none: {label: app.translator.trans('flarum-subscriptions.forum.discussion_controls.follow_button'), icon: 'fas fa-star', save: 'follow'}, - follow: {label: app.translator.trans('flarum-subscriptions.forum.discussion_controls.unfollow_button'), icon: 'far fa-star', save: false}, - ignore: {label: app.translator.trans('flarum-subscriptions.forum.discussion_controls.unignore_button'), icon: 'fas fa-eye', save: false} + follow: {label: app.translator.trans('flarum-subscriptions.forum.discussion_controls.unfollow_button'), icon: 'far fa-star', save: null}, + ignore: {label: app.translator.trans('flarum-subscriptions.forum.discussion_controls.unignore_button'), icon: 'fas fa-eye', save: null} }; const subscription = discussion.subscription() || 'none'; diff --git a/extensions/subscriptions/js/src/forum/components/SubscriptionMenu.js b/extensions/subscriptions/js/src/forum/components/SubscriptionMenu.js index fe6d6e147..559d272db 100644 --- a/extensions/subscriptions/js/src/forum/components/SubscriptionMenu.js +++ b/extensions/subscriptions/js/src/forum/components/SubscriptionMenu.js @@ -11,7 +11,7 @@ export default class SubscriptionMenu extends Dropdown { this.options = [ { - subscription: false, + subscription: null, icon: 'far fa-star', label: app.translator.trans('flarum-subscriptions.forum.sub_controls.not_following_button'), description: app.translator.trans('flarum-subscriptions.forum.sub_controls.not_following_text') @@ -64,11 +64,11 @@ export default class SubscriptionMenu extends Dropdown { const buttonAttrs = { className: 'Button SubscriptionMenu-button ' + buttonClass, icon: buttonIcon, - onclick: this.saveSubscription.bind(this, discussion, ['follow', 'ignore'].indexOf(subscription) !== -1 ? false : 'follow'), + onclick: this.saveSubscription.bind(this, discussion, ['follow', 'ignore'].indexOf(subscription) !== -1 ? null : 'follow'), title: title }; - if ((notifyEmail || notifyAlert) && subscription === false) { + if ((notifyEmail || notifyAlert) && subscription === null) { buttonAttrs.oncreate = buttonAttrs.onupdate = vnode => { $(vnode.dom).tooltip({ container: '.SubscriptionMenu', diff --git a/extensions/subscriptions/src/Listener/SaveSubscriptionToDatabase.php b/extensions/subscriptions/src/Listener/SaveSubscriptionToDatabase.php index d887208f8..18a53831f 100755 --- a/extensions/subscriptions/src/Listener/SaveSubscriptionToDatabase.php +++ b/extensions/subscriptions/src/Listener/SaveSubscriptionToDatabase.php @@ -18,7 +18,7 @@ class SaveSubscriptionToDatabase $discussion = $event->discussion; $data = $event->data; - if (isset($data['attributes']['subscription'])) { + if (array_key_exists('subscription', $data['attributes'])) { $actor = $event->actor; $subscription = $data['attributes']['subscription'];