This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(avatars): load profile image on settings and sign in pages if ava…
…ilable Fixes #1727.
- Loading branch information
Showing
11 changed files
with
184 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
// helper functions for views with a profile image. Meant to be mixed into views. | ||
|
||
'use strict'; | ||
|
||
define([ | ||
'lib/promise', | ||
'lib/session' | ||
], function (p, Session) { | ||
|
||
return { | ||
// Attempt to load a profile image from the profile server and cache it on Session | ||
_fetchProfileImage: function () { | ||
var self = this; | ||
|
||
return this.profileClient.getAvatar() | ||
.then(function (result) { | ||
if (result.avatar && result.id) { | ||
Session.set('avatar', result.avatar); | ||
Session.set('avatarId', result.id); | ||
return true; | ||
} | ||
}) | ||
.then(function (found) { | ||
if (found) { | ||
self.logEvent(self.className + '.profile_image_shown'); | ||
} | ||
}, function (err) { | ||
self.logEvent(self.className + '.profile_image_not_shown'); | ||
// Failures to load a profile image are not displayed in the ui | ||
// so log the error here to make sure it's in metrics. | ||
self.logError(err); | ||
throw err; | ||
}); | ||
} | ||
}; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.