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 { 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<RegularTootProps> = (oprops) => {
)}
<Transition
onExit={(el, done) => {
(el as HTMLElement).addEventListener("animationend", done)
el.classList.add("Transition-exit")
(el as HTMLElement).addEventListener("animationend", done);
el.classList.add("Transition-exit");
}}
>
<Show when={props.actionable}>