fix: require reactions to be unique for owner, asset

add: cut off really long text in posts
This commit is contained in:
trisua 2025-05-08 16:35:58 -04:00
parent a1c6beb664
commit d7a37809ba
9 changed files with 27 additions and 37 deletions

View file

@ -349,7 +349,7 @@ media_theme_pref();
for (const element of Array.from(
document.querySelectorAll("[hook=long]") || [],
)) {
const is_long = element.innerText.length >= 64 * 16;
const is_long = element.innerText.length >= 64 * 8;
if (!is_long) {
continue;
@ -362,12 +362,12 @@ media_theme_pref();
}
const html = element.innerHTML;
const short = html.slice(0, 64 * 16);
const short = html.slice(0, 64 * 8);
element.innerHTML = `${short}...`;
// event
const listener = () => {
app["hooks::long"](element, html);
self["hooks::long"](element, html);
element.removeEventListener("click", listener);
};
@ -508,7 +508,7 @@ media_theme_pref();
})
.then((res) => res.json())
.then((res) => {
trigger("app::toast", [
trigger("atto::toast", [
res.success ? "success" : "error",
res.message,
]);
@ -560,7 +560,7 @@ media_theme_pref();
wrapper.scrollTop + wrapper.offsetHeight + 100 >
attach.offsetHeight
) {
self.debounce("app::partials")
self.debounce("atto::partials")
.then(async () => {
if (document.getElementById("initial_loader")) {
console.log("partial blocked");
@ -570,7 +570,6 @@ media_theme_pref();
// biome-ignore lint/style/noParameterAssign: no it isn't
page += 1;
await load_partial();
await $["hooks::partial_embeds"]();
})
.catch(() => {
console.log("partial stuck");
@ -583,25 +582,6 @@ media_theme_pref();
},
);
self.define("hooks::partial_embeds", (_) => {
for (const paragraph of Array.from(
document.querySelectorAll("span[class] p"),
)) {
const groups = /(\/\+r\/)([\w]+)/.exec(paragraph.innerText);
if (groups === null) {
continue;
}
// add embed
paragraph.innerText = paragraph.innerText.replace(groups[0], "");
paragraph.parentElement.innerHTML += `<include-partial
src="/_app/components/response.html?id=${groups[2]}&do_render_nested=false"
uses="app::clean_date_codes,app::link_filter,app::hooks::alt"
></include-partial>`;
}
});
self.define("hooks::check_reactions", async ({ $ }) => {
const observer = $.offload_work_to_client_when_in_view(
async (element) => {

View file

@ -54,6 +54,7 @@
});
self.define("react", async (_, element, asset, asset_type, is_like) => {
await trigger("atto::debounce", ["reactions::toggle"]);
fetch("/api/v1/reactions", {
method: "POST",
headers: {