Skip to content

Commit 499a04d

Browse files
committed
MOBILE-1509 notifications: Show user picture in notifications
1 parent 2f56a49 commit 499a04d

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

www/addons/notifications/controllers/list.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ angular.module('mm.addons.notifications')
2121
* @ngdoc controller
2222
* @name mmaNotificationsListCtrl
2323
*/
24-
.controller('mmaNotificationsListCtrl', function($scope, $mmUtil, $mmaNotifications, mmaNotificationsListLimit) {
24+
.controller('mmaNotificationsListCtrl', function($scope, $mmUtil, $mmaNotifications, mmaNotificationsListLimit,
25+
mmUserProfileState) {
2526

2627
var readCount = 0,
2728
unreadCount = 0;
2829

2930
$scope.notifications = [];
31+
$scope.userStateName = mmUserProfileState;
3032

3133
// Convenience function to get notifications. Get unread notifications first.
3234
function fetchNotifications(refresh) {

www/addons/notifications/services/notifications.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ angular.module('mm.addons.notifications')
2121
* @ngdoc service
2222
* @name $mmaNotifications
2323
*/
24-
.factory('$mmaNotifications', function($q, $log, $mmSite, $mmSitesManager, mmaNotificationsListLimit) {
24+
.factory('$mmaNotifications', function($q, $log, $mmSite, $mmSitesManager, $mmUser, mmaNotificationsListLimit) {
2525

2626
$log = $log.getInstance('$mmaNotifications');
2727

@@ -42,6 +42,11 @@ angular.module('mm.addons.notifications')
4242
if (cid && cid[1]) {
4343
notification.courseid = cid[1];
4444
}
45+
46+
// Try to get the profile picture of the user.
47+
$mmUser.getProfile(notification.useridfrom, notification.courseid, true).then(function(user) {
48+
notification.profileimageurlfrom = user.profileimageurl;
49+
});
4550
});
4651
}
4752

@@ -52,7 +57,7 @@ angular.module('mm.addons.notifications')
5257
*/
5358
function getNotificationsCacheKey() {
5459
return 'mmaNotifications:list';
55-
};
60+
}
5661

5762
/**
5863
* Get notifications from site.

www/addons/notifications/templates/list.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
</ion-refresher>
55
<mm-loading hide-until="notificationsLoaded">
66
<article class="card" ng-repeat="notification in notifications track by $index">
7-
<div class="item">
7+
<div class="item item-avatar item-text-wrap">
8+
<img ng-if="notification.profileimageurlfrom" ng-src="{{notification.profileimageurlfrom}}" mm-external-content ui-sref="{{userStateName}}({courseid: notification.courseid, userid: notification.useridfrom})" alt="{{ 'mm.core.pictureof' | translate:{$a: notification.userfromfullname} }}" role="presentation">
9+
<img ng-if="!notification.profileimageurlfrom" src="img/user-avatar.png" alt="{{ 'mm.core.pictureof' | translate:{$a: notification.userfromfullname} }}" role="presentation">
810
<h2>{{notification.userfromfullname}}</h2>
911
<p>{{notification.timecreated | mmDateDayOrTime}}</p>
1012
</div>

www/core/lang/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
"openinbrowser": "Open in browser",
8989
"percentagenumber": "{{$a}}%",
9090
"phone": "Phone",
91+
"pictureof": "Picture of {{$a}}",
9192
"previous": "Previous",
9293
"pulltorefresh": "Pull to refresh",
9394
"refresh": "Refresh",

0 commit comments

Comments
 (0)