Don't display notifications with deleted subjects

This commit is contained in:
Toby Zerner 2015-07-28 17:15:09 +09:30
parent c2771abeaa
commit 22d322aa2a
4 changed files with 10 additions and 4 deletions

View File

@ -33,12 +33,14 @@ export default class NotificationList extends Component {
app.cache.notifications.forEach(notification => {
const subject = notification.subject();
if (typeof subject === 'undefined') return;
// 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
// other entity which is related to a discussion.
let discussion;
let discussion = false;
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
// indirectly, then we will assign it to a neutral group.

View File

@ -1,6 +1,5 @@
import Component from 'flarum/Component';
import humanTime from 'flarum/helpers/humanTime';
import username from 'flarum/helpers/username';
/**
* Displays information about a the first or last post in a discussion.

View File

@ -227,6 +227,8 @@ export default class Model {
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 false;
};
}

View File

@ -115,7 +115,8 @@ abstract class Serializer extends SerializerAbstract
} elseif ($many) {
$relationIds = $relation.'_ids';
$data = isset($model->$relationIds) ? $model->$relationIds : $model->$relation()->lists('id');
} else {
}
if (! $many && empty($data)) {
$relationId = $relation.'_id';
$data = $model->$relationId;
}