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 {
|
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, "");
|
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; }) {
|
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)}
|
src={getLanguageIconUrl(repo.language)}
|
||||||
alt={repo.language ?? "Unknown"}
|
alt={repo.language ?? "Unknown"}
|
||||||
className={showCount ? ProfileCardContainerClasses.displayCount : undefined}
|
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 && (
|
{showCount && (
|
||||||
<div className={ProfileCardContainerClasses.displayCountText}>
|
<div className={ProfileCardContainerClasses.displayCountText}>
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ import { openReviewsModal } from "./components/ReviewModal";
|
||||||
import { NotificationType, ReviewType } from "./entities";
|
import { NotificationType, ReviewType } from "./entities";
|
||||||
import { getCurrentUserInfo, getReviews, readNotification } from "./reviewDbApi";
|
import { getCurrentUserInfo, getReviews, readNotification } from "./reviewDbApi";
|
||||||
import { settings } from "./settings";
|
import { settings } from "./settings";
|
||||||
import { showToast } from "./utils";
|
import { cl, showToast } from "./utils";
|
||||||
|
|
||||||
const DMSideBarClasses = findCssClassesLazy("widgetPreviews");
|
const DMSideBarClasses = findCssClassesLazy("widgetPreviews");
|
||||||
const ProfileCardClasses = findCssClassesLazy("cardsList", "firstCardContainer", "card", "container");
|
const ProfileCardClasses = findCssClassesLazy("cardsList", "firstCardContainer", "card", "container");
|
||||||
|
|
@ -165,10 +165,17 @@ export default definePlugin({
|
||||||
<section className={ProfileCardClasses.container}>
|
<section className={ProfileCardClasses.container}>
|
||||||
<ul className={ProfileCardClasses.cardsList} tabIndex={-1}>
|
<ul className={ProfileCardClasses.cardsList} tabIndex={-1}>
|
||||||
<li className={ProfileCardClasses.firstCardContainer}>
|
<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)}>
|
<div className={classes(ProfileCardOverlayClasses.overlay, ProfileCardContainerClasses.innerContainer, ProfileCardClasses.card)}>
|
||||||
<Paragraph size={isSideBar ? "sm" : "xs"} weight="medium">User Reviews</Paragraph>
|
<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}>
|
<div className={ProfileCardContainerClasses.icons}>
|
||||||
{reviewData.reviews
|
{reviewData.reviews
|
||||||
.filter(review => review.id !== 0)
|
.filter(review => review.id !== 0)
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,11 @@ export const REVIEWS_PER_PAGE = 50;
|
||||||
|
|
||||||
export interface UserReviewsData {
|
export interface UserReviewsData {
|
||||||
message: string;
|
message: string;
|
||||||
reviews: Review[];
|
|
||||||
updated: boolean;
|
|
||||||
hasNextPage: boolean;
|
hasNextPage: boolean;
|
||||||
reviewCount: number;
|
reviewCount: number;
|
||||||
|
reviews: Review[];
|
||||||
|
updated: boolean;
|
||||||
|
hasOptedOut: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
const WarningFlag = 0b00000010;
|
const WarningFlag = 0b00000010;
|
||||||
|
|
@ -65,7 +66,8 @@ export async function getReviews(id: string, offset = 0, isProfileComponent = fa
|
||||||
reviews: [],
|
reviews: [],
|
||||||
updated: false,
|
updated: false,
|
||||||
hasNextPage: false,
|
hasNextPage: false,
|
||||||
reviewCount: 0
|
reviewCount: 0,
|
||||||
|
hasOptedOut: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!req.ok) {
|
if (!req.ok) {
|
||||||
|
|
|
||||||
|
|
@ -131,3 +131,8 @@
|
||||||
.vc-rdb-block-modal-unblock {
|
.vc-rdb-block-modal-unblock {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.vc-rdb-profile-popout-disabled {
|
||||||
|
opacity: 0.4;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue