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

fix(mfi-v2-ui): fb perms error #921

Merged
merged 3 commits into from
Oct 20, 2024
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
6 changes: 5 additions & 1 deletion apps/marginfi-v2-ui/src/hooks/useFirebaseAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { useRouter } from "next/router";

import { toast } from "react-toastify";
import { useUserProfileStore } from "~/store";
import { useMrgnlendStore } from "~/store";
import { useWallet } from "~/components/wallet-v2/hooks/use-wallet.hook";
import React from "react";

Expand All @@ -16,6 +17,8 @@ const useFirebaseAccount = () => {
const [isLogged, setIsLogged] = React.useState(false);
const referralCode = React.useMemo(() => routerQuery.referralCode as string | undefined, [routerQuery.referralCode]);

const [initialized] = useMrgnlendStore((state) => [state.initialized]);

const [checkForFirebaseUser, setFirebaseUser, signoutFirebaseUser, fetchPoints, resetPoints, hasUser] =
useUserProfileStore((state) => [
state.checkForFirebaseUser,
Expand All @@ -30,6 +33,7 @@ const useFirebaseAccount = () => {
const walletId = walletInfo && walletInfo?.name ? walletInfo.name : "";

useEffect(() => {
if (!initialized) return;
// NOTE: if more point-specific logic is added, move this to a separate hook
const unsubscribe = onAuthStateChanged(firebaseApi.auth, (newUser) => {
if (newUser) {
Expand All @@ -41,7 +45,7 @@ const useFirebaseAccount = () => {
}
});
return () => unsubscribe();
}, [fetchPoints, setFirebaseUser, resetPoints]);
}, [fetchPoints, setFirebaseUser, resetPoints, initialized]);

// Wallet connection side effect (auto-login attempt)
useEffect(() => {
Expand Down
2 changes: 0 additions & 2 deletions apps/marginfi-v2-ui/src/pages/api/user/signup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ export default async function handler(req: NextApiRequest<SignupRequest>, res: a
try {
const user = await getFirebaseUserByWallet(walletAddress);
if (user) {
Sentry.captureException({ message: "User already exists" });
return res.status(STATUS_BAD_REQUEST).json({ error: "User already exists" });
}
} catch (error: any) {
Sentry.captureException(error);
return res.status(STATUS_INTERNAL_ERROR).json({ error: error.message }); // An unexpected error occurred
}

Expand Down
2 changes: 1 addition & 1 deletion packages/mrgn-ui/src/components/wallet-v2/wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ const Wallet = ({
</li>
<li>
<CopyToClipboard
text={`https://www.mfi.gg/refer/${userPointsData.referralLink}`}
text={`https://app.marginfi.com/refer/${userPointsData.referralLink}`}
onCopy={() => {
if (userPointsData.referralLink && userPointsData.referralLink.length > 0) {
setIsReferralCopied(true);
Expand Down
Loading