diff --git a/files/routes/users.py b/files/routes/users.py index 9ec611b2a..1bf46edf3 100644 --- a/files/routes/users.py +++ b/files/routes/users.py @@ -131,13 +131,12 @@ def transfer_coins(v, username): receiver.coins += amount g.db.add(receiver) g.db.add(v) + g.db.commit() transfer_message = f"🤑 [@{v.username}]({v.url}) has gifted you {amount} {app.config['COINS_NAME']}!" send_notification(v.id, receiver, transfer_message) return {"message": f"{amount} {app.config['COINS_NAME']} transferred!"}, 200 - g.db.commit() - return {"message": f"{app.config['COINS_NAME']} transferred!"} diff --git a/files/templates/userpage.html b/files/templates/userpage.html index 01d37ea87..b1d060c63 100644 --- a/files/templates/userpage.html +++ b/files/templates/userpage.html @@ -62,20 +62,7 @@ t.disabled = true; post_toast("/@{{u.username}}/transfer_coins", - xhr => { - if(xhr.status == 200) { - fetch("/@{{u.username}}/coins") - .then(r => r.json()) - .then(m => { - document.getElementById("profile-coins-amount").innerText = m["coins"]; - document.getElementById("profile-coins-amount-mobile").innerText = m["coins"]; - }) - - fetch("/@{{v.username}}/coins") - .then(r => r.json()) - .then(m => document.getElementById(`user-coins-amount`).innerText = m["coins"]) - } - }, + false, {"amount": document.getElementById(mobile ? "coins-transfer-amount-mobile" : "coins-transfer-amount").value} );