TootBottomSheet: fix #13
All checks were successful
/ depoly (push) Successful in 1m4s

* use the .reblog to replace the remote toot
This commit is contained in:
thislight 2024-09-25 20:32:50 +08:00
parent 6306c5afbe
commit d3a7602fb5
No known key found for this signature in database
GPG key ID: A50F9451AC56A63E

View file

@ -8,21 +8,13 @@ import {
type Component, type Component,
} from "solid-js"; } from "solid-js";
import Scaffold from "../material/Scaffold"; 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 { Title } from "../material/typography";
import { import {
ArrowBack as BackIcon, ArrowBack as BackIcon,
Close as CloseIcon, Close as CloseIcon,
Send, Send,
} from "@suid/icons-material"; } from "@suid/icons-material";
import { isiOS } from "../platform/host";
import { createUnauthorizedClient, useSessions } from "../masto/clients"; import { createUnauthorizedClient, useSessions } from "../masto/clients";
import { resolveCustomEmoji } from "../masto/toot"; import { resolveCustomEmoji } from "../masto/toot";
import RegularToot from "./RegularToot"; import RegularToot from "./RegularToot";
@ -121,6 +113,11 @@ const TootBottomSheet: Component = (props) => {
const onBookmark = async () => { const onBookmark = async () => {
const status = remoteToot()!; const status = remoteToot()!;
const client = actSession()!.client; const client = actSession()!.client;
setRemoteToot(
Object.assign({}, status, {
bookmarked: !status.bookmarked,
}),
);
const result = await (status.bookmarked const result = await (status.bookmarked
? client.v1.statuses.$select(status.id).unbookmark() ? client.v1.statuses.$select(status.id).unbookmark()
: client.v1.statuses.$select(status.id).bookmark()); : 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).unreblog()
: client.v1.statuses.$select(status.id).reblog()); : client.v1.statuses.$select(status.id).reblog());
vibrate([20, 30]); vibrate([20, 30]);
setRemoteToot(result); setRemoteToot(result.reblog!);
}; };
const onFav = async () => { const onFav = async () => {
const status = remoteToot()!; const status = remoteToot()!;
const client = actSession()!.client; const client = actSession()!.client;
setRemoteToot(
Object.assign({}, status, {
favourited: !status.favourited,
}),
);
const result = await (status.favourited const result = await (status.favourited
? client.v1.statuses.$select(status.id).favourite() ? client.v1.statuses.$select(status.id).favourite()
: client.v1.statuses.$select(status.id).unfavourite()); : client.v1.statuses.$select(status.id).unfavourite());