mirror of
https://github.com/flarum/framework.git
synced 2024-11-25 09:41:49 +08:00
Don't assume app.session.user
is present
This commit is contained in:
parent
32d272c57f
commit
e79d3bc3b7
|
@ -15,7 +15,7 @@ export default class NotificationListState extends PaginatedListState<Notificati
|
|||
* Load the next page of notification results.
|
||||
*/
|
||||
load(): Promise<void> {
|
||||
if (app.session.user.newNotificationCount()) {
|
||||
if (app.session.user?.newNotificationCount()) {
|
||||
this.pages = [];
|
||||
this.location = { page: 1 };
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ export default class NotificationListState extends PaginatedListState<Notificati
|
|||
return Promise.resolve();
|
||||
}
|
||||
|
||||
app.session.user.pushAttributes({ newNotificationCount: 0 });
|
||||
app.session.user?.pushAttributes({ newNotificationCount: 0 });
|
||||
|
||||
return super.loadNext();
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ export default class NotificationListState extends PaginatedListState<Notificati
|
|||
markAllAsRead() {
|
||||
if (this.pages.length === 0) return;
|
||||
|
||||
app.session.user.pushAttributes({ unreadNotificationCount: 0 });
|
||||
app.session.user?.pushAttributes({ unreadNotificationCount: 0 });
|
||||
|
||||
this.pages.forEach((page) => {
|
||||
page.items.forEach((notification) => notification.pushAttributes({ isRead: true }));
|
||||
|
|
Loading…
Reference in New Issue
Block a user