From 52ea82af526e4c4cfcf5c74fb5090812018641ed Mon Sep 17 00:00:00 2001 From: Megha-Dev-19 <100185149+Megha-Dev-19@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:56:50 +0530 Subject: [PATCH] Fix tag action (#537) * fix tag action * remove old code * update search tag --- src/devhub/entity/post/List.jsx | 15 +++++++++++---- src/devhub/entity/post/Post.jsx | 7 ++++++- src/devhub/feature/post-search/panel.jsx | 1 + 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/src/devhub/entity/post/List.jsx b/src/devhub/entity/post/List.jsx index 04007c4ed..cece362dd 100644 --- a/src/devhub/entity/post/List.jsx +++ b/src/devhub/entity/post/List.jsx @@ -61,14 +61,13 @@ function updateSearchCondition() { }); } -function getPostIds() { +function getPostIds(tag) { if (searchConditionChanged()) { updateSearchCondition(); - return; } let where = {}; let authorId = props.author; - let label = props.tag; + let label = tag || props.tag; if (authorId) { where = { author_id: { _eq: authorId }, ...where }; } @@ -141,7 +140,9 @@ State.init({ period: "week", }); -getPostIds(); +if (!state.items || searchConditionChanged()) { + getPostIds(); +} function defaultRenderItem(postId, additionalProps) { if (!additionalProps) { @@ -162,6 +163,12 @@ function defaultRenderItem(postId, additionalProps) { onDraftStateChange, ...additionalProps, referral: postId, + updateTagInParent: (tag) => { + if (typeof props.updateTagInput === "function") { + props.updateTagInput(tag); + } + getPostIds(tag); + }, }} /> diff --git a/src/devhub/entity/post/Post.jsx b/src/devhub/entity/post/Post.jsx index 2b42d6d7c..1f988fd29 100644 --- a/src/devhub/entity/post/Post.jsx +++ b/src/devhub/entity/post/Post.jsx @@ -646,11 +646,16 @@ const tags = post.snapshot.labels ? (
{ + if (typeof props.updateTagInParent === "function") { + props.updateTagInParent(tag); + } + }} className="d-flex gap-3 align-items-center" style={{ cursor: "pointer", textDecoration: "none" }} > diff --git a/src/devhub/feature/post-search/panel.jsx b/src/devhub/feature/post-search/panel.jsx index 40faf428e..f6e6da59a 100644 --- a/src/devhub/feature/post-search/panel.jsx +++ b/src/devhub/feature/post-search/panel.jsx @@ -147,6 +147,7 @@ return ( term: state.term, recency: props.recency, transactionHashes: props.transactionHashes, + updateTagInput: (tag) => State.update({ tag }), }} />