fix #55: try to correct the toot modify algo
All checks were successful
/ depoly (push) Successful in 1m28s

This commit is contained in:
thislight 2025-01-14 15:12:51 +08:00
parent 45c03f9fce
commit b2db680076
No known key found for this signature in database
GPG key ID: FCFE5192241CCD4E

View file

@ -25,7 +25,6 @@ import TootAuthorGroup from "./toots/TootAuthorGroup.js";
import "./RegularToot.css"; import "./RegularToot.css";
import { vibrate } from "~platform/hardware.js"; import { vibrate } from "~platform/hardware.js";
import { Transition } from "solid-transition-group"; import { Transition } from "solid-transition-group";
import { ANIM_CURVE_SHARP, ANIM_CURVE_STD } from "~material/theme.js";
export type TootEnv = { export type TootEnv = {
boost: (value: mastodon.v1.Status) => void; boost: (value: mastodon.v1.Status) => void;
@ -97,20 +96,25 @@ export function createDefaultTootEnv(
} }
// modified the original // modified the original
const result = reblogged try {
? await c.v1.statuses.$select(status.id).unreblog() const result = reblogged
: await c.v1.statuses.$select(status.id).reblog(); ? await c.v1.statuses.$select(status.id).unreblog()
: await c.v1.statuses.$select(status.id).reblog();
if (status.reblog && !reblogged) { if (status.reblog && !reblogged) {
// When calling /reblog, the result is the boost object (the actor // When calling /reblog, the result is the boost object (the actor
// is the calling account); for /unreblog, the result is the original // is the calling account); for /unreblog, the result is the original
// toot. So we only do this trick only on the reblogging. // toot. So we only do this trick only on the rebloggings.
setToot(status.id, { setToot(status.id, {
...status, ...status,
reblog: result.reblog, reblog: result.reblog,
}); });
} else { } else {
setToot(status.id, result); setToot(status.id, reblogged ? result : result.reblog!);
}
} catch (reason) {
setToot(status.id, status);
throw reason;
} }
}, },
@ -310,8 +314,8 @@ const RegularToot: Component<RegularTootProps> = (oprops) => {
)} )}
<Transition <Transition
onExit={(el, done) => { onExit={(el, done) => {
(el as HTMLElement).addEventListener("animationend", done) (el as HTMLElement).addEventListener("animationend", done);
el.classList.add("Transition-exit") el.classList.add("Transition-exit");
}} }}
> >
<Show when={props.actionable}> <Show when={props.actionable}>