Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Community Announcements #603

Merged
merged 30 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6b56e41
feat: Community Announcements Page (#567)
Megha-Dev-19 Dec 26, 2023
7ff903b
replacements for testnet
elliotBraem Dec 26, 2023
6857ebf
allow no communities found
elliotBraem Dec 27, 2023
3d86230
attach 2N when creating a community
elliotBraem Dec 27, 2023
f70467f
Merge branch 'main' into develop
elliotBraem Dec 28, 2023
aa7091e
configures with updated function call
elliotBraem Dec 28, 2023
8a0ca66
updated announcements UI (#606)
Megha-Dev-19 Dec 29, 2023
16a0a0c
Merge branch 'main' into develop
elliotBraem Dec 29, 2023
7579358
Merge branch 'main' into develop
elliotBraem Jan 1, 2024
d9be9ed
Merge branch 'main' into develop
elliotBraem Jan 3, 2024
f1e04c3
updates feed
elliotBraem Jan 4, 2024
81663fe
working feed
elliotBraem Jan 5, 2024
cd99e2a
show preview
elliotBraem Jan 5, 2024
170ea4f
Merge branch 'main' into develop
elliotBraem Jan 5, 2024
783b871
fix testnet
elliotBraem Jan 5, 2024
d81cfc5
Revert "initial typescript support (#468)"
elliotBraem Jan 9, 2024
da86a64
Move community Github and Board widgets from devgogigs to devhub (#561)
Megha-Dev-19 Jan 5, 2024
f8c08b8
Kanban board UI enhancement (#620)
Megha-Dev-19 Jan 6, 2024
c387fee
update to devhub.near
elliotBraem Jan 11, 2024
fc8c50e
fix posts for devgovgigs.near
elliotBraem Jan 11, 2024
1bffa62
Merge branch 'main' into develop
elliotBraem Jan 11, 2024
f375846
Points tests to devhub.near rather than devgovgigs.near (#595)
elliotBraem Jan 11, 2024
f0577b9
fix feeds
elliotBraem Jan 16, 2024
c2ed67e
Announcements tests (#639)
Megha-Dev-19 Jan 17, 2024
7ef1bd2
Merge branch 'main' of https://github.com/NEAR-DevHub/neardevhub-bos …
elliotBraem Jan 17, 2024
4616296
tests
elliotBraem Jan 17, 2024
19c57ec
format
elliotBraem Jan 17, 2024
1aad90e
working test
elliotBraem Jan 17, 2024
74b46e2
format
elliotBraem Jan 17, 2024
0262e77
posts legacy
elliotBraem Jan 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions replacements.dev.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"REPL_DEVHUB": "devhub-dev.testnet",
"REPL_DEVHUB_LEGACY": "devhub-dev.testnet",
"REPL_DEVHUB_CONTRACT": "thomaspreview.testnet",
"REPL_DEVHUB_CONTRACT": "bodevhub.testnet",
"REPL_NEAR": "discom.testnet",
"REPL_MOB": "eugenethedream",
"REPL_EFIZ": "efiz.testnet"
"REPL_EFIZ": "efiz.testnet",
"REPL_DEVS": "nearbuilders.testnet"
}
3 changes: 2 additions & 1 deletion replacements.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"REPL_DEVHUB_CONTRACT": "devgovgigs.near",
"REPL_NEAR": "near",
"REPL_MOB": "mob.near",
"REPL_EFIZ": "efiz.near"
"REPL_EFIZ": "efiz.near",
"REPL_DEVS": "devs.near"
}
3 changes: 2 additions & 1 deletion replacements.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
"REPL_DEVHUB_CONTRACT": "thomaselliot.testnet",
"REPL_NEAR": "discom.testnet",
"REPL_MOB": "eugenethedream",
"REPL_EFIZ": "efiz.testnet"
"REPL_EFIZ": "efiz.testnet",
"REPL_DEVS": "nearbuilders.testnet"
}
64 changes: 17 additions & 47 deletions src/core/adapter/devhub-contract.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@ function hasModerator({ account_id }) {
}

function createCommunity({ inputs }) {
return Near.call("${REPL_DEVHUB_CONTRACT}", "create_community", { inputs });
return Near.call(
"${REPL_DEVHUB_CONTRACT}",
"create_community",
{ inputs },
Big(10).pow(14), // gas
Big(2) * Big(10).pow(24) // deposit (2N)
);
}

function getCommunity({ handle }) {
Expand Down Expand Up @@ -112,52 +118,6 @@ function getAllCommunitiesMetadata() {
);
}

function getAvailableAddons() {
return [
{
id: "wiki",
title: "Wiki",
description: "Create a wiki for your community",
view_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.wiki.Viewer",
configurator_widget:
"${REPL_DEVHUB}/widget/devhub.entity.addon.wiki.Configurator",
},
{
id: "telegram",
title: "Telegram",
description: "Connect your telegram",
view_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.telegram.Viewer",
configurator_widget:
"${REPL_DEVHUB}/widget/devhub.entity.addon.telegram.Configurator",
},
{
id: "github",
title: "Github",
description: "Connect your github",
view_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.github.Viewer",
configurator_widget:
"${REPL_DEVHUB}/widget/devhub.entity.addon.github.Configurator",
},
{
id: "kanban",
title: "Kanban",
description: "Connect your github kanban board",
view_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.kanban.Viewer",
configurator_widget:
"${REPL_DEVHUB}/widget/devhub.entity.addon.kanban.Configurator",
},
{
id: "blog",
title: "Blog",
description: "Create a blog for your community",
view_widget: "${REPL_DEVHUB}/widget/devhub.entity.addon.blog.Viewer",
configurator_widget:
"${REPL_DEVHUB}/widget/devhub.entity.addon.blog.Configurator",
},
];
// return Near.view("${REPL_DEVHUB_CONTRACT}", "get_available_addons") ?? null;
}

function getCommunityAddons({ handle }) {
return Near.view("${REPL_DEVHUB_CONTRACT}", "get_community_addons", {
handle,
Expand Down Expand Up @@ -193,6 +153,15 @@ function getPostsByLabel({ label }) {
);
}

function setCommunitySocialDB({ handle, data }) {
return (
Near.call("${REPL_DEVHUB_CONTRACT}", "set_community_socialdb", {
handle,
data,
}) ?? null
);
}

function useQuery(name, params) {
const initialState = { data: null, error: null, isLoading: true };

Expand Down Expand Up @@ -246,5 +215,6 @@ return {
getPost,
getPostsByAuthor,
getPostsByLabel,
setCommunitySocialDB,
useQuery,
};
8 changes: 4 additions & 4 deletions src/devhub/components/layout/LikeButton/Faces.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ return (
{renderFaces.map((accountId, i) => (
<a
key={i}
href={`#/mob.near/widget/ProfilePage?accountId=${accountId}`}
href={`#/${REPL_MOB}/widget/ProfilePage?accountId=${accountId}`}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, we can have these testnet widgets now

className="text-decoration-none d-inline-block"
>
<Widget
src="mob.near/widget/Profile.OverlayTrigger"
src="${REPL_MOB}/widget/Profile.OverlayTrigger"
props={{
accountId,
children: (
<Widget
src="mob.near/widget/ProfileImage"
src="${REPL_MOB}/widget/ProfileImage"
props={{
metadata,
accountId,
Expand Down Expand Up @@ -100,7 +100,7 @@ return (
{faces.slice(0, 10).map((accountId, i) => (
<Fragment key={i}>
<Widget
src="mob.near/widget/ProfileLine"
src="${REPL_MOB}/widget/ProfileLine"
props={{ accountId, link: false }}
/>
<br />
Expand Down
4 changes: 2 additions & 2 deletions src/devhub/components/molecule/ProfileCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const ProfileCard = (props) => {
{!hideImage && (
<Widget
key="image"
src="mob.near/widget/ProfileImage"
src="${REPL_MOB}/widget/ProfileImage"
props={{
style: { width: "2.5em", height: "2.5em", marginRight: "0.3em" },
profile,
Expand Down Expand Up @@ -80,7 +80,7 @@ const ProfileCard = (props) => {
if (props.tooltip === true) {
return (
<Widget
src="mob.near/widget/Profile.OverlayTrigger"
src="${REPL_MOB}/widget/Profile.OverlayTrigger"
props={{ accountId, children: inner }}
/>
);
Expand Down
119 changes: 119 additions & 0 deletions src/devhub/components/organism/Feed.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
const { Feed } = VM.require("${REPL_DEVS}/widget/Feed");
Feed = Feed || (() => <></>);

const filteredAccountIds = props.filteredAccountIds ?? [];

const GRAPHQL_ENDPOINT =
props.GRAPHQL_ENDPOINT ?? "https://near-queryapi.api.pagoda.co";

let lastPostSocialApi = Social.index("post", "main", {
limit: 1,
order: "desc",
});

if (lastPostSocialApi == null) {
return "Loading...";
}

State.init({
// If QueryAPI Feed is lagging behind Social API, fallback to old widget.
shouldFallback: false,
});

function fetchGraphQL(operationsDoc, operationName, variables) {
return asyncFetch(`${GRAPHQL_ENDPOINT}/v1/graphql`, {
method: "POST",
headers: { "x-hasura-role": "dataplatform_near" },
body: JSON.stringify({
query: operationsDoc,
variables: variables,
operationName: operationName,
}),
});
}

const lastPostQuery = `
query IndexerQuery {
dataplatform_near_social_feed_posts( limit: 1, order_by: { block_height: desc }) {
block_height
}
}
`;

fetchGraphQL(lastPostQuery, "IndexerQuery", {})
.then((feedIndexerResponse) => {
if (
feedIndexerResponse &&
feedIndexerResponse.body.data.dataplatform_near_social_feed_posts.length >
0
) {
const nearSocialBlockHeight = lastPostSocialApi[0].blockHeight;
const feedIndexerBlockHeight =
feedIndexerResponse.body.data.dataplatform_near_social_feed_posts[0]
.block_height;

const lag = nearSocialBlockHeight - feedIndexerBlockHeight;
let shouldFallback = lag > 2 || !feedIndexerBlockHeight;
if (shouldFallback === true) {
console.log(
"Falling back to Social index feed. Block difference is: ",
nearSocialBlockHeight - feedIndexerBlockHeight
);
State.update({ shouldFallback });
}
} else {
console.log(
"Falling back to Social index feed. No QueryApi data received."
);
State.update({ shouldFallback: true });
}
})
.catch((error) => {
console.log(
"Error while fetching QueryApi feed (falling back to index feed): ",
error
);
State.update({ shouldFallback: true });
});

return (
<>
{state.shouldFallback ? (
<Feed
index={[
{
action: "post",
key: "main",
options: {
limit: 10,
order: "desc",
accountId: filteredAccountIds,
},
cacheOptions: {
ignoreCache: true,
},
},
]}
Item={(item) => (
<Widget
src="${REPL_NEAR}/widget/v1.Posts.Post"
loading={<div className="w-100" style={{ height: "200px" }} />}
props={{
accountId: item.accountId,
blockHeight: item.blockHeight,
}}
/>
)}
/>
) : (
<Widget
src={`${REPL_DEVHUB}/widget/devhub.components.organism.Feed.NearQueryApi`}
props={{
GRAPHQL_ENDPOINT,
showFlagAccountFeature: true,
filteredAccountIds: filteredAccountIds,
}}
/>
)}
</>
);
Loading
Loading