Skip to content

Commit

Permalink
Some tweaks and fixed GC Updating
Browse files Browse the repository at this point in the history
  • Loading branch information
3r1s-s committed Jul 31, 2024
1 parent 71afbff commit 18703c4
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
6 changes: 5 additions & 1 deletion profile/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ This message was created by meo.

if (data._id === localStorage.getItem('username')) {
profilecont.innerHTML += `
<button class="modal-button updt-prfl" onclick="updateprofile()" aria-label="update profile"><div>${lang().action.update}</div></button>
<button id="updt-prfl" class="modal-button updt-prfl" onclick="updateprofile()" aria-label="update profile"><div>${lang().action.update}</div></button>
`;
}

Expand Down Expand Up @@ -188,6 +188,10 @@ function updateprofile() {
const file = fileInput.files[0];
const token = localStorage.getItem("token");

const update = document.getElementById("updt-prfl");
update.disabled = true;
update.textContent = "Uploading...";

const xhttp = new XMLHttpRequest();

xhttp.onreadystatechange = function() {
Expand Down
4 changes: 4 additions & 0 deletions profile/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ p {
border: 1px solid #ffffff20;
}

.button:disabled {
opacity: 0.5;
}

.custom-bg .quote-edit {
border: 2px dashed #ffffff20;
}
Expand Down
44 changes: 19 additions & 25 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4889,7 +4889,7 @@ function openGcModal(chatId) {
if (mdbt) {
if (data.owner === localStorage.getItem("username")) {
mdbt.innerHTML = `
<button class="modal-back-btn" onclick="updateGC('${chatId}')">Update Chat</button>
<button id="updategc" class="modal-back-btn" onclick="updateGC('${chatId}')">Update Chat</button>
`;
} else {
mdbt.innerHTML = `
Expand All @@ -4907,6 +4907,10 @@ function updateGC(chatId) {
const avtrclr = document.getElementById("gc-clr").value.substring(1);
const nick = document.getElementById("chat-nick-input").value;

const update = document.getElementById("updategc");
update.disabled = true;
update.textContent = "Uploading...";

const xhttp = new XMLHttpRequest();

xhttp.onreadystatechange = function() {
Expand Down Expand Up @@ -4934,33 +4938,23 @@ function updateGC(chatId) {
const formData = new FormData();
formData.append("file", file);

fetch("https://api.meower.org/uploads/token/icon", {
method: "GET",
fetch("https://uploads.meower.org/icons", {
method: "POST",
headers: {
"token": token
}
"Authorization": token
},
body: formData
})
.then(response => response.json())
.then(tokenData => {
fetch("https://uploads.meower.org/icons", {
method: "POST",
headers: {
"Authorization": tokenData.token
},
body: formData
})
.then(uploadResponse => uploadResponse.json())
.then(uploadData => {
if (nick) {
data.nickname = nick;
}
const avatarId = uploadData.id;
data.icon = avatarId;
xhttp.send(JSON.stringify(data));
})
.catch(error => console.error('Error uploading file:', error));
.then(uploadResponse => uploadResponse.json())
.then(uploadData => {
if (nick) {
data.nickname = nick;
}
const avatarId = uploadData.id;
data.icon = avatarId;
xhttp.send(JSON.stringify(data));
})
.catch(error => console.error('Error fetching uploads token:', error));
.catch(error => console.error('Error uploading file:', error));
} else {
if (nick) {
data.nickname = nick;
Expand Down

0 comments on commit 18703c4

Please sign in to comment.