From 70de83a24ac8f598a03c5e48d1d3e7bf40616c25 Mon Sep 17 00:00:00 2001 From: thislight Date: Wed, 25 Sep 2024 20:32:50 +0800 Subject: [PATCH] TootBottomSheet: fix #13 * use the .reblog to replace the remote toot --- src/timelines/TootBottomSheet.tsx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/timelines/TootBottomSheet.tsx b/src/timelines/TootBottomSheet.tsx index 18a83dc..ff075d3 100644 --- a/src/timelines/TootBottomSheet.tsx +++ b/src/timelines/TootBottomSheet.tsx @@ -8,21 +8,13 @@ import { type Component, } from "solid-js"; import Scaffold from "../material/Scaffold"; -import TootThread from "./TootThread"; -import { - AppBar, - Avatar, - CircularProgress, - IconButton, - Toolbar, -} from "@suid/material"; +import { AppBar, Avatar, CircularProgress, IconButton, Toolbar } from "@suid/material"; import { Title } from "../material/typography"; import { ArrowBack as BackIcon, Close as CloseIcon, Send, } from "@suid/icons-material"; -import { isiOS } from "../platform/host"; import { createUnauthorizedClient, useSessions } from "../masto/clients"; import { resolveCustomEmoji } from "../masto/toot"; import RegularToot from "./RegularToot"; @@ -121,6 +113,11 @@ const TootBottomSheet: Component = (props) => { const onBookmark = async () => { const status = remoteToot()!; const client = actSession()!.client; + setRemoteToot( + Object.assign({}, status, { + bookmarked: !status.bookmarked, + }), + ); const result = await (status.bookmarked ? client.v1.statuses.$select(status.id).unbookmark() : client.v1.statuses.$select(status.id).bookmark()); @@ -140,12 +137,17 @@ const TootBottomSheet: Component = (props) => { ? client.v1.statuses.$select(status.id).unreblog() : client.v1.statuses.$select(status.id).reblog()); vibrate([20, 30]); - setRemoteToot(result); + setRemoteToot(result.reblog!); }; const onFav = async () => { const status = remoteToot()!; const client = actSession()!.client; + setRemoteToot( + Object.assign({}, status, { + favourited: !status.favourited, + }), + ); const result = await (status.favourited ? client.v1.statuses.$select(status.id).favourite() : client.v1.statuses.$select(status.id).unfavourite());