Skip to content

Commit

Permalink
Iterate
Browse files Browse the repository at this point in the history
  • Loading branch information
serefyarar committed Jun 26, 2024
1 parent f533946 commit e1e6cd2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
14 changes: 14 additions & 0 deletions api/src/services/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ export class IndexService {
});
index.did = did;
}
index.hasItems =
index.items && index.items.edges && index.items.edges.length > 0;
delete index.items;

index.controllerDID = await this.didService.getProfile(
index.controllerDID.id,
Expand Down Expand Up @@ -84,6 +87,17 @@ export class IndexService {
createdAt
updatedAt
deletedAt
items(first:1, filters: {
where: {
deletedAt: {isNull: true}
}
}) {
edges {
node {
id
}
}
}
controllerDID {
id
profile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,19 @@ const TAB_TITLES = {

export default function TabContainer() {
const [tabKey, setTabKey] = useState<string>(TabKey.Chat);
const { id, items, loading } = useAppSelector(selectIndex);
const { data: indexData, loading } = useAppSelector(selectIndex);

useEffect(() => {
if (!items) return;
if (!indexData) return;

if (loading) {
return;
}

if (items.data && items.data.length === 0) {
if (!indexData.hasItems) {
setTabKey(TabKey.Index);
} else {
setTabKey(TabKey.Chat);
}
}, [items, loading]);
}, [loading, indexData]);

const renderTabContent = useCallback(() => {
switch (tabKey) {
Expand Down

0 comments on commit e1e6cd2

Please sign in to comment.