From b2db6800769813f1b3b0b0a3b502d437627a69b5 Mon Sep 17 00:00:00 2001 From: thislight Date: Tue, 14 Jan 2025 15:12:51 +0800 Subject: [PATCH] fix #55: try to correct the toot modify algo --- src/timelines/RegularToot.tsx | 36 +++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/src/timelines/RegularToot.tsx b/src/timelines/RegularToot.tsx index 52f0243..6a5f528 100644 --- a/src/timelines/RegularToot.tsx +++ b/src/timelines/RegularToot.tsx @@ -25,7 +25,6 @@ import TootAuthorGroup from "./toots/TootAuthorGroup.js"; import "./RegularToot.css"; import { vibrate } from "~platform/hardware.js"; import { Transition } from "solid-transition-group"; -import { ANIM_CURVE_SHARP, ANIM_CURVE_STD } from "~material/theme.js"; export type TootEnv = { boost: (value: mastodon.v1.Status) => void; @@ -97,20 +96,25 @@ export function createDefaultTootEnv( } // modified the original - const result = reblogged - ? await c.v1.statuses.$select(status.id).unreblog() - : await c.v1.statuses.$select(status.id).reblog(); + try { + const result = reblogged + ? await c.v1.statuses.$select(status.id).unreblog() + : await c.v1.statuses.$select(status.id).reblog(); - if (status.reblog && !reblogged) { - // When calling /reblog, the result is the boost object (the actor - // is the calling account); for /unreblog, the result is the original - // toot. So we only do this trick only on the reblogging. - setToot(status.id, { - ...status, - reblog: result.reblog, - }); - } else { - setToot(status.id, result); + if (status.reblog && !reblogged) { + // When calling /reblog, the result is the boost object (the actor + // is the calling account); for /unreblog, the result is the original + // toot. So we only do this trick only on the rebloggings. + setToot(status.id, { + ...status, + reblog: result.reblog, + }); + } else { + setToot(status.id, reblogged ? result : result.reblog!); + } + } catch (reason) { + setToot(status.id, status); + throw reason; } }, @@ -310,8 +314,8 @@ const RegularToot: Component = (oprops) => { )} { - (el as HTMLElement).addEventListener("animationend", done) - el.classList.add("Transition-exit") + (el as HTMLElement).addEventListener("animationend", done); + el.classList.add("Transition-exit"); }} >