Merge pull request #2419 from dwrensha/loading-accounts-button

Make sure incognito icon does not display when we're still waiting for data.
This commit is contained in:
Kenton Varda authored and GitHub committed 2016-08-19 12:33:09 -07:00
commit c136fcdc2d
2 files changed
+15 -21

No files matched your search

+10 -4
View File
@@ -41,10 +41,16 @@ licenses, included in the LICENSES directory.
</template>
<template name="accountButtons">
<button class="show-popup has-picture">
<span class="profile-picture" style="background-image: url('{{profilePictureUrl}}');"></span>
{{displayName}} ▾
</button>
{{#with profileData}}
{{#if loading}}
<button class="show-popup has-picture">Loading...</button>
{{else}}
<button class="show-popup has-picture">
<span class="profile-picture" style="background-image: url('{{pictureUrl}}');"></span>
{{displayName}} ▾
</button>
{{/if}}
{{/with}}
</template>
<template name="loginButtonsPopup">
+5 -17
View File
@@ -71,37 +71,25 @@ function getActiveIdentityId(grains) {
}
Template.accountButtons.helpers({
displayName: function () {
profileData: function () {
if (Meteor.user() && !Meteor.user().loginIdentities && !Meteor.user().profile) {
// Need to wait for resume token to complete login. For some reason, `Meteor.loggingIn()`
// is still false in this case.
return "Loading...";
return { loading: true };
}
const currentIdentityId = getActiveIdentityId(this.grains);
const user = Meteor.users.findOne({ _id: currentIdentityId });
if (currentIdentityId && !user) {
// Need to wait for the `identityProfile` subscription to be ready.
return "Loading...";
return { loading: true };
}
if (!user) return "(incognito)";
if (!user) return { displayName: "(incognito)", pictureUrl: "/incognito.svg", };
SandstormDb.fillInProfileDefaults(user);
return user.profile.name;
},
profilePictureUrl() {
const currentIdentityId = getActiveIdentityId(this.grains);
const user = Meteor.users.findOne({ _id: currentIdentityId });
if (currentIdentityId && !user) {
return "";
}
if (!user) return "/incognito.svg";
SandstormDb.fillInPictureUrl(user);
return user.profile.pictureUrl;
return { displayName: user.profile.name, pictureUrl: user.profile.pictureUrl };
},
});