diff --git a/web-app/src/app/[...id]/page.tsx b/web-app/src/app/[...id]/page.tsx index d071832d..9c75a84a 100644 --- a/web-app/src/app/[...id]/page.tsx +++ b/web-app/src/app/[...id]/page.tsx @@ -7,20 +7,15 @@ import IndexConversationSection from "components/sections/IndexConversation"; import UserConversationSection from "components/sections/UserConversation"; import "./app.css"; import { useEffect } from "react"; -import { useAuth } from "@/context/AuthContext"; -import { useAppSelector } from "@/store/store"; +import { useAppDispatch, useAppSelector } from "@/store/store"; import { selectView } from "@/store/slices/appViewSlice"; -import { selectIndex } from "@/store/slices/indexSlice"; -import { selectConversation } from "@/store/slices/conversationSlice"; -import { selectDID } from "@/store/slices/didSlice"; +import { toggleUserIndex } from "@/store/api"; const Discovery = () => { const { api: apiService, ready: apiReady } = useApi(); - const { session } = useAuth(); const view = useAppSelector(selectView); - const index = useAppSelector(selectIndex); - const did = useAppSelector(selectDID); - const conversation = useAppSelector(selectConversation); + + const dispatch = useAppDispatch(); useEffect(() => { if (typeof window !== "undefined") { @@ -34,34 +29,31 @@ const Discovery = () => { useEffect(() => { if (typeof window !== "undefined") { - if (!apiReady || !session) return; - + if (!apiReady || !apiService) return; const isFirstLogin = localStorage.getItem("isFirstLogin") === null; const isMainnet = process.env.NEXT_PUBLIC_API_URL === "https://index.network/api"; - if (isFirstLogin) { + if (isMainnet && isFirstLogin) { localStorage.setItem("isFirstLogin", "false"); - } else { - return; - } - - if (isMainnet) { - apiService?.starIndex( + const indexes = [ "kjzl6kcym7w8y6b1fncbo7p7h2v6tei9llby5ai9n7wj09oy1aeae7hqsc1io0j", - true, - ); - apiService?.starIndex( "kjzl6kcym7w8y63ksezbl4z1frr3xd0d9fg6nfmuwr1n0ue2xc4j7dtejvl4527", - true, - ); - apiService?.starIndex( "kjzl6kcym7w8y8lefkkbpl44q6jh1zu78gaq2zp18we4wdgz1tz9vxyx213ochh", - true, - ); + ]; + indexes.forEach((indexID) => { + dispatch( + toggleUserIndex({ + indexID, + api: apiService, + toggleType: "star", + value: true, + }), + ); + }); } } - }, [session, apiReady]); + }, [apiService, apiReady, dispatch]); return (