mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
change value of subscribed from false to null in the JSON API (#37)
This commit is contained in:
parent
c1c47e81aa
commit
e783a7603d
|
@ -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;
|
||||
}
|
||||
}),
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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'];
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user