mirror of
https://github.com/flarum/core.git
synced 2025-07-20 16:21:18 +02:00
Sync notification count when clicking on them or marking all as read
Refs #500.
This commit is contained in:
@@ -77,6 +77,7 @@ export default class Notification extends Component {
|
|||||||
* Mark the notification as read.
|
* Mark the notification as read.
|
||||||
*/
|
*/
|
||||||
markAsRead() {
|
markAsRead() {
|
||||||
|
app.session.user.pushAttributes({unreadNotificationsCount: app.session.user.unreadNotificationsCount() - 1});
|
||||||
this.props.notification.save({isRead: true});
|
this.props.notification.save({isRead: true});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -110,7 +110,7 @@ export default class NotificationList extends Component {
|
|||||||
* been loaded.
|
* been loaded.
|
||||||
*/
|
*/
|
||||||
load() {
|
load() {
|
||||||
if (app.cache.notifications && !app.session.user.unreadNotificationsCount()) {
|
if (app.cache.notifications && !app.session.user.newNotificationsCount()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ export default class NotificationList extends Component {
|
|||||||
m.redraw();
|
m.redraw();
|
||||||
|
|
||||||
app.store.find('notifications').then(notifications => {
|
app.store.find('notifications').then(notifications => {
|
||||||
app.session.user.pushAttributes({unreadNotificationsCount: 0});
|
app.session.user.pushAttributes({newNotificationsCount: 0});
|
||||||
app.cache.notifications = notifications.sort((a, b) => b.time() - a.time());
|
app.cache.notifications = notifications.sort((a, b) => b.time() - a.time());
|
||||||
|
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
@@ -132,6 +132,8 @@ export default class NotificationList extends Component {
|
|||||||
markAllAsRead() {
|
markAllAsRead() {
|
||||||
if (!app.cache.notifications) return;
|
if (!app.cache.notifications) return;
|
||||||
|
|
||||||
|
app.session.user.pushAttributes({unreadNotificationsCount: 0});
|
||||||
|
|
||||||
app.cache.notifications.forEach(notification => {
|
app.cache.notifications.forEach(notification => {
|
||||||
if (!notification.isRead()) {
|
if (!notification.isRead()) {
|
||||||
notification.save({isRead: true});
|
notification.save({isRead: true});
|
||||||
|
Reference in New Issue
Block a user