Skip to content

Commit

Permalink
fix posts for devgovgigs.near
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem committed Jan 11, 2024
1 parent c387fee commit fc8c50e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 5 additions & 5 deletions src/core/adapter/devhub-contract.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,23 +105,23 @@ function getAllCommunitiesMetadata() {
}

function getAllLabels() {
return Near.view("${REPL_DEVHUB_CONTRACT}", "get_all_labels") ?? null;
return Near.view("${REPL_DEVHUB_LEGACY}", "get_all_labels") ?? null;
}

function getPost({ post_id }) {
return Near.view("${REPL_DEVHUB_CONTRACT}", "get_post", { post_id }) ?? null;
return Near.view("${REPL_DEVHUB_LEGACY}", "get_post", { post_id }) ?? null;
}

function getPostsByAuthor({ author }) {
return (
Near.view("${REPL_DEVHUB_CONTRACT}", "get_posts_by_author", { author }) ??
Near.view("${REPL_DEVHUB_LEGACY}", "get_posts_by_author", { author }) ??
null
);
}

function getPostsByLabel({ label }) {
return (
Near.view("${REPL_DEVHUB_CONTRACT}", "get_posts_by_label", {
Near.view("${REPL_DEVHUB_LEGACY}", "get_posts_by_label", {
label,
}) ?? null
);
Expand All @@ -142,7 +142,7 @@ function useQuery(name, params) {
const cacheState = useCache(
() =>
Near.asyncView(
"${REPL_DEVHUB_CONTRACT}",
"${REPL_DEVHUB_LEGACY}",
["get", name].join("_"),
params ?? {}
)
Expand Down
8 changes: 4 additions & 4 deletions src/devhub/entity/post/Post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const postId = props.post.id ?? (props.id ? parseInt(props.id) : 0);

const post =
props.post ??
Near.view("${REPL_DEVHUB_CONTRACT}", "get_post", { post_id: postId });
Near.view("${REPL_DEVHUB_LEGACY}", "get_post", { post_id: postId });

if (!post) {
return <div>Loading ...</div>;
Expand Down Expand Up @@ -60,12 +60,12 @@ const compareSnapshot =
// If this post is displayed under another post. Used to limit the size.
const isUnderPost = props.isUnderPost ? true : false;

const parentId = Near.view("${REPL_DEVHUB_CONTRACT}", "get_parent_id", {
const parentId = Near.view("${REPL_DEVHUB_LEGACY}", "get_parent_id", {
post_id: postId,
});

const childPostIdsUnordered =
Near.view("${REPL_DEVHUB_CONTRACT}", "get_children_ids", {
Near.view("${REPL_DEVHUB_LEGACY}", "get_children_ids", {
post_id: postId,
}) ?? [];

Expand Down Expand Up @@ -278,7 +278,7 @@ const onLike = () => {

let likeTxn = [
{
contractName: "${REPL_DEVHUB_CONTRACT}",
contractName: "${REPL_DEVHUB_LEGACY}",
methodName: "add_like",
args: {
post_id: postId,
Expand Down
10 changes: 5 additions & 5 deletions src/devhub/entity/post/PostEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const [postData, setPostData] = useState(null); // for capturing edit post chang

useEffect(() => {
if (mode == "Edit") {
const data = Near.view("${REPL_DEVHUB_CONTRACT}", "get_post", {
const data = Near.view("${REPL_DEVHUB_LEGACY}", "get_post", {
post_id: postId,
});
if (!postData) {
Expand All @@ -97,7 +97,7 @@ useEffect(() => {
setPostData(data);
}
} else {
const postIds = Near.view("${REPL_DEVHUB_CONTRACT}", "get_all_post_ids");
const postIds = Near.view("${REPL_DEVHUB_LEGACY}", "get_all_post_ids");
if (!postIdList) {
setPostIdList(postIds);
}
Expand Down Expand Up @@ -400,7 +400,7 @@ const setLabels = (labels) => {
oldLabels.delete(label.name);
}
let removed = oldLabels.values().next().value;
Near.asyncView("${REPL_DEVHUB_CONTRACT}", "is_allowed_to_use_labels", {
Near.asyncView("${REPL_DEVHUB_LEGACY}", "is_allowed_to_use_labels", {
editor: context.accountId,
labels: [removed],
}).then((allowed) => {
Expand All @@ -425,7 +425,7 @@ const setLabels = (labels) => {
}
};
const existingLabelStrings =
Near.view("${REPL_DEVHUB_CONTRACT}", "get_all_allowed_labels", {
Near.view("${REPL_DEVHUB_LEGACY}", "get_all_allowed_labels", {
editor: context.accountId,
}) ?? [];
const existingLabelSet = new Set(existingLabelStrings);
Expand Down Expand Up @@ -455,7 +455,7 @@ const labelEditor = (
props.text.toLowerCase() !== "blog" && // dont allow adding "Blog"
props.selected.filter((selected) => selected.name === props.text)
.length == 0 &&
Near.view("${REPL_DEVHUB_CONTRACT}", "is_allowed_to_use_labels", {
Near.view("${REPL_DEVHUB_LEGACY}", "is_allowed_to_use_labels", {
editor: context.accountId,
labels: [props.text],
})
Expand Down

0 comments on commit fc8c50e

Please sign in to comment.