From db0137963cbcd4a6e685565da0e6f41193d26c31 Mon Sep 17 00:00:00 2001 From: serhat Date: Tue, 27 Feb 2024 17:41:11 +0300 Subject: [PATCH 1/6] bugfix --- .../components/layout/base/Navbar/index.tsx | 10 ++--- .../TabContainer/AccessControlTab.tsx | 37 +++---------------- .../TabContainer/ChatTab.tsx | 3 +- web-app/src/components/sections/IndexList.tsx | 18 ++------- web-app/src/components/sections/Loading.tsx | 1 + .../components/sections/UserConversation.tsx | 8 +++- .../components/sections/landing/Feature3.tsx | 11 ------ .../index-details/CreatorSettings/index.tsx | 2 +- .../site/indexes/AskIndexes/index.tsx | 35 +++++++++++------- web-app/src/context/AppContext.tsx | 32 ++++++++++++---- 10 files changed, 70 insertions(+), 87 deletions(-) diff --git a/web-app/src/components/layout/base/Navbar/index.tsx b/web-app/src/components/layout/base/Navbar/index.tsx index 84ccfa9c..c7b09c1f 100644 --- a/web-app/src/components/layout/base/Navbar/index.tsx +++ b/web-app/src/components/layout/base/Navbar/index.tsx @@ -1,14 +1,14 @@ -import { useApp } from "@/context/AppContext"; +import { IndexListTabKey, useApp } from "@/context/AppContext"; +import { AuthStatus, useAuth } from "@/context/AuthContext"; +import { useRouteParams } from "@/hooks/useRouteParams"; import cc from "classcat"; import Button from "components/base/Button"; import IconMenu from "components/base/Icon/IconMenu"; import LogoFull from "components/base/Logo/LogoFull"; import LogoMini from "components/base/Logo/LogoMini"; -import { AuthStatus, useAuth } from "@/context/AuthContext"; import { useYOffSet } from "hooks/useYOffset"; import { useRouter } from "next/navigation"; import React, { useEffect, useState } from "react"; -import { useRouteParams } from "@/hooks/useRouteParams"; import Text from "../../../base/Text"; import Col from "../Grid/Col"; import Container from "../Grid/Container"; @@ -52,12 +52,11 @@ const Navbar = ({ const yOffSet = useYOffSet(sticky); const [bgSticky, setBgSticky] = useState(false); - // const { did } = useAppSelector(selectConnection); const { session, status } = useAuth(); const { isLanding } = useRouteParams(); const router = useRouter(); - const { leftSidebarOpen, setLeftSidebarOpen } = useApp(); + const { leftSidebarOpen, setLeftTabKey, setLeftSidebarOpen } = useApp(); /* const [showTestnetWarning, setShowTestnetWarning] = useState(false); @@ -82,6 +81,7 @@ const Navbar = ({ }, [bgSticky, sticky, stickyBgChangeAfter, stickyBgColor, yOffSet]); const handleLogoClick = () => { + setLeftTabKey(IndexListTabKey.ALL); if (status === AuthStatus.CONNECTED) { router.push(`/${session?.did.parent}`); } else { diff --git a/web-app/src/components/sections/IndexConversation/TabContainer/AccessControlTab.tsx b/web-app/src/components/sections/IndexConversation/TabContainer/AccessControlTab.tsx index d10ac222..87db0b37 100644 --- a/web-app/src/components/sections/IndexConversation/TabContainer/AccessControlTab.tsx +++ b/web-app/src/components/sections/IndexConversation/TabContainer/AccessControlTab.tsx @@ -1,41 +1,16 @@ -import Col from "@/components/layout/base/Grid/Col"; import FlexRow from "@/components/layout/base/Grid/FlexRow"; -import { useApi } from "@/context/APIContext"; -import { useApp } from "@/context/AppContext"; import Soon from "@/components/site/indexes/Soon"; -import { useRole } from "@/hooks/useRole"; -import { useRouteParams } from "@/hooks/useRouteParams"; -import React from "react"; -import { useIndexConversation } from "../IndexConversationContext"; export default function AccessControlTabSection() { - const { id: indexID } = useRouteParams(); - // const [links, setLinks] = useState([]); - const { isOwner } = useRole(); - const { api } = useApi(); - const { viewedIndex } = useApp(); - const { itemsState } = useIndexConversation(); - - // const loadLinks = useCallback(async () => { - // // Logic to load chat links and update state - // // Example: - // try { - // const response = await api.searchLink({ index_id: indexID }); - // setLinks(response.records); - // } catch (error) { - // console.error("Error fetching chat links", error); - // } - // }, [api, indexID]); - - // useEffect(() => { - // loadLinks(); - // }, [loadLinks]); - return ( - +
- +
); } diff --git a/web-app/src/components/sections/IndexConversation/TabContainer/ChatTab.tsx b/web-app/src/components/sections/IndexConversation/TabContainer/ChatTab.tsx index 17602a02..6f7de248 100644 --- a/web-app/src/components/sections/IndexConversation/TabContainer/ChatTab.tsx +++ b/web-app/src/components/sections/IndexConversation/TabContainer/ChatTab.tsx @@ -17,6 +17,7 @@ export default function ChatTabSection() { flexDirection: "column", alignItems: "center", justifyContent: "center", + paddingBottom: "24rem", }} > @@ -38,7 +39,7 @@ export default function ChatTabSection() { ) : null; diff --git a/web-app/src/components/sections/IndexList.tsx b/web-app/src/components/sections/IndexList.tsx index 884342aa..53cd5678 100644 --- a/web-app/src/components/sections/IndexList.tsx +++ b/web-app/src/components/sections/IndexList.tsx @@ -8,14 +8,15 @@ import FlexRow from "components/layout/base/Grid/FlexRow"; import IndexItem from "components/site/indexes/IndexItem"; import { useRouteParams } from "hooks/useRouteParams"; import { useRouter } from "next/navigation"; -import { FC, useCallback, useEffect, useMemo, useRef } from "react"; +import { FC, useCallback, useEffect, useRef } from "react"; import { Indexes } from "types/entity"; const IndexListSection: FC = () => { const { id, isIndex } = useRouteParams(); const router = useRouter(); - const { indexes, setLeftTabKey, leftTabKey, viewedProfile } = useApp(); + const { indexes, sectionIndexes, setLeftTabKey, leftTabKey, viewedProfile } = + useApp(); const prevProfileID = useRef(viewedProfile?.id); @@ -29,19 +30,6 @@ const IndexListSection: FC = () => { [setLeftTabKey], ); - const sectionIndexes = useMemo(() => { - if (leftTabKey === IndexListTabKey.ALL) { - return indexes; - } - if (leftTabKey === IndexListTabKey.OWNER) { - return indexes.filter((i) => i.did.owned); - } - if (leftTabKey === IndexListTabKey.STARRED) { - return indexes.filter((i) => i.did.starred); - } - return []; - }, [indexes, leftTabKey]); - useEffect(() => { if (viewedProfile?.id !== prevProfileID.current) { setLeftTabKey(IndexListTabKey.ALL); diff --git a/web-app/src/components/sections/Loading.tsx b/web-app/src/components/sections/Loading.tsx index 53cb7f25..79b71ffb 100644 --- a/web-app/src/components/sections/Loading.tsx +++ b/web-app/src/components/sections/Loading.tsx @@ -5,6 +5,7 @@ export default function LoadingSection() { display: "flex", alignItems: "center", flexDirection: "column", + justifyContent: "center", height: "100%", textAlign: "center", margin: "auto", diff --git a/web-app/src/components/sections/UserConversation.tsx b/web-app/src/components/sections/UserConversation.tsx index e21d3594..1e3bb34d 100644 --- a/web-app/src/components/sections/UserConversation.tsx +++ b/web-app/src/components/sections/UserConversation.tsx @@ -4,7 +4,7 @@ import { useRouteParams } from "hooks/useRouteParams"; export default function UserConversationSection() { const { id } = useRouteParams(); - const { chatID } = useApp(); + const { chatID, sectionIndexes } = useApp(); if (!chatID || !id) { return null; @@ -21,7 +21,11 @@ export default function UserConversationSection() { maxHeight: "calc(100dvh - 12em)", }} > - + i.id)} + chatID={chatID} + did={id} + /> ); } diff --git a/web-app/src/components/sections/landing/Feature3.tsx b/web-app/src/components/sections/landing/Feature3.tsx index 10697c27..6f99a048 100644 --- a/web-app/src/components/sections/landing/Feature3.tsx +++ b/web-app/src/components/sections/landing/Feature3.tsx @@ -54,17 +54,6 @@ const FeatureSection3 = () => {

-
-
- -
-
-

Real-time listening

-

- Store, share, and discover verifiable generative information. -

-
-
diff --git a/web-app/src/components/site/index-details/CreatorSettings/index.tsx b/web-app/src/components/site/index-details/CreatorSettings/index.tsx index dbb5e98d..1275d3b4 100644 --- a/web-app/src/components/site/index-details/CreatorSettings/index.tsx +++ b/web-app/src/components/site/index-details/CreatorSettings/index.tsx @@ -129,7 +129,7 @@ const CreatorSettings = () => {
)} - Creators can add items, add tags to theirs and delete them. + Creators can add and remove items. diff --git a/web-app/src/components/site/indexes/AskIndexes/index.tsx b/web-app/src/components/site/indexes/AskIndexes/index.tsx index c3449535..a1468b39 100644 --- a/web-app/src/components/site/indexes/AskIndexes/index.tsx +++ b/web-app/src/components/site/indexes/AskIndexes/index.tsx @@ -40,7 +40,7 @@ export interface MessageWithIndex extends Message { } const AskIndexes: FC = ({ chatID, did, indexIds }) => { - const { viewedProfile, indexes: indexesFromApp, leftTabKey } = useApp(); + const { viewedProfile, sectionIndexes, leftTabKey } = useApp(); const { session } = useAuth(); const { viewedIndex } = useApp(); @@ -52,18 +52,18 @@ const AskIndexes: FC = ({ chatID, did, indexIds }) => { const bottomRef = useRef(null); - const sectionIndexes = useMemo(() => { - if (leftTabKey === IndexListTabKey.ALL) { - return indexesFromApp; - } - if (leftTabKey === IndexListTabKey.OWNER) { - return indexesFromApp.filter((i) => i.did.owned); - } - if (leftTabKey === IndexListTabKey.STARRED) { - return indexesFromApp.filter((i) => i.did.starred); - } - return []; - }, [indexesFromApp, leftTabKey]); + // const sectionIndexes = useMemo(() => { + // if (leftTabKey === IndexListTabKey.ALL) { + // return indexesFromApp; + // } + // if (leftTabKey === IndexListTabKey.OWNER) { + // return indexesFromApp.filter((i) => i.did.owned); + // } + // if (leftTabKey === IndexListTabKey.STARRED) { + // return indexesFromApp.filter((i) => i.did.starred); + // } + // return []; + // }, [indexesFromApp, leftTabKey]); const handleEditClick = (message: Message, indexOfMessage: number) => { setEditingMessage(message); @@ -174,6 +174,15 @@ const AskIndexes: FC = ({ chatID, did, indexIds }) => { height: "100%", }} > + {/*

+ {sectionIndexes + .map((i) => i.id.slice(i.id.length - 6, i.id.length)) + .join("|")} +

*/} +

+ {indexIds && + indexIds.map((i) => i.slice(i.length - 6, i.length)).join("|")} +

{messages.length ? ( diff --git a/web-app/src/context/AppContext.tsx b/web-app/src/context/AppContext.tsx index 582ba891..5f95d2ab 100644 --- a/web-app/src/context/AppContext.tsx +++ b/web-app/src/context/AppContext.tsx @@ -10,6 +10,7 @@ import { useCallback, useContext, useEffect, + useMemo, useRef, useState, } from "react"; @@ -27,20 +28,19 @@ export enum IndexListTabKey { STARRED = "starred", } -type TabKey = string; - export interface AppContextValue { indexes: Indexes[]; + sectionIndexes: Indexes[]; loading: boolean; discoveryType: DiscoveryType; setIndexes: (indexes: Indexes[]) => void; fetchIndexes: (did: string) => void; setCreateModalVisible: (visible: boolean) => void; setTransactionApprovalWaiting: (visible: boolean) => void; - leftTabKey: TabKey; - setLeftTabKey: (key: TabKey) => void; - rightTabKey: TabKey; - setRightTabKey: (key: TabKey) => void; + leftTabKey: IndexListTabKey; + setLeftTabKey: (key: IndexListTabKey) => void; + rightTabKey: string; + setRightTabKey: (key: string) => void; leftSidebarOpen: boolean; setLeftSidebarOpen: (visible: boolean) => void; rightSidebarOpen: boolean; @@ -82,8 +82,10 @@ export const AppContextProvider = ({ children }: AppContextProviderProps) => { useState(false); const [leftSidebarOpen, setLeftSidebarOpen] = useState(false); const [rightSidebarOpen, setRightSidebarOpen] = useState(false); - const [rightTabKey, setRightTabKey] = useState("history"); - const [leftTabKey, setLeftTabKey] = useState("all"); + const [rightTabKey, setRightTabKey] = useState("history"); + const [leftTabKey, setLeftTabKey] = useState( + IndexListTabKey.ALL, + ); const [loading, setLoading] = useState(false); const [chatID, setChatID] = useState(undefined); @@ -92,6 +94,19 @@ export const AppContextProvider = ({ children }: AppContextProviderProps) => { const { isLanding, discoveryType, isDID, isIndex } = useRouteParams(); + const sectionIndexes = useMemo(() => { + if (leftTabKey === IndexListTabKey.ALL) { + return indexes; + } + if (leftTabKey === IndexListTabKey.OWNER) { + return indexes.filter((i) => i.did.owned); + } + if (leftTabKey === IndexListTabKey.STARRED) { + return indexes.filter((i) => i.did.starred); + } + return []; + }, [indexes, leftTabKey]); + const fetchIndexes = useCallback( async (did: string) => { if (!apiReady) return; @@ -273,6 +288,7 @@ export const AppContextProvider = ({ children }: AppContextProviderProps) => { const contextValue: AppContextValue = { discoveryType, indexes, + sectionIndexes, setIndexes, fetchIndexes, setCreateModalVisible, From d44659720af7083ba60b290ef81fd0be2817f394 Mon Sep 17 00:00:00 2001 From: serhat Date: Tue, 27 Feb 2024 21:04:34 +0300 Subject: [PATCH 2/6] edit title enter --- .../site/input/IndexTitleInput/index.tsx | 94 ++++++++++++------- 1 file changed, 58 insertions(+), 36 deletions(-) diff --git a/web-app/src/components/site/input/IndexTitleInput/index.tsx b/web-app/src/components/site/input/IndexTitleInput/index.tsx index e914d6cb..869f3967 100644 --- a/web-app/src/components/site/input/IndexTitleInput/index.tsx +++ b/web-app/src/components/site/input/IndexTitleInput/index.tsx @@ -1,44 +1,66 @@ -import React, { useEffect, useState } from "react"; +import { + ChangeEventHandler, + FC, + FocusEventHandler, + useEffect, + useState, +} from "react"; import HeaderInput from "../HeaderInput"; export interface IndexTitleInputProps { - defaultValue: string; - disabled?: boolean; - loading?: boolean; - onChange(value: string): void; + defaultValue: string; + disabled?: boolean; + loading?: boolean; + onChange: (value: string) => void; } -const IndexTitleInput: React.VFC = ({ - defaultValue, - disabled, - loading, - onChange, + +const IndexTitleInput: FC = ({ + defaultValue, + disabled, + loading, + onChange, }) => { - const [title, setTitle] = useState(defaultValue); - - useEffect(() => { - setTitle(defaultValue || ""); - }, [defaultValue]); - - const handleBlur: React.FocusEventHandler = () => { - if (title && title !== defaultValue) { - onChange(title); - } - }; - - const handleChange: React.ChangeEventHandler = ({ target }) => { - setTitle(target?.value || ""); - }; - - return ( - - ); + const [title, setTitle] = useState(defaultValue); + + useEffect(() => { + setTitle(defaultValue || ""); + }, [defaultValue]); + + const handleBlur: FocusEventHandler = () => { + if (title && title !== defaultValue) { + onChange(title); + } + }; + + const handleChange: ChangeEventHandler = ({ + target, + }: { + target: HTMLInputElement; + }) => { + setTitle(target?.value || ""); + }; + + const handleEnter = (e: any) => { + if (e && (e.code === "Enter" || e.code === "NumpadEnter")) { + e.preventDefault(); + + if (title && title !== defaultValue) { + onChange(title); + } + } + }; + + return ( + + ); }; export default IndexTitleInput; From 3bbfe4039918952494929c45946c11fa8540e63d Mon Sep 17 00:00:00 2001 From: serhat Date: Tue, 27 Feb 2024 21:05:06 +0300 Subject: [PATCH 3/6] access control tab padding --- .../TabContainer/AccessControlTab.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/web-app/src/components/sections/IndexConversation/TabContainer/AccessControlTab.tsx b/web-app/src/components/sections/IndexConversation/TabContainer/AccessControlTab.tsx index 87db0b37..5f1d2e8c 100644 --- a/web-app/src/components/sections/IndexConversation/TabContainer/AccessControlTab.tsx +++ b/web-app/src/components/sections/IndexConversation/TabContainer/AccessControlTab.tsx @@ -1,9 +1,15 @@ -import FlexRow from "@/components/layout/base/Grid/FlexRow"; import Soon from "@/components/site/indexes/Soon"; export default function AccessControlTabSection() { return ( - +
- +
); } From 590ba4b34cedf773a0d2847c312c35340847e509 Mon Sep 17 00:00:00 2001 From: serhat Date: Tue, 27 Feb 2024 21:05:37 +0300 Subject: [PATCH 4/6] query params --- .../TabContainer/ChatTab.tsx | 4 +- web-app/src/components/sections/IndexList.tsx | 37 +++++++++++++------ .../components/sections/UserConversation.tsx | 4 +- .../site/indexes/AskIndexes/index.tsx | 27 ++++---------- web-app/src/context/AppContext.tsx | 10 ++--- 5 files changed, 41 insertions(+), 41 deletions(-) diff --git a/web-app/src/components/sections/IndexConversation/TabContainer/ChatTab.tsx b/web-app/src/components/sections/IndexConversation/TabContainer/ChatTab.tsx index 6f7de248..b84a14f5 100644 --- a/web-app/src/components/sections/IndexConversation/TabContainer/ChatTab.tsx +++ b/web-app/src/components/sections/IndexConversation/TabContainer/ChatTab.tsx @@ -25,7 +25,7 @@ export default function ChatTabSection() { ); } - if (itemsState.items.length > 0) { + if (itemsState.items.length > 0 && viewedIndex) { return chatID ? (
) : null; diff --git a/web-app/src/components/sections/IndexList.tsx b/web-app/src/components/sections/IndexList.tsx index 53cd5678..e01eb4a5 100644 --- a/web-app/src/components/sections/IndexList.tsx +++ b/web-app/src/components/sections/IndexList.tsx @@ -7,34 +7,47 @@ import Col from "components/layout/base/Grid/Col"; import FlexRow from "components/layout/base/Grid/FlexRow"; import IndexItem from "components/site/indexes/IndexItem"; import { useRouteParams } from "hooks/useRouteParams"; -import { useRouter } from "next/navigation"; +import { useRouter, useSearchParams } from "next/navigation"; import { FC, useCallback, useEffect, useRef } from "react"; import { Indexes } from "types/entity"; +const TAB_QUERY = "tab"; + const IndexListSection: FC = () => { - const { id, isIndex } = useRouteParams(); + const { id, isIndex, isDID } = useRouteParams(); const router = useRouter(); + const query = useSearchParams(); - const { indexes, sectionIndexes, setLeftTabKey, leftTabKey, viewedProfile } = - useApp(); + const { + indexes, + leftSectionIndexes, + setLeftTabKey, + leftTabKey, + viewedProfile, + } = useApp(); const prevProfileID = useRef(viewedProfile?.id); const handleTabChange = useCallback( (tabKey: IndexListTabKey) => { + if (!viewedProfile) return; + setLeftTabKey(tabKey); - if (isIndex) { - router.push(`/${viewedProfile?.id}`); + if (tabKey !== IndexListTabKey.ALL) { + router.push(`/${viewedProfile?.id}?${TAB_QUERY}=${tabKey}`); } }, - [setLeftTabKey], + [setLeftTabKey, router, viewedProfile, isIndex], ); useEffect(() => { - if (viewedProfile?.id !== prevProfileID.current) { + const tab = query.get(TAB_QUERY) as IndexListTabKey; + if (tab && isDID) { + setLeftTabKey(tab); + } else if (viewedProfile?.id !== prevProfileID.current) { setLeftTabKey(IndexListTabKey.ALL); } - }, [viewedProfile?.id, setLeftTabKey]); + }, [query, viewedProfile?.id, setLeftTabKey]); return ( <> @@ -53,7 +66,7 @@ const IndexListSection: FC = () => { /> i.did.owned).length} title={`Owned`} /> @@ -67,10 +80,10 @@ const IndexListSection: FC = () => {
- {sectionIndexes.length > 0 ? ( + {leftSectionIndexes.length > 0 ? (
( <> diff --git a/web-app/src/components/sections/UserConversation.tsx b/web-app/src/components/sections/UserConversation.tsx index 1e3bb34d..d69a708a 100644 --- a/web-app/src/components/sections/UserConversation.tsx +++ b/web-app/src/components/sections/UserConversation.tsx @@ -4,7 +4,7 @@ import { useRouteParams } from "hooks/useRouteParams"; export default function UserConversationSection() { const { id } = useRouteParams(); - const { chatID, sectionIndexes } = useApp(); + const { chatID, leftSectionIndexes } = useApp(); if (!chatID || !id) { return null; @@ -22,7 +22,7 @@ export default function UserConversationSection() { }} > i.id)} + indexIds={leftSectionIndexes.map((i) => i.id)} chatID={chatID} did={id} /> diff --git a/web-app/src/components/site/indexes/AskIndexes/index.tsx b/web-app/src/components/site/indexes/AskIndexes/index.tsx index a1468b39..fcf9dd6f 100644 --- a/web-app/src/components/site/indexes/AskIndexes/index.tsx +++ b/web-app/src/components/site/indexes/AskIndexes/index.tsx @@ -1,4 +1,4 @@ -import { IndexListTabKey, useApp } from "@/context/AppContext"; +import { useApp } from "@/context/AppContext"; import { useAuth } from "@/context/AuthContext"; import { useRouteParams } from "@/hooks/useRouteParams"; import { useChat, type Message } from "ai/react"; @@ -16,7 +16,6 @@ import { FC, useCallback, useEffect, - useMemo, useRef, useState, } from "react"; @@ -29,6 +28,7 @@ export interface ChatProps extends ComponentProps<"div"> { initialMessages?: Message[]; id?: string; } + export interface AskIndexesProps { chatID: string; did?: string; @@ -40,7 +40,7 @@ export interface MessageWithIndex extends Message { } const AskIndexes: FC = ({ chatID, did, indexIds }) => { - const { viewedProfile, sectionIndexes, leftTabKey } = useApp(); + const { viewedProfile, leftSectionIndexes, leftTabKey } = useApp(); const { session } = useAuth(); const { viewedIndex } = useApp(); @@ -52,19 +52,6 @@ const AskIndexes: FC = ({ chatID, did, indexIds }) => { const bottomRef = useRef(null); - // const sectionIndexes = useMemo(() => { - // if (leftTabKey === IndexListTabKey.ALL) { - // return indexesFromApp; - // } - // if (leftTabKey === IndexListTabKey.OWNER) { - // return indexesFromApp.filter((i) => i.did.owned); - // } - // if (leftTabKey === IndexListTabKey.STARRED) { - // return indexesFromApp.filter((i) => i.did.starred); - // } - // return []; - // }, [indexesFromApp, leftTabKey]); - const handleEditClick = (message: Message, indexOfMessage: number) => { setEditingMessage(message); setEditingIndex(indexOfMessage); @@ -98,7 +85,7 @@ const AskIndexes: FC = ({ chatID, did, indexIds }) => { if (session && viewedProfile?.id === session.did.parent) { const sections = { - owner: "indexes owned by you", + owned: "indexes owned by you", starred: "indexes starred by you", all: "all your indexes", } as any; @@ -107,7 +94,7 @@ const AskIndexes: FC = ({ chatID, did, indexIds }) => { if (viewedProfile?.id) { const sections = { - owner: "indexes owned by", + owned: "indexes owned by", starred: "indexes starred by", all: "all indexes of", } as any; @@ -157,7 +144,7 @@ const AskIndexes: FC = ({ chatID, did, indexIds }) => { scrollToBottom(); }, [messages, isLoading]); - if (sectionIndexes.length === 0) { + if (leftSectionIndexes.length === 0) { return ; } @@ -175,7 +162,7 @@ const AskIndexes: FC = ({ chatID, did, indexIds }) => { }} > {/*

- {sectionIndexes + {leftSectionIndexes .map((i) => i.id.slice(i.id.length - 6, i.id.length)) .join("|")}

*/} diff --git a/web-app/src/context/AppContext.tsx b/web-app/src/context/AppContext.tsx index 5f95d2ab..f4150bb2 100644 --- a/web-app/src/context/AppContext.tsx +++ b/web-app/src/context/AppContext.tsx @@ -24,13 +24,13 @@ type AppContextProviderProps = { export enum IndexListTabKey { ALL = "all", - OWNER = "owner", + OWNED = "owned", STARRED = "starred", } export interface AppContextValue { indexes: Indexes[]; - sectionIndexes: Indexes[]; + leftSectionIndexes: Indexes[]; loading: boolean; discoveryType: DiscoveryType; setIndexes: (indexes: Indexes[]) => void; @@ -94,11 +94,11 @@ export const AppContextProvider = ({ children }: AppContextProviderProps) => { const { isLanding, discoveryType, isDID, isIndex } = useRouteParams(); - const sectionIndexes = useMemo(() => { + const leftSectionIndexes = useMemo(() => { if (leftTabKey === IndexListTabKey.ALL) { return indexes; } - if (leftTabKey === IndexListTabKey.OWNER) { + if (leftTabKey === IndexListTabKey.OWNED) { return indexes.filter((i) => i.did.owned); } if (leftTabKey === IndexListTabKey.STARRED) { @@ -288,7 +288,7 @@ export const AppContextProvider = ({ children }: AppContextProviderProps) => { const contextValue: AppContextValue = { discoveryType, indexes, - sectionIndexes, + leftSectionIndexes, setIndexes, fetchIndexes, setCreateModalVisible, From b1d0b664ab123dd43ad3ab0501447872ed82293c Mon Sep 17 00:00:00 2001 From: serhat Date: Tue, 27 Feb 2024 21:44:57 +0300 Subject: [PATCH 5/6] cleanup --- web-app/src/components/site/indexes/AskIndexes/index.tsx | 9 --------- 1 file changed, 9 deletions(-) diff --git a/web-app/src/components/site/indexes/AskIndexes/index.tsx b/web-app/src/components/site/indexes/AskIndexes/index.tsx index fcf9dd6f..445028c7 100644 --- a/web-app/src/components/site/indexes/AskIndexes/index.tsx +++ b/web-app/src/components/site/indexes/AskIndexes/index.tsx @@ -161,15 +161,6 @@ const AskIndexes: FC = ({ chatID, did, indexIds }) => { height: "100%", }} > - {/*

- {leftSectionIndexes - .map((i) => i.id.slice(i.id.length - 6, i.id.length)) - .join("|")} -

*/} -

- {indexIds && - indexIds.map((i) => i.slice(i.length - 6, i.length)).join("|")} -

{messages.length ? ( From 149824870a28ba767331427e4535965ee4d7d031 Mon Sep 17 00:00:00 2001 From: serhat Date: Tue, 27 Feb 2024 21:52:44 +0300 Subject: [PATCH 6/6] cleanup --- web-app/src/components/sections/IndexList.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web-app/src/components/sections/IndexList.tsx b/web-app/src/components/sections/IndexList.tsx index e01eb4a5..ee4d2846 100644 --- a/web-app/src/components/sections/IndexList.tsx +++ b/web-app/src/components/sections/IndexList.tsx @@ -35,6 +35,8 @@ const IndexListSection: FC = () => { setLeftTabKey(tabKey); if (tabKey !== IndexListTabKey.ALL) { router.push(`/${viewedProfile?.id}?${TAB_QUERY}=${tabKey}`); + } else { + router.push(`/${viewedProfile?.id}`); } }, [setLeftTabKey, router, viewedProfile, isIndex],