- {state.hasItems()
- ? pages.map((page) => {
- const groups = [];
- const discussions = {};
-
- page.items.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 = null;
- if (subject instanceof Discussion) discussion = subject;
- 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.
- const key = discussion ? discussion.id() : 0;
- discussions[key] = discussions[key] || { discussion: discussion, notifications: [] };
- discussions[key].notifications.push(notification);
-
- if (groups.indexOf(discussions[key]) === -1) {
- groups.push(discussions[key]);
- }
- });
-
- return groups.map((group) => {
- const badges = group.discussion && group.discussion.badges().toArray();
-
- return (
-
);
}
+ content(state) {
+ if (state.isLoading()) {
+ return ;
+ }
+
+ if (state.hasItems()) {
+ return state.getPages().map((page) => {
+ const groups = [];
+ const discussions = {};
+
+ page.items.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 = null;
+ if (subject instanceof Discussion) discussion = subject;
+ 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.
+ const key = discussion ? discussion.id() : 0;
+ discussions[key] = discussions[key] || { discussion: discussion, notifications: [] };
+ discussions[key].notifications.push(notification);
+
+ if (groups.indexOf(discussions[key]) === -1) {
+ groups.push(discussions[key]);
+ }
+ });
+
+ return groups.map((group) => {
+ const badges = group.discussion && group.discussion.badges().toArray();
+
+ return (
+