ReviewDB: Support Disabled & No Reviews
This commit is contained in:
parent
83783b9478
commit
0dbf463096
4 changed files with 22 additions and 12 deletions
|
|
@ -35,10 +35,10 @@ const LANGUAGE_MAP: Record<string, string> = {
|
|||
};
|
||||
|
||||
function getLanguageIconUrl(language: string | null): string {
|
||||
if (!language) return "https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github-original.svg";
|
||||
if (!language) return "https://cdn.jsdelivr.net/gh/devicons/devicon@develop/icons/github/github-original.svg";
|
||||
|
||||
const normalized = LANGUAGE_MAP[language.toLowerCase()] ?? language.toLowerCase().replace(/\s+/g, "");
|
||||
return `https://cdn.jsdelivr.net/gh/devicons/devicon/icons/${normalized}/${normalized}-original.svg`;
|
||||
return `https://cdn.jsdelivr.net/gh/devicons/devicon@develop/icons/${normalized}/${normalized}-original.svg`;
|
||||
}
|
||||
|
||||
export function ProfilePopoutComponent({ id, theme }: { id: string, theme: string; }) {
|
||||
|
|
@ -112,10 +112,6 @@ export function ProfilePopoutComponent({ id, theme }: { id: string, theme: strin
|
|||
src={getLanguageIconUrl(repo.language)}
|
||||
alt={repo.language ?? "Unknown"}
|
||||
className={showCount ? ProfileCardContainerClasses.displayCount : undefined}
|
||||
style={!repo.language && theme !== "light" ? { filter: "invert(1)" } : undefined}
|
||||
onError={e => {
|
||||
(e.target as HTMLImageElement).src = "https://cdn.jsdelivr.net/gh/devicons/devicon/icons/github/github-original.svg";
|
||||
}}
|
||||
/>
|
||||
{showCount && (
|
||||
<div className={ProfileCardContainerClasses.displayCountText}>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ import { openReviewsModal } from "./components/ReviewModal";
|
|||
import { NotificationType, ReviewType } from "./entities";
|
||||
import { getCurrentUserInfo, getReviews, readNotification } from "./reviewDbApi";
|
||||
import { settings } from "./settings";
|
||||
import { showToast } from "./utils";
|
||||
import { cl, showToast } from "./utils";
|
||||
|
||||
const DMSideBarClasses = findCssClassesLazy("widgetPreviews");
|
||||
const ProfileCardClasses = findCssClassesLazy("cardsList", "firstCardContainer", "card", "container");
|
||||
|
|
@ -165,10 +165,17 @@ export default definePlugin({
|
|||
<section className={ProfileCardClasses.container}>
|
||||
<ul className={ProfileCardClasses.cardsList} tabIndex={-1}>
|
||||
<li className={ProfileCardClasses.firstCardContainer}>
|
||||
<Clickable className={ProfileCardContainerClasses.breadcrumb} onClick={() => openReviewsModal(user.id, user.username, ReviewType.User)}>
|
||||
<Clickable
|
||||
className={classes(ProfileCardContainerClasses.breadcrumb, reviewData?.hasOptedOut ? cl("profile-popout-disabled") : null)}
|
||||
onClick={() => !reviewData?.hasOptedOut && openReviewsModal(user.id, user.username, ReviewType.User)}
|
||||
>
|
||||
<div className={classes(ProfileCardOverlayClasses.overlay, ProfileCardContainerClasses.innerContainer, ProfileCardClasses.card)}>
|
||||
<Paragraph size={isSideBar ? "sm" : "xs"} weight="medium">User Reviews</Paragraph>
|
||||
{!!reviewData?.reviewCount && (
|
||||
{reviewData?.hasOptedOut ? (
|
||||
<Paragraph size={isSideBar ? "sm" : "xs"}>User disabled reviews</Paragraph>
|
||||
) : !reviewData?.reviewCount ? (
|
||||
<Paragraph size={isSideBar ? "sm" : "xs"}>No reviews yet</Paragraph>
|
||||
) : !!reviewData?.reviewCount && (
|
||||
<div className={ProfileCardContainerClasses.icons}>
|
||||
{reviewData.reviews
|
||||
.filter(review => review.id !== 0)
|
||||
|
|
|
|||
|
|
@ -29,10 +29,11 @@ export const REVIEWS_PER_PAGE = 50;
|
|||
|
||||
export interface UserReviewsData {
|
||||
message: string;
|
||||
reviews: Review[];
|
||||
updated: boolean;
|
||||
hasNextPage: boolean;
|
||||
reviewCount: number;
|
||||
reviews: Review[];
|
||||
updated: boolean;
|
||||
hasOptedOut: boolean;
|
||||
}
|
||||
|
||||
const WarningFlag = 0b00000010;
|
||||
|
|
@ -65,7 +66,8 @@ export async function getReviews(id: string, offset = 0, isProfileComponent = fa
|
|||
reviews: [],
|
||||
updated: false,
|
||||
hasNextPage: false,
|
||||
reviewCount: 0
|
||||
reviewCount: 0,
|
||||
hasOptedOut: false,
|
||||
};
|
||||
|
||||
if (!req.ok) {
|
||||
|
|
|
|||
|
|
@ -131,3 +131,8 @@
|
|||
.vc-rdb-block-modal-unblock {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.vc-rdb-profile-popout-disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue