From a0c2ca7837c4585ead0e630d4475c354671fb8fd Mon Sep 17 00:00:00 2001 From: pylixonly <82711525+pylixonly@users.noreply.github.com> Date: Sat, 12 Oct 2024 00:51:05 +0800 Subject: [PATCH] fix(badges): check if user is null --- src/core/plugins/badges/index.tsx | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/core/plugins/badges/index.tsx b/src/core/plugins/badges/index.tsx index a11e8ee..af46ca0 100644 --- a/src/core/plugins/badges/index.tsx +++ b/src/core/plugins/badges/index.tsx @@ -1,8 +1,7 @@ import { addJSXCallback } from "@lib/api/jsx"; import { after } from "@lib/api/patcher"; import { findByName } from "@metro"; -import { FC, useEffect, useState } from "react"; -import { ImageSourcePropType, ViewStyle } from "react-native"; +import { useEffect, useState } from "react"; import { defineCorePlugin } from ".."; @@ -42,19 +41,21 @@ export default defineCorePlugin({ } }, [user]); - badges.forEach((badges, i) => { - propHolder[`bunny-${user.userId}-${i}`] = { - source: { uri: badges.url }, - id: `bunny-${i}`, - label: badges.label - }; + if (user) { + badges.forEach((badges, i) => { + propHolder[`bunny-${user.userId}-${i}`] = { + source: { uri: badges.url }, + id: `bunny-${i}`, + label: badges.label + }; - r.push({ - id: `bunny-${user.userId}-${i}`, - description: badges.label, - icon: "2ba85e8026a8614b640c2837bcdfe21b", + r.push({ + id: `bunny-${user.userId}-${i}`, + description: badges.label, + icon: "_", + }); }); - }); + } }); } });