}) {
const uploadImageRef = useRef(null);
+ // Uploads the selected image and passes the resulting URI to the onUpload function provided in component props.
function uploadImage(e) {
const file = e.target.files.item(0);
if (file !== null) { // TODO Add upload progress spinner
let username = mx.getUser(mx.getUserId()).displayName;
+ // Sets avatar URL and updates the avatar component in profile editor to reflect new upload
function handleUpload(e) {
mx.setAvatarUrl(e.content_uri);
updateImgSrc(mx.mxcUrlToHttp(e.content_uri));
}
}
+ // Enables/disables save button depending on whether or not the username is different than the current.
function onDisplayNameInputChange() {
setDisabled((username === displayNameRef.current.value) || displayNameRef.current.value === '' || displayNameRef.current.value == null);
}