UX: reload the page when changing avatar

This commit is contained in:
Régis Hanol 2018-07-18 22:50:50 +02:00
parent def2653fc8
commit facef06d60
1 changed files with 15 additions and 13 deletions

View File

@ -46,13 +46,18 @@ export default RestrictedUserRoute.extend({
selectAvatar(url) { selectAvatar(url) {
const user = this.modelFor("user"); const user = this.modelFor("user");
const controller = this.controllerFor("avatar-selector");
this.controllerFor("avatar-selector").send("closeModal");
user user
.selectAvatar(url) .selectAvatar(url)
.then(() => bootbox.alert(I18n.t("user.change_avatar.cache_notice"))) .then(() => {
.catch(popupAjaxError) bootbox.alert(
.finally(() => controller.send("closeModal")); I18n.t("user.change_avatar.cache_notice"),
() => window.location.reload()
);
})
.catch(popupAjaxError);
}, },
saveAvatarSelection() { saveAvatarSelection() {
@ -62,20 +67,17 @@ export default RestrictedUserRoute.extend({
const selectedAvatarTemplate = controller.get("selectedAvatarTemplate"); const selectedAvatarTemplate = controller.get("selectedAvatarTemplate");
const type = controller.get("selected"); const type = controller.get("selected");
controller.send("closeModal");
user user
.pickAvatar(selectedUploadId, type, selectedAvatarTemplate) .pickAvatar(selectedUploadId, type, selectedAvatarTemplate)
.then(() => { .then(() => {
user.setProperties( bootbox.alert(
controller.getProperties( I18n.t("user.change_avatar.cache_notice"),
"system_avatar_template", () => window.location.reload()
"gravatar_avatar_template",
"custom_avatar_template"
)
); );
bootbox.alert(I18n.t("user.change_avatar.cache_notice"));
}) })
.catch(popupAjaxError) .catch(popupAjaxError);
.finally(() => controller.send("closeModal"));
} }
} }
}); });