The weeb for the next gen discord boat - Wamellow wamellow.com
bot discord
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: rename BitfieldManager to Bitfield (#33)

authored by

Luna Seemann and committed by
GitHub
e7d4c91b 24e69675

+7 -9
+2 -2
app/dashboard/[guildId]/notifications/page.tsx
··· 16 16 import { Button } from "@/components/ui/button"; 17 17 import { cacheOptions } from "@/lib/api"; 18 18 import { type ApiV1GuildsModulesNotificationsGetResponse, BlueskyNotificationFlags, GuildFlags, NotificationFlags, NotificationType, YoutubeNotificationFlags } from "@/typings"; 19 - import { arrayToBitfield, BitfieldManager, bitfieldToArray, transformer } from "@/utils/bitfields"; 19 + import { arrayToBitfield, Bitfield, bitfieldToArray, transformer } from "@/utils/bitfields"; 20 20 import { createSelectableItems } from "@/utils/create-selectable-items"; 21 21 import { getCanonicalUrl } from "@/utils/urls"; 22 22 import { LoaderCircleIcon } from "lucide-react"; ··· 51 51 } = useList<ApiV1GuildsModulesNotificationsGetResponse>({ url }); 52 52 53 53 const platformFlags = getFlags(item?.type || 0); 54 - const flags = useMemo(() => new BitfieldManager(item?.flags || 0), [item?.flags]); 54 + const flags = useMemo(() => new Bitfield(item?.flags || 0), [item?.flags]); 55 55 56 56 if (error) { 57 57 return (
+3 -3
app/profile/rank/leaderboard-style.component.tsx
··· 1 1 import { type User, userStore } from "@/common/user"; 2 2 import { type ApiError, type ApiV1UsersMeGetResponse, UserFlags } from "@/typings"; 3 - import { BitfieldManager } from "@/utils/bitfields"; 3 + import { Bitfield } from "@/utils/bitfields"; 4 4 import { cn } from "@/utils/cn"; 5 5 import { deepMerge } from "@/utils/deepMerge"; 6 6 import { useState } from "react"; ··· 8 8 export default function LeaderboardStyle() { 9 9 const user = userStore((s) => s); 10 10 11 - const flags = new BitfieldManager(user?.extended?.flags || 0); 11 + const flags = new Bitfield(user?.extended?.flags || 0); 12 12 const enabled = flags.has(UserFlags.LeaderboardAlternateStyle); 13 13 14 14 const [error, setError] = useState<string | null>(null); ··· 18 18 async function update(alternateLeaderboardStyle: boolean) { 19 19 setError(null); 20 20 21 - const flags = new BitfieldManager(user?.extended?.flags || 0); 21 + const flags = new Bitfield(user?.extended?.flags || 0); 22 22 if (alternateLeaderboardStyle) flags.add(UserFlags.LeaderboardAlternateStyle); 23 23 else flags.remove(UserFlags.LeaderboardAlternateStyle); 24 24
+2 -4
utils/bitfields.ts
··· 1 - export class BitfieldManager { 2 - constructor(private flags: number) {} 1 + export class Bitfield { 2 + constructor(private flags: number) { } 3 3 4 4 add(flag: number) { 5 - if (this.has(flag)) return; 6 5 this.flags |= flag; 7 6 } 8 7 9 8 remove(flag: number) { 10 - if (!this.has(flag)) return; 11 9 this.flags &= ~flag; 12 10 } 13 11