-
Notifications
You must be signed in to change notification settings - Fork 22
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
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 7ff903b
replacements for testnet
elliotBraem 6857ebf
allow no communities found
elliotBraem 3d86230
attach 2N when creating a community
elliotBraem f70467f
Merge branch 'main' into develop
elliotBraem aa7091e
configures with updated function call
elliotBraem 8a0ca66
updated announcements UI (#606)
Megha-Dev-19 16a0a0c
Merge branch 'main' into develop
elliotBraem 7579358
Merge branch 'main' into develop
elliotBraem d9be9ed
Merge branch 'main' into develop
elliotBraem f1e04c3
updates feed
elliotBraem 81663fe
working feed
elliotBraem cd99e2a
show preview
elliotBraem 170ea4f
Merge branch 'main' into develop
elliotBraem 783b871
fix testnet
elliotBraem d81cfc5
Revert "initial typescript support (#468)"
elliotBraem da86a64
Move community Github and Board widgets from devgogigs to devhub (#561)
Megha-Dev-19 f8c08b8
Kanban board UI enhancement (#620)
Megha-Dev-19 c387fee
update to devhub.near
elliotBraem fc8c50e
fix posts for devgovgigs.near
elliotBraem 1bffa62
Merge branch 'main' into develop
elliotBraem f375846
Points tests to devhub.near rather than devgovgigs.near (#595)
elliotBraem f0577b9
fix feeds
elliotBraem c2ed67e
Announcements tests (#639)
Megha-Dev-19 7ef1bd2
Merge branch 'main' of https://github.com/NEAR-DevHub/neardevhub-bos …
elliotBraem 4616296
tests
elliotBraem 19c57ec
format
elliotBraem 1aad90e
working test
elliotBraem 74b46e2
format
elliotBraem 0262e77
posts legacy
elliotBraem File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}} | ||
/> | ||
)} | ||
</> | ||
); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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