diff --git a/src/devhub/entity/post/PostEditor.jsx b/src/devhub/entity/post/PostEditor.jsx index b2de4e2e5..2ca5ebd68 100644 --- a/src/devhub/entity/post/PostEditor.jsx +++ b/src/devhub/entity/post/PostEditor.jsx @@ -263,6 +263,7 @@ const onSubmit = () => { }); } Near.call(txn); + } }; @@ -581,141 +582,159 @@ function generateDescription(text, amount, token, supervisor, seekingFunding) { } const [tab, setTab] = useState("editor"); +const [numPosts, setNumPosts] = useState(null); +const [numPostsChanged, setNumPostsChanged] = useState(false); +useEffect(() => { + const all_post_ids = Near.view("${REPL_DEVHUB_CONTRACT}", 'get_all_post_ids'); + if (all_post_ids) { + console.log(numPosts, all_post_ids.length); + if (numPosts !=null && numPosts != all_post_ids.length) { + console.log('numPosts changed'); + setNumPostsChanged(true); + } + setNumPosts(all_post_ids.length); + } +}); const renamedPostType = postType == "Submission" ? "Solution" : postType; // Below there is a weird code with fields.includes("githubLink") ternary operator. // This is to hack around rendering bug of near.social. -return ( -
-
-
- -
- {tab === "editor" && ( -
- {mode} {renamedPostType} +if (!numPostsChanged) { + return ( +
+
+ num Posts: {numPosts}. New posts added: {numPostsChanged} +
+
- )} - {tab === "preview" &&
Post Preview
} -
- - {tab === "editor" && ( -
- {state.warning && ( - - )} - {/* This statement around the githubLinkDiv creates a weird render bug - where the title renders extra on state change. */} - {fields.includes("githubLink") ? ( -
- {fields.includes("githubLink") && githubLinkDiv} - {labelEditor} - {fields.includes("name") && nameDiv} - {fields.includes("description") && callDescriptionDiv()} -
- ) : ( -
- {labelEditor} - {fields.includes("name") && nameDiv} - {fields.includes("amount") && amountDiv} - {fields.includes("sponsorship_token") && tokenDiv} - {fields.includes("supervisor") && supervisorDiv} - {fields.includes("description") && callDescriptionDiv()} - {fields.includes("fund_raising") && isFundraisingDiv} - {state.seekingFunding && - fields.includes("fund_raising") && - fundraisingDiv} + {tab === "editor" && ( +
+ {mode} {renamedPostType}
)} - - - {disclaimer} + {tab === "preview" &&
Post Preview
}
- )} - {tab === "preview" && ( -
- + {state.warning && ( + + )} + {/* This statement around the githubLinkDiv creates a weird render bug + where the title renders extra on state change. */} + {fields.includes("githubLink") ? ( +
+ {fields.includes("githubLink") && githubLinkDiv} + {labelEditor} + {fields.includes("name") && nameDiv} + {fields.includes("description") && callDescriptionDiv()} +
+ ) : ( +
+ {labelEditor} + {fields.includes("name") && nameDiv} + {fields.includes("amount") && amountDiv} + {fields.includes("sponsorship_token") && tokenDiv} + {fields.includes("supervisor") && supervisorDiv} + {fields.includes("description") && callDescriptionDiv()} + {fields.includes("fund_raising") && isFundraisingDiv} + {state.seekingFunding && + fields.includes("fund_raising") && + fundraisingDiv} +
+ )} + + + {disclaimer} +
+ )} + {tab === "preview" && ( +
+ -
- )} -
-); + }} + /> +
+ )} +
+ ); +} else { + return <>; +} \ No newline at end of file