Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(no-ref): remove arrows #51

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions components/leaderboard-panel.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useUser } from "context/user-context";
import useBreakpoints from "hooks/use-breakpoints";
import { isEqual } from "lodash";
import { IXPLeaderboardUser } from "models/backend/xp-models";
Expand All @@ -9,7 +8,6 @@ import { calculateLevel, formatNumber } from "utils/text-utils";

import BlockButton from "./block-button";
import FallBackImage from "./fallback-image";
import { ArrowDown, ArrowUp, Neutral } from "./svg/arrows";

interface LeaderboardPanelProps {
user: IXPLeaderboardUser;
Expand All @@ -18,23 +16,12 @@ interface LeaderboardPanelProps {
isAdmin?: boolean;
}

const getArrowPos = (id: string, arrPos: number, pos: number) => {
return arrPos < pos ? (
<ArrowDown />
) : arrPos > pos ? (
<ArrowUp />
) : (
<Neutral />
);
};

const LeaderboardPanel: FC<LeaderboardPanelProps> = ({
user,
rank,
requestEdit,
isAdmin,
}) => {
const userContext = useUser();
const [hovering, setHovering] = useState(false);
const breakpoints = useBreakpoints();
hovering;
Expand Down Expand Up @@ -85,11 +72,6 @@ const LeaderboardPanel: FC<LeaderboardPanelProps> = ({
<div className="relative hidden h-full shrink-0 items-center overflow-hidden whitespace-nowrap rounded-md bg-panelBack p-4 text-darkText shadow-md dark:bg-panelBack-darkMode dark:text-darkText-darkMode md:flex">
{formatNumber(user.xp)} xp
</div>
{!userContext.flags?.["disable-leaderboard-arrows"] && (
<div className="relative flex h-full shrink-0 items-center overflow-hidden whitespace-nowrap rounded-md bg-panelBack p-4 text-darkText shadow-md dark:bg-panelBack-darkMode dark:text-darkText-darkMode">
{getArrowPos(user.id, user.arrowPos, rank)}
</div>
)}
{isAdmin && (
<BlockButton
onClick={requestEdit}
Expand Down
4 changes: 3 additions & 1 deletion context/user-context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ export function UserContextProvider({
[]
);
const [currentUser, setCurrentUser] = useState<IXPAPIUser | undefined>();
const { flags } = useFlags();
const { flags } = useFlags(
currentUser ? { user: { key: currentUser?.discordUser.id } } : undefined
);

const [inboxItems, setInboxItems] = useState<IInboxItem[]>([]);

Expand Down
2 changes: 0 additions & 2 deletions models/backend/xp-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export interface IXPGuild {
allowed: Array<string>;
}>;
};
arrows: { [id: string]: number };
leaderboard_message: {
enabled: boolean;
messageID: string;
Expand Down Expand Up @@ -126,7 +125,6 @@ export interface IXPLeaderboardGuild {
export interface IXPLeaderboardUser {
id: string;
xp: number;
arrowPos: number;
username: string;
avatar?: string;
banner?: string;
Expand Down