fix: user avatar images & upload

This commit is contained in:
David Arnold 2020-09-17 01:57:58 -05:00 committed by Denis Perov
parent 1875551a93
commit efcca9739a
3 changed files with 10 additions and 15 deletions

View file

@ -85,7 +85,7 @@ template(name="changeAvatarPopup")
each uploadedAvatars
li: a.js-select-avatar
.member
img.avatar.avatar-image(src="{{url avatarUrlOptions}}")
img.avatar.avatar-image(src="{{link}}?auth=false&brokenIsFine=true")
| {{_ 'uploaded-avatar'}}
if isSelected
i.fa.fa-check

View file

@ -3,6 +3,7 @@ import Avatars from '/models/avatars';
import Users from '/models/users';
import Org from '/models/org';
import Team from '/models/team';
import { formatFleURL } from 'meteor/ostrio:files/lib';
Template.userAvatar.helpers({
userData() {
@ -184,21 +185,14 @@ BlazeComponent.extendComponent({
Meteor.subscribe('my-avatars');
},
avatarUrlOptions() {
return {
auth: false,
brokenIsFine: true,
};
},
uploadedAvatars() {
return Avatars.find({ userId: Meteor.userId() });
return Avatars.find({ userId: Meteor.userId() }).each();
},
isSelected() {
const userProfile = Meteor.user().profile;
const avatarUrl = userProfile && userProfile.avatarUrl;
const currentAvatarUrl = this.currentData().url(this.avatarUrlOptions());
const currentAvatarUrl = `${this.currentData().link()}?auth=false&brokenIsFine=true`;
return avatarUrl === currentAvatarUrl;
},
@ -234,8 +228,9 @@ BlazeComponent.extendComponent({
);
uploader.on('uploaded', (error, fileRef) => {
if (!error) {
self.setAvatar(fileRef.path);
// self.setAvatar(this.currentData().url(this.avatarUrlOptions()));
self.setAvatar(
`${formatFleURL(fileRef)}?auth=false&brokenIsFine=true`,
);
}
});
uploader.on('error', (error, fileData) => {
@ -245,7 +240,7 @@ BlazeComponent.extendComponent({
}
},
'click .js-select-avatar'() {
const avatarUrl = this.currentData().url(this.avatarUrlOptions());
const avatarUrl = `${this.currentData().link()}?auth=false&brokenIsFine=true`;
this.setAvatar(avatarUrl);
},
'click .js-select-initials'() {

View file

@ -15,9 +15,9 @@ Avatars = new FilesCollection({
collectionName: 'avatars',
allowClientCode: true,
onBeforeUpload(file) {
if (file.size <= 72000 && file.type.startsWith("image/")) {
if (file.size <= 72000 && file.type.startsWith('image/')) {
return true;
};
}
return 'avatar-too-big';
},
onAfterUpload: createOnAfterUpload(avatarsBucket),