Fix up Notification model

This commit is contained in:
Toby Zerner 2018-08-24 21:47:57 +09:30
parent f0d296bfb0
commit ad33638a99

View File

@ -1,17 +1,13 @@
import Model from '../Model'; import Model from '../Model';
import computed from '../utils/computed';
export default class Notification extends Model {} export default class Notification extends Model {}
Object.assign(Notification.prototype, { Object.assign(Notification.prototype, {
contentType: Model.attribute('contentType'), contentType: Model.attribute('contentType'),
subjectId: Model.attribute('subjectId'),
content: Model.attribute('content'), content: Model.attribute('content'),
time: Model.attribute('time', Model.date), createdAt: Model.attribute('createdAt', Model.transformDate),
isRead: Model.attribute('isRead'), isRead: Model.attribute('isRead'),
unreadCount: Model.attribute('unreadCount'),
additionalUnreadCount: computed('unreadCount', unreadCount => Math.max(0, unreadCount - 1)),
user: Model.hasOne('user'), user: Model.hasOne('user'),
fromUser: Model.hasOne('fromUser'), fromUser: Model.hasOne('fromUser'),