Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 88730ab

Browse files
author
Parth Shah
committed
Merge branch 'feature/SUP-2289-image-update' into dev
2 parents c705a5a + c101b39 commit 88730ab

File tree

4 files changed

+18
-8
lines changed

4 files changed

+18
-8
lines changed

app/directives/page-state-header/page-state-header.directive.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@
1313
hideMoney: '=',
1414
defaultState: '@'
1515
},
16-
controller: ['$scope', 'NotificationService', 'ProfileService', '$log', '$state', pageStateHeader],
16+
controller: ['CONSTANTS', '$rootScope', '$scope', 'NotificationService', 'ProfileService', '$log', '$state', pageStateHeader],
1717
controllerAs: "vm"
1818
};
1919
});
2020

21-
function pageStateHeader($scope, NotificationService, ProfileService, $log, $state) {
21+
function pageStateHeader(CONSTANTS, $rootScope, $scope, NotificationService, ProfileService, $log, $state) {
2222
var vm = this;
2323
vm.handle = $scope.handle;
2424
vm.profile = null;
@@ -31,12 +31,16 @@
3131
vm.backHandler = backHandler;
3232
activate();
3333

34+
// watch for profile update event in case handle/image are updated
35+
$rootScope.$on(CONSTANTS.EVENT_PROFILE_UPDATED, function() {
36+
activate();
37+
});
38+
3439
function activate() {
3540
vm.loading = true;
3641

3742
// identifies the previous state
3843
if ($scope.$root.previousState && $scope.$root.previousState.name.length > 0) {
39-
console.log($scope.$root.previousState);
4044
vm.previousState = $scope.$root.previousState;
4145
vm.previousStateName = vm.previousState.name;
4246
} else if ($scope.defaultState) {

app/layout/header/header.controller.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
angular.forEach([
3333
CONSTANTS.EVENT_USER_LOGGED_IN,
3434
CONSTANTS.EVENT_USER_LOGGED_OUT,
35+
CONSTANTS.EVENT_PROFILE_UPDATED
3536
], function(event) {
3637
$rootScope.$on(event, function() {
3738
initHeaderProps(event);

app/services/profile.service.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
angular.module('tc.services').factory('ProfileService', ProfileService);
55

6-
ProfileService.$inject = ['CONSTANTS', 'ApiService', 'UserService', '$q', '$filter'];
6+
ProfileService.$inject = ['CONSTANTS', 'ApiService', 'UserService', '$q', '$filter', '$rootScope'];
77

8-
function ProfileService(CONSTANTS, ApiService, UserService, $q, $filter) {
8+
function ProfileService(CONSTANTS, ApiService, UserService, $q, $filter, $rootScope) {
99

1010
var restangular = ApiService.restangularV3;
1111

@@ -42,7 +42,11 @@
4242
}
4343

4444
function updateUserProfile(userData) {
45-
return userData.save();
45+
return userData.save().then(function(resp) {
46+
// notify listeners of profile update event
47+
$rootScope.$broadcast(CONSTANTS.EVENT_PROFILE_UPDATED);
48+
return resp;
49+
});
4650
}
4751

4852
function getUserSkills(username) {

app/settings/edit-profile/edit-profile.controller.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
angular.module('tc.settings').controller('EditProfileController', EditProfileController);
55

66

7-
EditProfileController.$inject = ['userData', 'userHandle', 'ProfileService', 'ExternalAccountService', '$log', 'ISO3166', 'ImageService', 'CONSTANTS', 'TagsService', 'toaster', '$scope'];
7+
EditProfileController.$inject = ['$rootScope', 'userData', 'userHandle', 'ProfileService', 'ExternalAccountService', '$log', 'ISO3166', 'ImageService', 'CONSTANTS', 'TagsService', 'toaster', '$scope'];
88

9-
function EditProfileController(userData, userHandle, ProfileService, ExternalAccountService, $log, ISO3166, ImageService, CONSTANTS, TagsService, toaster, $scope) {
9+
function EditProfileController($rootScope, userData, userHandle, ProfileService, ExternalAccountService, $log, ISO3166, ImageService, CONSTANTS, TagsService, toaster, $scope) {
1010
$log = $log.getInstance("EditProfileCtrl");
1111
var vm = this;
1212
vm.toggleTrack = toggleTrack;
@@ -112,6 +112,7 @@
112112
.then(ImageService.createFileRecord)
113113
.then(function(newPhotoURL) {
114114
vm.userData.photoURL = newPhotoURL;
115+
$rootScope.$broadcast(CONSTANTS.EVENT_PROFILE_UPDATED);
115116
});
116117
}
117118

0 commit comments

Comments
 (0)