Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/profile not found errors #225

Merged
merged 24 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
83d2b69
fix(ui): use console.error instead of toast for 2 passive errors
mattyg Sep 8, 2023
c4cc672
fix(ui): follow users without profile data
mattyg Sep 8, 2023
400efb9
chore(ui): remove unused callZomes from profile
mattyg Sep 8, 2023
c84c41f
fix(ui): creators and followers lists still display agents with missi…
mattyg Sep 8, 2023
23f05c1
fix(ui): split agent profile & joined timestamp fetching in AgentProf…
mattyg Sep 8, 2023
7dc2ca3
Merge branch 'main' into fix/profile-not-found-errors
mattyg Sep 9, 2023
fa75ef7
fix(ui): split agent profile & joined timestamp fetching in AgentProf…
mattyg Sep 9, 2023
841efbd
revert(ui): remove profile placeholders
mattyg Sep 9, 2023
c884d1a
build(ui): bump tanstack deps
mattyg Sep 9, 2023
17c4270
fix(ui): ensure tanstack query key is reactively updated when agentPu…
mattyg Sep 9, 2023
94f9a87
fix(ui): extract list of random mews by tag into seperate component, …
mattyg Sep 9, 2023
f8f384c
fix(ui): wrap props in computed before using in tanstack queryKey to …
mattyg Sep 9, 2023
604dc93
fix(ui): avoid console error
mattyg Sep 9, 2023
3bd701a
fix(ui): more computeds
mattyg Sep 9, 2023
d46d1fe
Merge branch 'fix/profile-not-found-errors' into fix/profile-popup-da…
mattyg Sep 9, 2023
020d64b
chore(ui): rm console log
mattyg Sep 9, 2023
3885216
fix(ui): zome call payload incorrect
mattyg Sep 9, 2023
515ae86
Merge pull request #230 from GeekGene/fix/profile-popup-data-incorrect
mattyg Sep 11, 2023
2c7f9f8
Merge branch 'main' into fix/profile-not-found-errors
mattyg Sep 11, 2023
9428059
fix(ui): refetch followers / creators lists upon opening dialog
mattyg Sep 11, 2023
1fb4345
fix(ui): spacing between <name> followed you
mattyg Sep 11, 2023
de5b1db
fix(ui): do not abbreviate agentpubkey when used as primary displayed…
mattyg Sep 11, 2023
cb534ad
chore(ui): remove unnecessary filters
mattyg Sep 11, 2023
fb5a49a
chore(ui): fix ts lint
mattyg Sep 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 27 additions & 18 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions ui/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ declare module 'vue' {
Dialogs: typeof import('./src/components/Dialogs.vue')['default']
EditAgentProfileDialog: typeof import('./src/components/EditAgentProfileDialog.vue')['default']
FollowersListDialog: typeof import('./src/components/FollowersListDialog.vue')['default']
RandomMewWithTagList: typeof import('./src/components/RandomMewWithTagList.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
SearchEverythingDialog: typeof import('./src/components/SearchEverythingDialog.vue')['default']
Expand Down
6 changes: 3 additions & 3 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"@holochain-open-dev/profiles": "^0.16.1",
"@holochain/client": "^0.15.0",
"@shoelace-style/shoelace": "^2.4.0",
"@tanstack/query-persist-client-core": "^4.33.0",
"@tanstack/query-sync-storage-persister": "^4.33.0",
"@tanstack/vue-query": "^4.34.0",
"@tanstack/query-persist-client-core": "^4.35.0",
"@tanstack/query-sync-storage-persister": "^4.35.0",
"@tanstack/vue-query": "^4.35.2",
"@tauri-apps/api": "^1.4.0",
"async-retry": "^1.3.3",
"dayjs": "^1.11.7",
Expand Down
58 changes: 34 additions & 24 deletions ui/src/components/AgentProfileDetail.vue
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
<template>
<BaseAgentProfileDetail
v-if="profileWithContext"
:profile="profileWithContext.profile"
:profile="profile"
:agentPubKey="props.agentPubKey"
:joined-timestamp="profileWithContext.joinedTimestamp"
:joined-timestamp="joinedTimestamp"
:hide-edit-button="hideEditButton"
v-bind="$attrs"
/>
</template>

<script setup lang="ts">
import { useToasts } from "@/stores/toasts";
import { AgentPubKey, AppAgentClient } from "@holochain/client";
import { ComputedRef, inject, watch } from "vue";
import { ComputedRef, computed, inject, watch } from "vue";
import { ProfilesStore } from "@holochain-open-dev/profiles";
import BaseAgentProfileDetail from "@/components/BaseAgentProfileDetail.vue";
import { useQuery } from "@tanstack/vue-query";
import { encodeHashToBase64 } from "@holochain/client";

const props = withDefaults(
defineProps<{
Expand All @@ -30,38 +29,49 @@ const props = withDefaults(
const profilesStore = (inject("profilesStore") as ComputedRef<ProfilesStore>)
.value;
const client = (inject("client") as ComputedRef<AppAgentClient>).value;
const { showError } = useToasts();
const agentPubKeyB64 = computed(() => encodeHashToBase64(props.agentPubKey));

const fetchProfileWithContext = async () => {
const fetchProfile = async () => {
const profile = await profilesStore.client.getAgentProfile(props.agentPubKey);
const joinedTimestamp = await client.callZome({
role_name: "mewsfeed",
zome_name: "profiles",
fn_name: "get_joining_timestamp_for_agent",
payload: props.agentPubKey,
});

if (profile) {
return {
profile,
joinedTimestamp,
};
return profile;
} else {
throw new Error("No profile found");
}
};

const {
data: profileWithContext,
data: profile,
error: errorProfile,
refetch,
refetch: refetchProfile,
} = useQuery({
queryKey: ["profiles", "getAgentProfile", agentPubKeyB64],
queryFn: fetchProfile,
refetchOnMount: true,
});
watch(errorProfile, console.error);

const fetchJoinedTimestamp = async () =>
client.callZome({
role_name: "mewsfeed",
zome_name: "profiles",
fn_name: "get_joining_timestamp_for_agent",
payload: props.agentPubKey,
});

const {
data: joinedTimestamp,
error: errorJoinedTimestamp,
refetch: refetchJoinedTimestamp,
} = useQuery({
queryKey: ["profiles", "getAgentProfile", props.agentPubKey],
queryFn: fetchProfileWithContext,
queryKey: ["profiles", "get_joining_timestamp_for_agent", agentPubKeyB64],
queryFn: fetchJoinedTimestamp,
refetchOnMount: true,
});
watch(errorProfile, showError);
watch(errorJoinedTimestamp, console.error);

watch(props, () => {
refetch();
refetchProfile();
refetchJoinedTimestamp();
});
</script>
1 change: 0 additions & 1 deletion ui/src/components/BaseAgentProfile.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<template>
<div class="flex justify-start items-center space-x-2">
<agent-avatar
v-if="profile"
:agentPubKey="agentPubKey"
size="20"
disable-tooltip
Expand Down
11 changes: 4 additions & 7 deletions ui/src/components/BaseAgentProfileDetail.vue
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<template>
<div
v-if="profile"
class="h-full w-full text-base-content font-content font-normal"
v-bind="$attrs"
>
<div class="flex space-x-6 h-full p-4">
<div class="flex flex-col justify-between">
<div
v-tooltip.bottom="{
disabled: !!profile.fields.avatar,
disabled: profile && !!profile.fields.avatar,
content: encodeHashToBase64(agentPubKey),
popperClass: 'text-xs',
triggers: ['hover'],
Expand Down Expand Up @@ -70,7 +69,7 @@
</div>

<div
v-if="profile.fields.avatar"
v-if="profile?.fields.avatar"
v-tooltip.bottom="{
content: encodeHashToBase64(agentPubKey),
popperClass: 'text-xs',
Expand Down Expand Up @@ -121,7 +120,7 @@
</div>

<div
v-if="profile.fields[PROFILE_FIELDS.BIO]"
v-if="profile?.fields[PROFILE_FIELDS.BIO]"
class="flex justify-start space-x-2 text-md mb-5"
>
{{ profile.fields[PROFILE_FIELDS.BIO] }}
Expand Down Expand Up @@ -168,7 +167,7 @@
class="flex justify-start items-center space-x-2 sm:space-x-16 text-xs mt-3"
>
<div
v-if="profile.fields[PROFILE_FIELDS.LOCATION]"
v-if="profile?.fields[PROFILE_FIELDS.LOCATION]"
class="flex justify-start items-center space-x-2 text-xs font-mono px-2"
>
<IconNavigateCircleOutline />
Expand All @@ -187,7 +186,6 @@
</div>
</div>
</div>
<BaseAgentProfileDetailSkeleton v-else />
</template>

<script setup lang="ts">
Expand All @@ -206,7 +204,6 @@ import IconNavigateCircleOutline from "~icons/ion/navigate-circle-outline";
import IconCalendarOutline from "~icons/ion/calendar-outline";
import IconPencilSharp from "~icons/ion/pencil-sharp";
import { Timestamp } from "@holochain/client";
import BaseAgentProfileDetailSkeleton from "@/components/BaseAgentProfileDetailSkeleton.vue";
import BaseCopyOnClick from "@/components/BaseCopyOnClick.vue";
import { useLightboxStore } from "@/stores/lightbox";

Expand Down
3 changes: 2 additions & 1 deletion ui/src/components/BaseAgentProfileList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
:is-loading="loading"
>
<BaseAgentProfileListItem
:agent-profile="item"
:agent-pub-key="item.agentPubKey"
:profile="item.profile"
:enable-popup="enablePopups"
class="cursor-pointer py-3"
@click="
Expand Down
17 changes: 10 additions & 7 deletions ui/src/components/BaseAgentProfileListItem.vue
Original file line number Diff line number Diff line change
@@ -1,30 +1,33 @@
<template>
<div class="flex justify-start items-center space-x-4">
<BaseAgentProfileLinkAvatar
:agentPubKey="agentProfile.agentPubKey"
:agentPubKey="agentPubKey"
:size="50"
:enable-popup="enablePopup"
/>
<BaseAgentProfileName
<BaseAgentProfileNameLarge
class="text-lg"
:profile="agentProfile.profile"
:agentPubKey="agentProfile.agentPubKey"
:profile="profile"
:agentPubKey="agentPubKey"
/>
</div>
</template>

<script setup lang="ts">
import { AgentProfile } from "@/types/types";
import BaseAgentProfileLinkAvatar from "@/components/BaseAgentProfileLinkAvatar.vue";
import BaseAgentProfileName from "@/components/BaseAgentProfileName.vue";
import BaseAgentProfileNameLarge from "@/components/BaseAgentProfileNameLarge.vue";
import { AgentPubKey } from "@holochain/client";
import { Profile } from "@holochain-open-dev/profiles";

withDefaults(
defineProps<{
agentProfile: AgentProfile;
agentPubKey: AgentPubKey;
profile?: Profile;
enablePopup?: boolean;
}>(),
{
enablePopup: true,
profile: undefined,
}
);
</script>
2 changes: 1 addition & 1 deletion ui/src/components/BaseAgentProfileNameLarge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div class="font-mono text-sm">@{{ profile.nickname }}</div>
</div>
<div v-else class="font-mono">
{{ encodeHashToBase64(agentPubKey).slice(0, 8) }}
{{ encodeHashToBase64(agentPubKey) }}
</div>
</div>
</template>
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/BaseNotification.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"
class="flex justify-between items-center py-2 w-full space-x-2"
>
<div class="flex justify-start items-start">
<div class="flex justify-start items-start space-x-2">
<BaseAgentProfileLinkName
:agentPubKey="notification.agent"
:profile="notification.agent_profile"
Expand Down
Loading
Loading