Skip to content

Commit

Permalink
SAK-48326 WC sakai-picture-changer dont attach all of the cropping un…
Browse files Browse the repository at this point in the history
…til the user wants to change their profile image (#12325)
  • Loading branch information
ottenhoff authored Feb 12, 2024
1 parent 7e48a1c commit 4a592f4
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export class SakaiPictureChanger extends SakaiElement {
super();

this.loadTranslations("sakai-picture-changer").then(r => this._i18n = r);
this._loadExisting();
}

_attachCropper() {
Expand All @@ -48,7 +47,13 @@ export class SakaiPictureChanger extends SakaiElement {
}

firstUpdated() {
this._loadExisting();
// Add an event listener for the Bootstrap 'show.bs.modal' event
const modal = this.renderRoot.querySelector("#profile-image-upload");
if (modal) {
modal.addEventListener("show.bs.modal", () => {
this._loadExisting();
});
}
}

_filePicked(e) {
Expand Down Expand Up @@ -123,6 +128,7 @@ export class SakaiPictureChanger extends SakaiElement {
}

_loadExisting() {
if (this._imageUrl) return;

const url = `/direct/profile-image/details?_=${Date.now()}`;
fetch(url, { credentials: "include" }).then(r => r.json()).then(json => {
Expand Down Expand Up @@ -199,7 +205,7 @@ export class SakaiPictureChanger extends SakaiElement {
}

shouldUpdate() {
return this._i18n && this._imageUrl;
return this._i18n;
}

render() {
Expand Down

0 comments on commit 4a592f4

Please sign in to comment.