| 1 |
( function () { |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
mw.echo.ui.NotificationsWrapper = function MwEchoUiNotificationsWrapper( controller, model, config ) { |
| 17 |
config = config || {}; |
| 18 |
|
| 19 |
|
| 20 |
mw.echo.ui.NotificationsWrapper.super.call( this, config ); |
| 21 |
|
| 22 |
|
| 23 |
OO.ui.mixin.PendingElement.call( this, config ); |
| 24 |
|
| 25 |
this.controller = controller; |
| 26 |
this.model = model; |
| 27 |
|
| 28 |
this.notificationsWidget = new mw.echo.ui.NotificationsListWidget( |
| 29 |
this.controller, |
| 30 |
this.model, |
| 31 |
{ |
| 32 |
$overlay: config.$overlay, |
| 33 |
types: this.controller.getTypes(), |
| 34 |
label: mw.msg( 'notifications' ), |
| 35 |
icon: 'bell' |
| 36 |
} |
| 37 |
); |
| 38 |
|
| 39 |
|
| 40 |
this.$element |
| 41 |
.addClass( 'mw-echo-notificationsWrapper skin-invert' ) |
| 42 |
.append( this.notificationsWidget.$element ); |
| 43 |
}; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
OO.inheritClass( mw.echo.ui.NotificationsWrapper, OO.ui.Widget ); |
| 48 |
OO.mixinClass( mw.echo.ui.NotificationsWrapper, OO.ui.mixin.PendingElement ); |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
mw.echo.ui.NotificationsWrapper.prototype.populate = function () { |
| 68 |
this.pushPending(); |
| 69 |
return this.controller.fetchLocalNotifications( true ) |
| 70 |
.catch( ( errorObj ) => { |
| 71 |
if ( errorObj.errCode === 'notlogin-required' ) { |
| 72 |
|
| 73 |
this.notificationsWidget.resetLoadingOption( mw.msg( 'echo-notification-loginrequired' ) ); |
| 74 |
} else { |
| 75 |
|
| 76 |
this.notificationsWidget.resetLoadingOption( mw.msg( 'echo-api-failure' ) ); |
| 77 |
} |
| 78 |
} ) |
| 79 |
.always( () => { |
| 80 |
this.popPending(); |
| 81 |
this.emit( 'finishLoading' ); |
| 82 |
this.promiseRunning = false; |
| 83 |
} ); |
| 84 |
}; |
| 85 |
}() ); |