[ReviewDB] Improve UI & Use new RewviewDB api endpoints (#1104)

This commit is contained in:
Manti 2023-05-14 02:29:13 +03:00 committed by GitHub
parent 1bc0678422
commit 7a27de8927
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 101 additions and 33 deletions

View file

@ -19,7 +19,7 @@
import { Settings } from "@api/Settings";
import { classes } from "@utils/misc";
import { useAwaiter } from "@utils/react";
import { findLazy } from "@webpack";
import { findByPropsLazy } from "@webpack";
import { Forms, React, Text, UserStore } from "@webpack/common";
import type { KeyboardEvent } from "react";
@ -27,7 +27,7 @@ import { addReview, getReviews } from "../Utils/ReviewDBAPI";
import { authorize, showToast } from "../Utils/Utils";
import ReviewComponent from "./ReviewComponent";
const Classes = findLazy(m => typeof m.textarea === "string");
const Classes = findByPropsLazy("inputDefault", "editable");
export default function ReviewsView({ userId }: { userId: string; }) {
const { token } = Settings.plugins.ReviewDB;
@ -65,7 +65,7 @@ export default function ReviewsView({ userId }: { userId: string; }) {
tag="h2"
variant="eyebrow"
style={{
marginBottom: "12px",
marginBottom: "8px",
color: "var(--header-primary)"
}}
>
@ -79,13 +79,17 @@ export default function ReviewsView({ userId }: { userId: string; }) {
/>
)}
{reviews?.length === 0 && (
<Forms.FormText style={{ padding: "12px", paddingTop: "0px", paddingLeft: "4px", fontWeight: "bold", fontStyle: "italic" }}>
<Forms.FormText style={{ paddingRight: "12px", paddingTop: "0px", paddingLeft: "0px", paddingBottom: "4px", fontWeight: "bold", fontStyle: "italic" }}>
Looks like nobody reviewed this user yet. You could be the first!
</Forms.FormText>
)}
<textarea
className={classes(Classes.textarea.replace("textarea", ""), "enter-comment")}
// this produces something like '-_59yqs ...' but since no class exists with that name its fine
className={classes(Classes.inputDefault, "enter-comment")}
onKeyDownCapture={e => {
if (e.key === "Enter") {
e.preventDefault(); // prevent newlines
}
}}
placeholder={
token
? (reviews?.some(r => r.sender.discordID === UserStore.getCurrentUser().id)
@ -106,6 +110,9 @@ export default function ReviewsView({ userId }: { userId: string; }) {
resize: "none",
marginBottom: "12px",
overflow: "hidden",
background: "transparent",
border: "1px solid var(--profile-message-input-border-color)",
fontSize: "14px",
}}
/>
</div>