From 9329d796958ca6c6a3beeaf7270eb7bcffe31b3f Mon Sep 17 00:00:00 2001 From: Matt Gabrenya Date: Thu, 31 Aug 2023 15:49:12 -0700 Subject: [PATCH] fix: use count_links for followers count --- .../follows/src/follower_to_creators.rs | 28 +++++++++++ ui/src/components/BaseAgentProfileDetail.vue | 2 + ui/src/pages/AgentProfile.vue | 49 +++++++++++++++++-- 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/dnas/mewsfeed/zomes/coordinator/follows/src/follower_to_creators.rs b/dnas/mewsfeed/zomes/coordinator/follows/src/follower_to_creators.rs index 54af1af9..b777ced1 100644 --- a/dnas/mewsfeed/zomes/coordinator/follows/src/follower_to_creators.rs +++ b/dnas/mewsfeed/zomes/coordinator/follows/src/follower_to_creators.rs @@ -52,6 +52,34 @@ pub fn get_followers_for_creator( Ok(agents) } +#[hdk_extern] +pub fn count_creators_for_follower( + follower: AgentPubKey, +) -> ExternResult { + let query = LinkQuery::new( + follower, + LinkTypeFilter::single_type( + ZomeIndex(2), + LinkType(0), // LinkTypes::FollowerToCreators + ), + ); + count_links(query) +} + +#[hdk_extern] +pub fn count_followers_for_creator( + creator: AgentPubKey, +) -> ExternResult { + let query = LinkQuery::new( + creator, + LinkTypeFilter::single_type( + ZomeIndex(2), + LinkType(1), // LinkTypes::CreatorToFollowers + ), + ); + count_links(query) +} + #[hdk_extern] pub fn get_follower_links_for_creator( input: GetFollowersForCreatorInput, diff --git a/ui/src/components/BaseAgentProfileDetail.vue b/ui/src/components/BaseAgentProfileDetail.vue index 1545340a..7f9d1d5c 100644 --- a/ui/src/components/BaseAgentProfileDetail.vue +++ b/ui/src/components/BaseAgentProfileDetail.vue @@ -95,6 +95,7 @@ v-if="!isMyProfile" :agentPubKey="agentPubKey" :big="bigFollowButton" + @toggle-follow="(val) => emit('toggle-follow', val)" />