custom app rendering

This commit is contained in:
metacryst
2026-03-24 04:16:00 -05:00
parent 881c9408b6
commit c5b71add07
5 changed files with 68 additions and 31 deletions

View File

@@ -83,7 +83,11 @@ class Announcements extends Shadow {
.display("none")
.visibility("hidden")
.onChange((e) => {
this.handleUpload(e.target.files[0]);
const file = e.target.files[0]
if (!file) return
this.stagedImage = file
this.stagedImageURL = URL.createObjectURL(file)
this.rerender()
})
div("+")
@@ -138,8 +142,8 @@ class Announcements extends Shadow {
this.style.backgroundColor = "var(--accent)"
} else {
setTimeout(() => {
$("appmenu-").display("none")
this.focus()
}, 20)
console.log($("appmenu-"))
this.style.backgroundColor = "var(--searchbackground)"
@@ -169,6 +173,31 @@ class Announcements extends Shadow {
})
}
async handleUpload(file) {
try {
const body = new FormData();
body.append('image', file);
const res = await util.authFetch(`${util.HOST}/profile/upload-image`, {
method: "POST",
credentials: "include",
headers: {
"Accept": "application/json"
},
body: body
});
if(res.status === 401) {
return res.status
}
if (!res.ok) return res.status;
const data = await res.json()
global.profile = data.member
console.log(global.profile)
} catch (err) { // Network error / Error reaching server
console.error(err);
}
}
addPhoto() {
console.log("hey")
}