From bfd39a1bb38e6eb3a06726f289ced218c43ca497 Mon Sep 17 00:00:00 2001 From: martines3000 Date: Mon, 4 Mar 2024 13:23:19 +0100 Subject: [PATCH] chore: rename .env.example, revert last change --- packages/dapp/{.env.example => example.env} | 2 +- .../components/EncryptedSessionProvider/index.tsx | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) rename packages/dapp/{.env.example => example.env} (93%) diff --git a/packages/dapp/.env.example b/packages/dapp/example.env similarity index 93% rename from packages/dapp/.env.example rename to packages/dapp/example.env index 0bee1758a..ccba7d364 100644 --- a/packages/dapp/.env.example +++ b/packages/dapp/example.env @@ -13,7 +13,7 @@ POLYGON_MUMBAI_RPC_URL= # Masca version -NEXT_PUBLIC_MASCA_VERSION=v1.1.0 +NEXT_PUBLIC_MASCA_VERSION= # SupaBase Public NEXT_PUBLIC_SUPABASE_URL= diff --git a/packages/dapp/src/components/EncryptedSessionProvider/index.tsx b/packages/dapp/src/components/EncryptedSessionProvider/index.tsx index 661bd0232..ede1b146e 100644 --- a/packages/dapp/src/components/EncryptedSessionProvider/index.tsx +++ b/packages/dapp/src/components/EncryptedSessionProvider/index.tsx @@ -1,13 +1,11 @@ 'use client'; -import { useEffect, useState } from 'react'; +import { useEffect, useMemo } from 'react'; import { hexToUint8Array } from '@blockchain-lab-um/masca-connector'; -import { SupabaseClient } from '@supabase/supabase-js'; import { useTranslations } from 'next-intl'; import { useAccount } from 'wagmi'; import { createClient } from '@/utils/supabase/client'; -import { Database } from '@/utils/supabase/database.types'; import { useMascaStore, useToastStore } from '@/stores'; import { useAuthStore } from '@/stores/authStore'; import { useEncryptedSessionStore } from '@/stores/encryptedSessionStore'; @@ -15,7 +13,6 @@ import { useEncryptedSessionStore } from '@/stores/encryptedSessionStore'; export const EncryptedSessionProvider = () => { const t = useTranslations('EncryptedSessionProvider'); const token = useAuthStore((state) => state.token); - const [client, setClient] = useState>(null); const { address } = useAccount(); @@ -39,6 +36,8 @@ export const EncryptedSessionProvider = () => { const api = useMascaStore((state) => state.mascaApi); + const client = useMemo(() => createClient(token ?? ''), [token]); + // Decrypt data const decryptData = async ({ iv, @@ -137,7 +136,6 @@ export const EncryptedSessionProvider = () => { }; useEffect(() => { - if (!client) return; if (sessionId && deviceType === 'primary') { client .channel('realtime encrypted_sessions') @@ -200,10 +198,5 @@ export const EncryptedSessionProvider = () => { }); }, [address]); - useEffect(() => { - if (!token) return; - setClient(createClient(token)); - }, [token]); - return null; };