| 1 |
( function () { |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
mw.echo.dm.BundleNotificationItem = function MwEchoDmBundleNotificationItem( id, bundledNotificationModels, config ) { |
| 15 |
|
| 16 |
mw.echo.dm.BundleNotificationItem.super.call( this, id, config ); |
| 17 |
|
| 18 |
this.getSecondaryUrls().forEach( ( link ) => { |
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
delete link.prioritized; |
| 24 |
} ); |
| 25 |
|
| 26 |
this.setForeign( false ); |
| 27 |
this.count = bundledNotificationModels.length; |
| 28 |
|
| 29 |
|
| 30 |
bundledNotificationModels.forEach( ( bundled ) => { |
| 31 |
bundled.content.header = bundled.content.compactHeader; |
| 32 |
delete bundled.iconUrl; |
| 33 |
} ); |
| 34 |
|
| 35 |
this.list = new mw.echo.dm.NotificationsList(); |
| 36 |
this.list.setItems( bundledNotificationModels ); |
| 37 |
|
| 38 |
this.list.connect( this, { itemUpdate: 'onItemUpdate' } ); |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
this.toggleRead( this.isRead() ); |
| 45 |
}; |
| 46 |
|
| 47 |
OO.inheritClass( mw.echo.dm.BundleNotificationItem, mw.echo.dm.NotificationItem ); |
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
mw.echo.dm.BundleNotificationItem.prototype.onItemUpdate = function () { |
| 55 |
this.toggleRead( this.isRead() ); |
| 56 |
}; |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
mw.echo.dm.BundleNotificationItem.prototype.isRead = function () { |
| 62 |
return this.list.getItems().every( ( item ) => item.isRead() ); |
| 63 |
}; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
mw.echo.dm.BundleNotificationItem.prototype.getList = function () { |
| 71 |
return this.list; |
| 72 |
}; |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
mw.echo.dm.BundleNotificationItem.prototype.getCount = function () { |
| 80 |
return this.list.getItemCount(); |
| 81 |
}; |
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
mw.echo.dm.BundleNotificationItem.prototype.hasUnseen = function () { |
| 91 |
return this.list.getItems().some( ( item ) => !item.isSeen() ); |
| 92 |
}; |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
mw.echo.dm.BundleNotificationItem.prototype.updateSeenState = function ( timestamp ) { |
| 100 |
this.list.getItems().forEach( ( notification ) => { |
| 101 |
notification.toggleSeen( |
| 102 |
notification.isRead() || notification.getTimestamp() < timestamp |
| 103 |
); |
| 104 |
} ); |
| 105 |
}; |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
mw.echo.dm.BundleNotificationItem.prototype.isGroup = function () { |
| 115 |
return true; |
| 116 |
}; |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
mw.echo.dm.BundleNotificationItem.prototype.getAllIds = function () { |
| 124 |
return this.list.getItems().map( ( item ) => item.getId() ); |
| 125 |
}; |
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
mw.echo.dm.BundleNotificationItem.prototype.findByIds = function ( ids ) { |
| 134 |
return this.list.findByIds( ids ); |
| 135 |
}; |
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
mw.echo.dm.BundleNotificationItem.prototype.getItems = function () { |
| 143 |
return this.list.getItems(); |
| 144 |
}; |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
mw.echo.dm.BundleNotificationItem.prototype.getName = function () { |
| 152 |
return this.getModelName(); |
| 153 |
}; |
| 154 |
|
| 155 |
}() ); |