add: better quote post ui

This commit is contained in:
trisua 2025-05-21 00:04:18 -04:00
parent fb2a9285d2
commit 2b91422d18
8 changed files with 138 additions and 102 deletions

View file

@ -201,31 +201,40 @@
});
});
self.define("repost", (_, id, content, community) => {
fetch(`/api/v1/posts/${id}/repost`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
content,
community,
}),
})
.then((res) => res.json())
.then((res) => {
trigger("atto::toast", [
res.ok ? "success" : "error",
res.message,
]);
self.define(
"repost",
(_, id, content, community, do_not_redirect = false) => {
return new Promise((resolve, _) => {
fetch(`/api/v1/posts/${id}/repost`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
content,
community,
}),
})
.then((res) => res.json())
.then((res) => {
trigger("atto::toast", [
res.ok ? "success" : "error",
res.message,
]);
if (res.ok) {
setTimeout(() => {
window.location.href = `/post/${res.payload}`;
}, 100);
}
if (res.ok) {
if (!do_not_redirect) {
setTimeout(() => {
window.location.href = `/post/${res.payload}`;
}, 100);
}
resolve(res.payload);
}
});
});
});
},
);
self.define("report", (_, asset, asset_type) => {
window.open(