Skip to content

Commit

Permalink
feat(no-ref): remove arrows (#51)
Browse files Browse the repository at this point in the history
Co-authored-by: Morian Engelhardt <[email protected]>
  • Loading branch information
ConnysCode and Morian Engelhardt authored Oct 21, 2023
1 parent 40e8793 commit f091c13
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 21 deletions.
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

0 comments on commit f091c13

Please sign in to comment.