mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 14:13:37 +08:00
Rename user.unreadNotificationsCount
This commit is contained in:
parent
f9bab0822e
commit
eb5b3a0484
|
@ -22,7 +22,7 @@ Object.assign(User.prototype, {
|
||||||
joinTime: Model.attribute('joinTime', Model.transformDate),
|
joinTime: Model.attribute('joinTime', Model.transformDate),
|
||||||
lastSeenAt: Model.attribute('lastSeenAt', Model.transformDate),
|
lastSeenAt: Model.attribute('lastSeenAt', Model.transformDate),
|
||||||
markedAllAsReadAt: Model.attribute('markedAllAsReadAt', Model.transformDate),
|
markedAllAsReadAt: Model.attribute('markedAllAsReadAt', Model.transformDate),
|
||||||
unreadNotificationsCount: Model.attribute('unreadNotificationsCount'),
|
unreadNotificationCount: Model.attribute('unreadNotificationCount'),
|
||||||
newNotificationsCount: Model.attribute('newNotificationsCount'),
|
newNotificationsCount: Model.attribute('newNotificationsCount'),
|
||||||
|
|
||||||
discussionCount: Model.attribute('discussionCount'),
|
discussionCount: Model.attribute('discussionCount'),
|
||||||
|
|
|
@ -79,7 +79,7 @@ export default class Notification extends Component {
|
||||||
markAsRead() {
|
markAsRead() {
|
||||||
if (this.props.notification.isRead()) return;
|
if (this.props.notification.isRead()) return;
|
||||||
|
|
||||||
app.session.user.pushAttributes({unreadNotificationsCount: app.session.user.unreadNotificationsCount() - 1});
|
app.session.user.pushAttributes({unreadNotificationCount: app.session.user.unreadNotificationCount() - 1});
|
||||||
|
|
||||||
this.props.notification.save({isRead: true});
|
this.props.notification.save({isRead: true});
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,7 +191,7 @@ 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.session.user.pushAttributes({unreadNotificationCount: 0});
|
||||||
|
|
||||||
app.cache.notifications.forEach(notifications => {
|
app.cache.notifications.forEach(notifications => {
|
||||||
notifications.forEach(notification => notification.pushAttributes({isRead: true}))
|
notifications.forEach(notification => notification.pushAttributes({isRead: true}))
|
||||||
|
|
|
@ -62,7 +62,7 @@ export default class NotificationsDropdown extends Dropdown {
|
||||||
}
|
}
|
||||||
|
|
||||||
getUnreadCount() {
|
getUnreadCount() {
|
||||||
return app.session.user.unreadNotificationsCount();
|
return app.session.user.unreadNotificationCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
getNewCount() {
|
getNewCount() {
|
||||||
|
|
|
@ -25,7 +25,7 @@ class CurrentUserSerializer extends UserSerializer
|
||||||
'isEmailConfirmed' => (bool) $user->is_email_confirmed,
|
'isEmailConfirmed' => (bool) $user->is_email_confirmed,
|
||||||
'email' => $user->email,
|
'email' => $user->email,
|
||||||
'markedAllAsReadAt' => $this->formatDate($user->marked_all_as_read_at),
|
'markedAllAsReadAt' => $this->formatDate($user->marked_all_as_read_at),
|
||||||
'unreadNotificationsCount' => (int) $user->getUnreadNotificationsCount(),
|
'unreadNotificationCount' => (int) $user->getUnreadNotificationCount(),
|
||||||
'newNotificationsCount' => (int) $user->getNewNotificationsCount(),
|
'newNotificationsCount' => (int) $user->getNewNotificationsCount(),
|
||||||
'preferences' => (array) $user->preferences
|
'preferences' => (array) $user->preferences
|
||||||
];
|
];
|
||||||
|
|
|
@ -417,7 +417,7 @@ class User extends AbstractModel
|
||||||
*
|
*
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function getUnreadNotificationsCount()
|
public function getUnreadNotificationCount()
|
||||||
{
|
{
|
||||||
return $this->getUnreadNotifications()->count();
|
return $this->getUnreadNotifications()->count();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user