Skip to content

Commit

Permalink
Merge branch 'main' into refactor-proposal-feed
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 authored Aug 5, 2024
2 parents 02e1a2e + 4af0f4d commit bc8962c
Show file tree
Hide file tree
Showing 56 changed files with 930 additions and 491 deletions.
1 change: 1 addition & 0 deletions .devcontainer/post-create.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/latest/download/near-cli-rs-installer.sh | sh

npm install
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/mpeterdev/bos-loader/releases/download/v0.7.1/bos-loader-v0.7.1-installer.sh | sh
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/deploy-prod-mainnet-devhub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ jobs:
- name: Set replacements
id: set_replacements
run: |
echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value), {"find": "${REPL_POSTHOG_API_KEY}", "replace": "'${{ secrets.POSTHOG_API_KEY }}'"}]' aliases.mainnet.json | tr -d "\n\r")" >> $GITHUB_OUTPUT
jq '.REPL_POSTHOG_API_KEY = "${{ secrets.POSTHOG_API_KEY }}"' aliases.mainnet.json > temp.aliases.mainnet.json && mv temp.aliases.mainnet.json aliases.mainnet.json
echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value)]' aliases.mainnet.json | tr -d "\n\r")" >> $GITHUB_OUTPUT
- name: Replace placeholders
uses: flcdrg/replace-multiple-action@v1
Expand Down
3 changes: 2 additions & 1 deletion instances/devhub.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
"REPL_SOCIAL_CONTRACT": "social.near",
"REPL_RPC_URL": "https://rpc.mainnet.near.org",
"REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_prod_v1_proposals_with_latest_snapshot",
"REPL_INDEXER_HASURA_ROLE": "polyprogrammist_near"
"REPL_INDEXER_HASURA_ROLE": "polyprogrammist_near",
"REPL_POSTHOG_API_KEY": "01234567890123456789012345678901234567890123456"
}
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,16 @@ return (

return (
<Widget
src="${REPL_NEAR}/widget/v1.Posts.Post"
src={`${REPL_DEVHUB}/widget/devhub.components.organism.Feed.Posts.Post`}
loading={<div className="w-100" style={{ height: "200px" }} />}
props={{
accountId: item.accountId,
blockHeight: item.blockHeight,
filteredAccountIds: filteredAccountIds,
page: props.page,
handle: props.handle,
tab: props.tab,
highlight: props.highlight,
}}
/>
);
Expand All @@ -118,6 +122,10 @@ return (
src={`${REPL_DEVHUB}/widget/devhub.components.organism.Feed.NearQueryApi`}
props={{
GRAPHQL_ENDPOINT,
page: props.page,
handle: props.handle,
tab: props.tab,
highlight: props.highlight,
filteredAccountIds: filteredAccountIds,
showFlagAccountFeature: showFlagAccountFeature,
onNewUnseenPosts: props.onNewUnseenPosts,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,12 @@ if (!initialized && sort) {
return (
<>
<Widget
src="${REPL_NEAR}/widget/Posts.Feed"
src={`${REPL_DEVHUB}/widget/devhub.components.organism.Feed.Posts.Feed`}
props={{
page: props.page,
handle: props.handle,
tab: props.tab,
highlight: props.highlight,
hasMore,
isLoading,
loadMorePosts: () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
const GRAPHQL_ENDPOINT =
props.GRAPHQL_ENDPOINT || "https://near-queryapi.api.pagoda.co";
const loadMorePosts = props.loadMorePosts;
const hasMore = props.hasMore || false;
const posts = props.posts || [];

const Post = styled.div`
border-bottom: 1px solid #eceef0;
padding: 24px 0 12px;
@media (max-width: 1024px) {
padding: 12px 0 0;
}
`;

const TextLink = styled("Link")`
font-weight: 600;
`;

const renderItem = (item) => {
if (item.accounts_liked.length !== 0) {
item.accounts_liked = JSON.parse(item.accounts_liked);
}

if (item.content.includes("repost")) {
const repostData = JSON.parse(item.content);
const fullPath = repostData[0].value.item.path.split("/");
item.repostData = {
reposted_by: item.account_id,
reposted_content: JSON.parse(item.content),
original_post_accountId: fullPath[0],
original_post_blockHeight: repostData[0].value.item.blockHeight,
};
}
return (
<Post className="post" key={item.block_height + "_" + item.account_id}>
<Widget
src={`${REPL_DEVHUB}/widget/devhub.components.organism.Feed.Posts.Post`}
props={{
page: props.page,
handle: props.handle,
tab: props.tab,
accountId: item.account_id,
blockHeight: item.block_height,
blockTimestamp: item.block_timestamp,
content: item.content,
comments: item.comments,
likes: item.accounts_liked,
GRAPHQL_ENDPOINT,
verifications: item.verifications,
showFlagAccountFeature: props.showFlagAccountFeature ?? false,
profile: item.profile,
isRespost: item.isRespost,
repostData: item.repostData,
highlight: props.highlight,
}}
/>
</Post>
);
};

if (posts.length === 0 && !props.isLoading) {
return (
<div className="alert alert-info mx-3" role="alert">
Build your feed by finding
<TextLink className="alert-link" href="near/widget/PeoplePage">
people to follow
</TextLink>
</div>
);
}

const renderedItems = posts.map(renderItem);

return (
<InfiniteScroll
pageStart={0}
loadMore={loadMorePosts}
hasMore={hasMore}
initialLoad={false}
loader={
<div className="loader">
<span
className="spinner-grow spinner-grow-sm me-1"
role="status"
aria-hidden="true"
/>
Loading ...
</div>
}
>
{renderedItems}
</InfiniteScroll>
);
Loading

0 comments on commit bc8962c

Please sign in to comment.