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