Skip to content

Commit

Permalink
Merge pull request #235 from GeekGene/fix/trim-agentpubkeys
Browse files Browse the repository at this point in the history
Fix/trim agentpubkeys
  • Loading branch information
mattyg authored Sep 13, 2023
2 parents 246ad1d + aa4ee0b commit 9206b0b
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 13 deletions.
3 changes: 3 additions & 0 deletions ui/src/components/BaseAgentProfileList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
:agent-pub-key="item.agentPubKey"
:profile="item.profile"
:enable-popup="enablePopups"
:trim-agent-pub-key="trimAgentPubKey"
class="cursor-pointer py-3"
@click="
router.push({
Expand Down Expand Up @@ -51,11 +52,13 @@ withDefaults(
loading: boolean;
emptyText?: string;
enablePopups?: boolean;
trimAgentPubKey?: boolean;
}>(),
{
agentProfiles: undefined,
emptyText: undefined,
enablePopups: true,
trimAgentPubKey: true,
}
);
const router = useRouter();
Expand Down
3 changes: 3 additions & 0 deletions ui/src/components/BaseAgentProfileListItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
class="text-lg"
:profile="profile"
:agentPubKey="agentPubKey"
:trim-agent-pub-key="trimAgentPubKey"
/>
</div>
</template>
Expand All @@ -24,10 +25,12 @@ withDefaults(
agentPubKey: AgentPubKey;
profile?: Profile;
enablePopup?: boolean;
trimAgentPubKey?: boolean;
}>(),
{
enablePopup: true,
profile: undefined,
trimAgentPubKey: true,
}
);
</script>
21 changes: 16 additions & 5 deletions ui/src/components/BaseAgentProfileName.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
<div class="font-mono">@{{ profile.nickname }}</div>
</div>
<div v-else class="font-mono">
{{ encodeHashToBase64(agentPubKey).slice(0, 8) }}
{{
trimAgentPubKey
? `${encodeHashToBase64(agentPubKey).slice(0, 15)}...`
: encodeHashToBase64(agentPubKey)
}}
</div>
</div>
</template>
Expand All @@ -20,10 +24,17 @@ import { Profile } from "@holochain-open-dev/profiles";
import { PROFILE_FIELDS } from "@/types/types";
import { AgentPubKey, encodeHashToBase64 } from "@holochain/client";
defineProps<{
profile?: Profile | null;
agentPubKey: AgentPubKey;
}>();
withDefaults(
defineProps<{
profile?: Profile | null;
agentPubKey: AgentPubKey;
trimAgentPubKey?: boolean;
}>(),
{
profile: null,
trimAgentPubKey: true,
}
);
</script>

<style scoped></style>
21 changes: 16 additions & 5 deletions ui/src/components/BaseAgentProfileNameLarge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
<div class="font-mono text-sm">@{{ profile.nickname }}</div>
</div>
<div v-else class="font-mono">
{{ encodeHashToBase64(agentPubKey) }}
{{
trimAgentPubKey
? `${encodeHashToBase64(agentPubKey).slice(0, 15)}...`
: encodeHashToBase64(agentPubKey)
}}
</div>
</div>
</template>
Expand All @@ -20,10 +24,17 @@ import { Profile } from "@holochain-open-dev/profiles";
import { PROFILE_FIELDS } from "@/types/types";
import { AgentPubKey, encodeHashToBase64 } from "@holochain/client";
defineProps<{
profile?: Profile | null;
agentPubKey: AgentPubKey;
}>();
withDefaults(
defineProps<{
profile?: Profile | null;
agentPubKey: AgentPubKey;
trimAgentPubKey?: boolean;
}>(),
{
profile: null,
trimAgentPubKey: true,
}
);
</script>

<style scoped></style>
1 change: 1 addition & 0 deletions ui/src/components/CreatorsListDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:agent-profiles="page"
:loading="isInitialLoading"
:enable-popups="false"
:trim-agent-pub-key="false"
/>
<hr v-if="i !== data.pages.length - 1" class="border-base-300" />
</template>
Expand Down
1 change: 1 addition & 0 deletions ui/src/components/FollowersListDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
:agent-profiles="page"
:loading="isInitialLoading"
:enable-popups="false"
:trim-agent-pub-key="false"
/>
<hr v-if="i !== data.pages.length - 1" class="border-base-300" />
</template>
Expand Down
6 changes: 3 additions & 3 deletions ui/src/pages/AgentProfile.vue
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ const fetchJoinedTimestamp = () =>
role_name: "mewsfeed",
zome_name: "profiles",
fn_name: "get_joining_timestamp_for_agent",
payload: agentPubKey.value,
payload: route.params.agentPubKey,
});
const { data: joinedTimestamp, error: errorJoinedTimestamp } = useQuery({
Expand All @@ -246,7 +246,7 @@ const fetchCreatorsCount = async (): Promise<number> =>
role_name: "mewsfeed",
zome_name: "follows",
fn_name: "count_creators_for_follower",
payload: agentPubKey.value,
payload: route.params.agentPubKey,
});
const { data: creatorsCount, error: errorCreatorsCount } = useQuery({
Expand All @@ -260,7 +260,7 @@ const fetchFollowersCount = async (): Promise<number> =>
role_name: "mewsfeed",
zome_name: "follows",
fn_name: "count_followers_for_creator",
payload: agentPubKey.value,
payload: route.params.agentPubKey,
});
const {
Expand Down

0 comments on commit 9206b0b

Please sign in to comment.