({
});
}
}
- }, [settingsOpened]);
+ }, [
+ blocks.local.access,
+ blocks.local.block,
+ blocks.local.id,
+ blocks.private.access,
+ blocks.private.block,
+ blocks.private.id,
+ copy,
+ editableBlocks,
+ emptyBlock,
+ is_admin,
+ organizationId,
+ settingsOpened,
+ ]);
return (
diff --git a/src/components/supabase-provider.tsx b/src/components/supabase-provider.tsx
index 82e592f..dfa9c07 100644
--- a/src/components/supabase-provider.tsx
+++ b/src/components/supabase-provider.tsx
@@ -1,6 +1,6 @@
"use client";
-import { createContext, useEffect } from "react";
+import { createContext, useCallback, useEffect } from "react";
import { useRouter, usePathname } from "next/navigation";
import { useSetUserProfile } from "@/hooks/use-user-profile";
import {
@@ -97,7 +97,15 @@ export default function SupabaseProvider({
return () => {
subscription.unsubscribe();
};
- }, [router, supabase, session, pathname]);
+ }, [
+ router,
+ session,
+ pathname,
+ setUserProfile,
+ setOrganizations,
+ setRoles,
+ setSession,
+ ]);
useEffect(() => {
if (organizations && organizations.length && session?.user.id)
@@ -112,9 +120,9 @@ export default function SupabaseProvider({
console.log(error);
}
});
- }, [supabase, organizations, session]);
+ }, [organizations, session, setRoles]);
- const refreshDevice = () => {
+ const refreshDevice = useCallback(() => {
getDevices().then(({ data, error }) => {
if (error) {
toast.error(error.message);
@@ -123,7 +131,7 @@ export default function SupabaseProvider({
setDevices(data);
}
});
- };
+ }, [setDevices]);
useEffect(() => {
if (session?.user.id && xpDatas && !xpDatas[session.user.id]) {
const userData: XpUserData = {
@@ -178,7 +186,7 @@ export default function SupabaseProvider({
refreshDevice();
}
}
- }, [xpDatas, session?.user.id]);
+ }, [xpDatas, session?.user?.id, setXpDatas, refreshDevice]);
return (
diff --git a/src/hooks/use-block.tsx b/src/hooks/use-block.tsx
index 1a00562..37a5c69 100644
--- a/src/hooks/use-block.tsx
+++ b/src/hooks/use-block.tsx
@@ -54,7 +54,7 @@ export function useSettingBlock(
},
});
- const _load = async () => {
+ const _load = React.useCallback(async () => {
if (user?.id) {
console.log("loading...", organizationId, applicationKey, blockKey);
const { data: publicDate } = await supabase
@@ -94,21 +94,21 @@ export function useSettingBlock(
local: localData || prev.local,
}));
}
- };
- const load = () => {
+ }, [applicationKey, blockKey, organizationId, user?.id]);
+ const load = React.useCallback(() => {
if (loading) {
return;
}
setLoading(true);
_load().then(() => setLoading(false));
- };
+ }, [loading, _load]);
React.useEffect(() => {
if (organizationId && user?.id) {
load();
}
- }, [organizationId, user?.id]);
+ }, [load, organizationId, user?.id]);
const mutate = async (block: Block) => {
let id = block.id;