Skip to content

Commit

Permalink
new subgraph tests and feed spike
Browse files Browse the repository at this point in the history
  • Loading branch information
dekanbro committed Mar 27, 2024
1 parent 3de4697 commit 45196b0
Show file tree
Hide file tree
Showing 15 changed files with 218 additions and 52 deletions.
3 changes: 2 additions & 1 deletion src/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import { SigSesh } from "./pages/SigSesh";
import { AllComments } from "./pages/AllComments";
import { StagingDAO } from "./pages/StagingDAO";
import { PromoteDraftForm } from "./pages/PromoteDraftForm";
import { FeedList } from "./pages/FeedList";

export const Routes = ({
setDaoChainId,
Expand Down Expand Up @@ -72,7 +73,7 @@ export const Routes = ({
<Route path="members" element={<Members />} />
<Route path="member/:memberAddress" element={<Member />} />
<Route path="members/ragequit" element={<RageQuit />} />
<Route path="articles" element={<ArticleList/>} />
<Route path="articles" element={<FeedList/>} />
<Route path="articles/:hash" element={<ArticleDetails/>} />
<Route path="articles/:hash/comments" element={<Comments/>} />
<Route path="comments" element={<StagingDAO/>} />
Expand Down
11 changes: 11 additions & 0 deletions src/abis/nftCuratorShaman.json
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,17 @@
"stateMutability": "payable",
"type": "function"
},
{
"inputs": [
{ "internalType": "address", "name": "to", "type": "address" },
{ "internalType": "bytes32", "name": "postId", "type": "bytes32" },
{ "internalType": "string", "name": "content", "type": "string" }
],
"name": "comment",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{ "internalType": "uint256", "name": "parentId", "type": "uint256" }
Expand Down
60 changes: 36 additions & 24 deletions src/components/ArticleListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import React from "react";
import { useCurrentDao, useDaoData } from "@daohaus/moloch-v3-hooks";
import { ParMd, Tooltip } from "@daohaus/ui";
import { Badge, ParMd, Tag, Tooltip } from "@daohaus/ui";
import { ArticleCard, ArticleLinks, CardAvatar, CardDescription, CardTitle, CardTitleWrapper, StyledLink } from "../utils/listStyles";
import { AuthorAvatar } from "./AuthorAvatar";
import { Link } from "react-router-dom";
Expand All @@ -10,23 +10,28 @@ import { Comments } from "../pages/Comments";
import { ZERO_ADDRESS } from "@daohaus/utils";
import { BlogPost } from "../utils/types";
import { DEFAULT_NETWORK_ID } from "../utils/constants";
import styled from "styled-components";

const Tags = styled.div`
display: flex;
export const ArticleListItem = ({parsedContent}:{parsedContent: BlogPost}) => {
`


export const ArticleListItem = ({ parsedContent }: { parsedContent: BlogPost }) => {

const getArticleUrl = (daoId: string, articleId: string, daoChain?: string) => {
return `/molochv3/${daoChain || DEFAULT_NETWORK_ID}/${daoId}/articles/${articleId}`
}

if(!parsedContent.id || !parsedContent.daoId || !parsedContent.content) {
if (!parsedContent.id || !parsedContent.daoId || !parsedContent.content) {
return <ParMd>Invalid Metadata Format</ParMd>
}

console.log(parsedContent)

return (
<ArticleCard>
{/* <CardImg>
{/* <CardImg>
<Link to={parsedContent?.id}>
<img
src={
Expand All @@ -36,29 +41,36 @@ export const ArticleListItem = ({parsedContent}:{parsedContent: BlogPost}) => {
/>
</Link>
</CardImg> */}
<CardAvatar>
<CardAvatar>


{parsedContent?.authorAddress ? (
<AuthorAvatar address={parsedContent?.authorAddress} />
) : (
<AuthorAvatar address={ZERO_ADDRESS} />
)}
</CardAvatar>
{parsedContent?.tag == "DIN" && (<CardTitleWrapper>
<Link to={`${getArticleUrl(parsedContent.daoId, parsedContent.id)}/comments`}><CardTitle>{parsedContent?.title}</CardTitle></Link>
<Tooltip key={parsedContent?.id} content={`updoot & collect`} triggerEl={(<CollectButton hash={parsedContent?.id} link={true} />)} />
</CardTitleWrapper>)}

{parsedContent?.authorAddress ? (
<AuthorAvatar address={parsedContent?.authorAddress} />
) : (
<AuthorAvatar address={ZERO_ADDRESS} />
)}
</CardAvatar>
<CardTitleWrapper>
<Link to={`${getArticleUrl(parsedContent.daoId, parsedContent.id)}/comments`}><CardTitle>{parsedContent?.title}</CardTitle></Link>
<Tooltip key={parsedContent?.id} content={`updoot & collect`} triggerEl={(<CollectButton hash={parsedContent?.id} link={true} />)} />
</CardTitleWrapper>
<CardDescription>{parsedContent?.content}</CardDescription>
<ParMd>{parsedContent?.contentURI}</ParMd>
<ArticleLinks>
<StyledLink to={getArticleUrl(parsedContent.daoId, parsedContent.id)}> detail</StyledLink>
<StyledLink to={`${getArticleUrl(parsedContent.daoId, parsedContent.id)}/comments`}> comments <Comments hash={parsedContent?.id} badge /> </StyledLink>
<StyledLink to={``}> created at: {new Date(Number(parsedContent.createdAt) * 1000).toString()} </StyledLink>
<CardDescription>{parsedContent?.content}</CardDescription>
<ParMd>{parsedContent?.contentURI}</ParMd>
<Tags>{parsedContent?.tag && (<Tag tagColor="violet"> {parsedContent?.tag}</Tag>)}</Tags>
<ArticleLinks>
{!parsedContent?.parentId && (<StyledLink to={getArticleUrl(parsedContent.daoId, parsedContent.id)}> detail</StyledLink>)}
{!parsedContent?.parentId && (<StyledLink to={`${getArticleUrl(parsedContent.daoId, parsedContent.id)}/comments`}> comments <Comments hash={parsedContent?.id} badge /> </StyledLink>)}
{parsedContent?.parentId && parsedContent?.parentId != "0" && (
<StyledLink to={`/molochv3/${parsedContent.daoChain}/${parsedContent.daoId}/articles/${parsedContent.parentId}`}> Reply to ↩
</StyledLink>
)}

</ArticleLinks>
<StyledLink to={``}> created at: {new Date(Number(parsedContent.createdAt) * 1000).toString()} </StyledLink>

</ArticleLinks>


</ArticleCard>
</ArticleCard>
);
};
2 changes: 0 additions & 2 deletions src/components/DraftListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export const DraftListItem = ({parsedContent, createdAt, dao, daoChain, memberAd
daoChain: string,
memberAddress: string
}) => {
console.log("p>>>>>>>>>>>> parsedContent", parsedContent)
const getArticleUrl = (daoId: string, articleId: string, daoChain?: string) => {
return `/molochv3/${daoChain || DEFAULT_NETWORK_ID}/${daoId}/articles/${articleId}`
}
Expand All @@ -29,7 +28,6 @@ console.log("p>>>>>>>>>>>> parsedContent", parsedContent)
return <ParMd>Invalid Metadata Format</ParMd>
}

console.log(parsedContent)

return (
<ArticleCard>
Expand Down
2 changes: 1 addition & 1 deletion src/components/NewDraftDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export const NewDraftDialog = () => {
return (
<Dialog>
<DialogTrigger asChild>
<a><Button size="sm" variant="link" color="secondary">New Draft or Submit Content</Button></a>
<a><Button size="sm" variant="link" color="primary">Create Content</Button></a>
</DialogTrigger>
<DialogContent
title="New Draft or Submit Draft"
Expand Down
1 change: 0 additions & 1 deletion src/components/RandomSubTopics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export const RandomSubTopic = ({daoChain}: {daoChain: ValidNetwork}) => {
},
});
if (query.items && shouldUpdate) {
console.log("query.items", query.items);
setDaos(query.items);
setLoading(false);
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/hub/DaoCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const DaoCard = ({
color="secondary"
to={`/molochv3/${chainIdLocal}/${id}/articles`}
>
Articles
Feed
</ButtonRouterLink>
<ButtonRouterLink
color="secondary"
Expand Down
1 change: 0 additions & 1 deletion src/components/hub/HomeDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const HomeDashboard = () => {
},
});
if (query.items && shouldUpdate) {
console.log("query.items", query.items);
setDaoData(query.items);
setLoading(false);
}
Expand Down
46 changes: 29 additions & 17 deletions src/components/layout/DaoContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Outlet, useLocation, useParams } from "react-router-dom";
import { DHLayout, useDHConnect } from "@daohaus/connect";
import { TXBuilder } from "@daohaus/tx-builder";
import { ValidNetwork } from "@daohaus/keychain-utils";
import { CurrentDaoProvider, useDaoData } from "@daohaus/moloch-v3-hooks";
import { CurrentDaoProvider, useDaoData, useDaoMember } from "@daohaus/moloch-v3-hooks";
import { HeaderAvatar } from "../HeaderAvatar";
import { useShamanNFT } from "../../hooks/useShamanNFT";
import { MolochV3Dao } from "@daohaus/moloch-v3-data";
Expand Down Expand Up @@ -49,15 +49,15 @@ const DaoWrapper = ({
}
return (

<TXBuilder
publicClient={publicClient}
chainId={daoChain}
daoId={dao?.id}
safeId={dao?.safeAddress}
appState={{ dao, memberAddress: memberAddress || address, shamanData: {shamanName, shamanAddress, sdata}, chainId: chainId }}
>
<Outlet />
</TXBuilder>
<TXBuilder
publicClient={publicClient}
chainId={daoChain}
daoId={dao?.id}
safeId={dao?.safeAddress}
appState={{ dao, memberAddress: memberAddress || address, shamanData: { shamanName, shamanAddress, sdata }, chainId: chainId }}
>
<Outlet />
</TXBuilder>

);
};
Expand All @@ -81,15 +81,27 @@ const Dao = ({
daoChain: daoChain as string,
});

const { member } = useDaoMember({
daoId: daoId as string,
daoChain: daoChain as ValidNetwork,
memberAddress: memberAddress || address,
});

const routePath = `molochv3/${daoChain}/${daoId}`;
// const curratorLabel = member?.shares ? "Curators" : "Curators 🔒";
// const collectorLabel = member?.loot ? "Collectors" : "Collectors 🔒";
const curratorLabel = "Curators";
const collectorLabel = "Collectors";



const navLinks = useMemo(() => {
let baseLinks = [
{ label: "Topics ↩", href: `/` },
{ label: "Articles", href: `/${routePath}/articles` },
{ label: "Comments", href: `/${routePath}/comments` },
{ label: "Curators", href: `/${routePath}` },
{ label: "Collectors", href: `/${routePath}/polls` },
{ label: "Feed", href: `/${routePath}/articles` },
// { label: "Comments", href: `/${routePath}/comments` },
{ label: curratorLabel, href: `/${routePath}` },
{ label: collectorLabel, href: `/${routePath}/polls` },

// { label: "Safes", href: `/${routePath}/safes` },
// { label: "Proposals", href: `/${routePath}/proposals` },
Expand All @@ -100,9 +112,9 @@ const Dao = ({

return address
? [
...baseLinks,
{ label: "Profile", href: `/${routePath}/member/${address}` },
]
...baseLinks,
{ label: "Profile", href: `/${routePath}/member/${address}` },
]
: baseLinks;
}, [daoChain, daoId, address]);

Expand Down
7 changes: 5 additions & 2 deletions src/hooks/useRecords.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useQuery } from "react-query";
import { ValidNetwork, Keychain } from "@daohaus/keychain-utils";
import { listRecords } from "@daohaus/moloch-v3-data";
import { handleErrorMessage } from "@daohaus/utils";
import { BlogPost } from "../utils/types";

const defaultGraphApiKeys = {
"0x1": import.meta.env.VITE_GRAPH_API_KEY_MAINNET,
Expand Down Expand Up @@ -76,10 +77,12 @@ const fetchRecords = async ({
}


// console.log('>>>>>>>>>>>items', recordType, data.items);
// console.log('>>>>>>>>>>>.hash', hash);
for (let i = 0; i < data.items.length; i++) {
(data.items[i].parsedContent as BlogPost).tag = recordType;
}

if (hash && recordType === "DIN") {

return data.items.filter(
(item) => {
return (item as Record)?.parsedContent?.id === hash
Expand Down
4 changes: 3 additions & 1 deletion src/legos/forms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,9 @@ export const APP_FORM: Record<string, CustomFormLego> = {
requiredFields: { content: true },
submitButtonText: "Promote Draft",
log: true,
tx: APP_TX.COMMENT as TXLego,
// tx: APP_TX.NEW_SUBTOPIC as TXLego,
tx: APP_TX.COMMENTNFT as TXLego,

fields: [
APP_FIELD.COMMENTPARENTID_FIELD,
APP_FIELD.TITLE_FIELD,
Expand Down
27 changes: 27 additions & 0 deletions src/legos/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,33 @@ export const APP_TX = {
{ type: 'static', value: POSTER_TAGS.daoDatabaseSharesOrLoot },
],
},
COMMENTNFT: {
id: "COMMENTNFT",
contract: DOMAIN_CONTRACT.NEW_POST,
method: 'comment',
args: [
".memberAddress",
".formValues.contentHash",
{
type: "JSONDetails",
jsonSchema: {
daoId: ".dao.id",
table: { type: 'static', value: 'DINComment' },
queryType: { type: 'static', value: 'list' },
content: ".formValues.content",
contentURIType: { type: "static", value: "url" },
// imageURI: ".formValues.image",
// imageURIType: { type: "static", value: "url" },
parentId: { type: "static", value: "0" },
id: ".formValues.contentHash",
authorAddress: ".memberAddress",
createdAt: '.formValues.createdAt',
chainId: `.chainId`

},
},
],
},
STAGE_ARTICLE: {
id: "STAGE_ARTICLE",
contract: CONTRACT.POSTER,
Expand Down
Loading

0 comments on commit 45196b0

Please sign in to comment.