diff options
author | Justice Almanzar <superdash993@gmail.com> | 2022-12-02 10:43:37 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-02 16:43:37 +0100 |
commit | 41dddc9eee6f19fb5055545811aff1e282790a9c (patch) | |
tree | bf38148e87242e169adfa39919aa636a9d0551ce /src/plugins/reviewDB | |
parent | 4760af7f0ee275caa1eee440f4945032057d2b56 (diff) | |
download | Vencord-41dddc9eee6f19fb5055545811aff1e282790a9c.tar.gz Vencord-41dddc9eee6f19fb5055545811aff1e282790a9c.tar.bz2 Vencord-41dddc9eee6f19fb5055545811aff1e282790a9c.zip |
feat(plugin): ShikiCodeblocks (#267)
Co-authored-by: ArjixWasTaken <53124886+ArjixWasTaken@users.noreply.github.com>
Co-authored-by: Ven <vendicated@riseup.net>
Diffstat (limited to 'src/plugins/reviewDB')
-rw-r--r-- | src/plugins/reviewDB/components/ReviewsView.tsx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/plugins/reviewDB/components/ReviewsView.tsx b/src/plugins/reviewDB/components/ReviewsView.tsx index 999b970..57f974e 100644 --- a/src/plugins/reviewDB/components/ReviewsView.tsx +++ b/src/plugins/reviewDB/components/ReviewsView.tsx @@ -18,7 +18,7 @@ import { classes, useAwaiter } from "@utils/misc"; import { findLazy } from "@webpack"; -import { Forms, Text, UserStore } from "@webpack/common"; +import { Forms, React, Text, UserStore } from "@webpack/common"; import type { KeyboardEvent } from "react"; import { addReview, getReviews } from "../Utils/ReviewDBAPI"; @@ -27,7 +27,13 @@ import ReviewComponent from "./ReviewComponent"; const Classes = findLazy(m => typeof m.textarea === "string"); export default function ReviewsView({ userId }: { userId: string; }) { - const [reviews, _, isLoading, refetch] = useAwaiter(() => getReviews(userId), []); + const [refetchCount, setRefetchCount] = React.useState(0); + const [reviews, _, isLoading] = useAwaiter(() => getReviews(userId), { + fallbackValue: [], + deps: [refetchCount], + }); + + const dirtyRefetch = () => setRefetchCount(refetchCount + 1); if (isLoading) return null; @@ -40,7 +46,7 @@ export default function ReviewsView({ userId }: { userId: string; }) { }).then(res => { if (res === 0 || res === 1) { (target as HTMLInputElement).value = ""; // clear the input - refetch(); + dirtyRefetch(); } }); } @@ -64,7 +70,7 @@ export default function ReviewsView({ userId }: { userId: string; }) { <ReviewComponent key={review.id} review={review} - refetch={refetch} + refetch={dirtyRefetch} /> )} {reviews?.length === 0 && ( |