diff --git a/apps/web/src/components/InboxList.tsx b/apps/web/src/components/InboxList.tsx index 408d2de5..c4a6fd4c 100644 --- a/apps/web/src/components/InboxList.tsx +++ b/apps/web/src/components/InboxList.tsx @@ -1,7 +1,7 @@ import { graphql, useFragment, useSmartSubscription } from "@flowdev/relay"; import { ItemCard } from "./ItemCard"; import { ReactSortable } from "react-sortablejs"; -import { useState } from "react"; +import { useEffect, useState } from "react"; import { Button } from "@flowdev/ui/Button"; import { NewItemCard } from "./NewItemCard"; import { InboxListSubscription } from "../relay/__generated__/InboxListSubscription.graphql"; @@ -10,7 +10,41 @@ import { InboxListItemToBeInList_item$key } from "../relay/__generated__/InboxLi type InboxListProps = {}; export const InboxList = (props: InboxListProps) => { - const [showNewTaskCard, setShowNewTaskCard] = useState(false); + const [showNewItemCard, setShowNewItemCard] = useState(false); + const [itemsConnectionId, setItemsConnectionId] = useState(null); + + return ( +
+
+
Inbox
+
+ Quickly add items to your inbox so you can triage them later. +
+
+ + {showNewItemCard && itemsConnectionId && ( + setShowNewItemCard(false)} + onCancel={() => setShowNewItemCard(false)} + /> + )} +
+
+ +
+ ); +}; + +const InboxListItems = (props: { onItemsConnectionIdChange: (id: string) => void }) => { const [data] = useSmartSubscription(graphql` subscription InboxListSubscription { items( @@ -57,45 +91,24 @@ export const InboxList = (props: InboxListProps) => { }) ?? [], ); - if (!data) return null; // TODO: loading state + useEffect(() => { + if (data?.items.__id) { + props.onItemsConnectionIdChange(data.items.__id); + } + }, [data?.items.__id]); return ( -
-
-
Inbox
-
- Quickly add items to your inbox so you can triage them later. -
-
- - {showNewTaskCard && ( - setShowNewTaskCard(false)} - onCancel={() => setShowNewTaskCard(false)} - /> - )} + {}} + group="shared" + className="no-scrollbar flex h-full flex-col overflow-y-scroll px-4" + > + {items.map((item) => ( +
+
-
- {}} - group="shared" - className="no-scrollbar flex h-full flex-col overflow-y-scroll px-4" - > - {items.map((item) => ( -
- -
- ))} -
-
+ ))} + ); };