mirror of
https://github.com/flarum/framework.git
synced 2025-01-07 19:13:37 +08:00
Don't display notifications with deleted subjects
This commit is contained in:
parent
c2771abeaa
commit
22d322aa2a
|
@ -33,12 +33,14 @@ export default class NotificationList extends Component {
|
||||||
app.cache.notifications.forEach(notification => {
|
app.cache.notifications.forEach(notification => {
|
||||||
const subject = notification.subject();
|
const subject = notification.subject();
|
||||||
|
|
||||||
|
if (typeof subject === 'undefined') return;
|
||||||
|
|
||||||
// Get the discussion that this notification is related to. If it's not
|
// Get the discussion that this notification is related to. If it's not
|
||||||
// directly related to a discussion, it may be related to a post or
|
// directly related to a discussion, it may be related to a post or
|
||||||
// other entity which is related to a discussion.
|
// other entity which is related to a discussion.
|
||||||
let discussion;
|
let discussion = false;
|
||||||
if (subject instanceof Discussion) discussion = subject;
|
if (subject instanceof Discussion) discussion = subject;
|
||||||
else if (subject.discussion) discussion = subject.discussion();
|
else if (subject && subject.discussion) discussion = subject.discussion();
|
||||||
|
|
||||||
// If the notification is not related to a discussion directly or
|
// If the notification is not related to a discussion directly or
|
||||||
// indirectly, then we will assign it to a neutral group.
|
// indirectly, then we will assign it to a neutral group.
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
import Component from 'flarum/Component';
|
import Component from 'flarum/Component';
|
||||||
import humanTime from 'flarum/helpers/humanTime';
|
import humanTime from 'flarum/helpers/humanTime';
|
||||||
import username from 'flarum/helpers/username';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays information about a the first or last post in a discussion.
|
* Displays information about a the first or last post in a discussion.
|
||||||
|
|
|
@ -227,6 +227,8 @@ export default class Model {
|
||||||
|
|
||||||
return relationship && app.store.getById(relationship.data.type, relationship.data.id);
|
return relationship && app.store.getById(relationship.data.type, relationship.data.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,6 +249,8 @@ export default class Model {
|
||||||
|
|
||||||
return relationship && relationship.data.map(data => app.store.getById(data.type, data.id));
|
return relationship && relationship.data.map(data => app.store.getById(data.type, data.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,8 @@ abstract class Serializer extends SerializerAbstract
|
||||||
} elseif ($many) {
|
} elseif ($many) {
|
||||||
$relationIds = $relation.'_ids';
|
$relationIds = $relation.'_ids';
|
||||||
$data = isset($model->$relationIds) ? $model->$relationIds : $model->$relation()->lists('id');
|
$data = isset($model->$relationIds) ? $model->$relationIds : $model->$relation()->lists('id');
|
||||||
} else {
|
}
|
||||||
|
if (! $many && empty($data)) {
|
||||||
$relationId = $relation.'_id';
|
$relationId = $relation.'_id';
|
||||||
$data = $model->$relationId;
|
$data = $model->$relationId;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user