mirror of
https://github.com/flarum/framework.git
synced 2025-02-18 09:52:45 +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 the next page of notification results.
|
||||||
*/
|
*/
|
||||||
load(): Promise<void> {
|
load(): Promise<void> {
|
||||||
if (app.session.user.newNotificationCount()) {
|
if (app.session.user?.newNotificationCount()) {
|
||||||
this.pages = [];
|
this.pages = [];
|
||||||
this.location = { page: 1 };
|
this.location = { page: 1 };
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ export default class NotificationListState extends PaginatedListState<Notificati
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.session.user.pushAttributes({ newNotificationCount: 0 });
|
app.session.user?.pushAttributes({ newNotificationCount: 0 });
|
||||||
|
|
||||||
return super.loadNext();
|
return super.loadNext();
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ export default class NotificationListState extends PaginatedListState<Notificati
|
||||||
markAllAsRead() {
|
markAllAsRead() {
|
||||||
if (this.pages.length === 0) return;
|
if (this.pages.length === 0) return;
|
||||||
|
|
||||||
app.session.user.pushAttributes({ unreadNotificationCount: 0 });
|
app.session.user?.pushAttributes({ unreadNotificationCount: 0 });
|
||||||
|
|
||||||
this.pages.forEach((page) => {
|
this.pages.forEach((page) => {
|
||||||
page.items.forEach((notification) => notification.pushAttributes({ isRead: true }));
|
page.items.forEach((notification) => notification.pushAttributes({ isRead: true }));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user