I know this has been asked and appropriately answered HERE. However I am wondering if this is possibly done differently now as I can not get that structure to work. My code is almost exactly the same as the original.
@track _getRecordResponse;
@wire(getRecord, { recordId: USER_ID, fields: [PHOTO_URL_FIELD] })
userRecord(response) {
this._getRecordResponse = response;
let error = response && response.error;
let data = response && response.data;
if (data) {
this.userImage = data.fields[PHOTO_URL_FIELD.fieldApiName].value;
} else if (error) {
this.handleError(error);
}
}
I am updating the User Image through Apex (I am building a community page and there are a few additional requirements that the built in User Image component doesn't have)
save() {
if (this.newImage && this.uploadType === "Account") {
this.showSpinner = true;
// "Create" new Account Image
this.updateContentVersion(
{
Id: this.newImage.ContentVersionId,
[ACCOUNT_FILE_TYPE_FIELD.fieldApiName]: "Account Image"
},
true
);
if (this.existingImage)
this.updateContentVersion(
{
Id: this.existingImage.ContentVersionId,
[IS_DELETED_FIELD.fieldApiName]: true
},
false
);
return;
}
if (this.newImage && this.uploadType === "User") {
uploadUserImage({
fileRecordId: this.newImage.ContentDocumentId
})
.then(() => {
this.showSpinner = false;
this.newImage = undefined;
this.showModal = false;
this.saveDisabled = true;
refreshApex(this._getRecordResponse);
})
.catch(error => {
this.handleError(error);
this.saveDisabled = true;
});
}
}
Once I manually refresh the page, the data updated in "uploadUserImage" renders without issue. I just need to of course programmatically refresh the getRecord wire
Any ideas?