-
Notifications
You must be signed in to change notification settings - Fork 395
Update to new card design #4065
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
Changes from all commits
fea0840
dd69b69
8e96c8c
cb35670
b9110e1
771e132
9c31fa2
ebb26ca
228b4d4
ed2c66b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -408,19 +408,30 @@ const handleGridContainerClick = (event: MouseEvent) => { | |
|
|
||
| const hasMultipleSelections = computed(() => selectedNodePacks.value.length > 1) | ||
|
|
||
| // Track the last pack ID for which we've fetched full registry data | ||
| const lastFetchedPackId = ref<string | null>(null) | ||
|
|
||
| // Whenever a single pack is selected, fetch its full info once | ||
| whenever(selectedNodePack, async () => { | ||
| // Cancel any in-flight requests from previously selected node pack | ||
| getPackById.cancel() | ||
|
|
||
| if (!selectedNodePack.value?.id) return | ||
|
|
||
| // If only a single node pack is selected, fetch full node pack info from registry | ||
| const pack = selectedNodePack.value | ||
| if (!pack?.id) return | ||
| if (hasMultipleSelections.value) return | ||
| const data = await getPackById.call(selectedNodePack.value.id) | ||
|
|
||
| if (data?.id === selectedNodePack.value?.id) { | ||
| // If selected node hasn't changed since request, merge registry & Algolia data | ||
| selectedNodePacks.value = [merge(selectedNodePack.value, data)] | ||
| // Only fetch if we haven't already for this pack | ||
| if (lastFetchedPackId.value === pack.id) return | ||
| const data = await getPackById.call(pack.id) | ||
| // If selected node hasn't changed since request, merge registry & Algolia data | ||
| if (data?.id === pack.id) { | ||
| lastFetchedPackId.value = pack.id | ||
| const mergedPack = merge({}, pack, data) | ||
| selectedNodePacks.value = [mergedPack] | ||
| // Replace pack in displayPacks so that children receive a fresh prop reference | ||
| const idx = displayPacks.value.findIndex((p) => p.id === mergedPack.id) | ||
| if (idx !== -1) { | ||
| displayPacks.value.splice(idx, 1, mergedPack) | ||
| } | ||
|
Comment on lines
+419
to
+434
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you verify using Network tab in dev tools that this caching is necessary? The getPackById should already be wrapped with useCachedRequest which handles request caching / deduplication. Although in general this doesn't really hurt to add, so not a big deal. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. apart from caching, it also prevents an infinite loop issue I had, it should be OK to ship as is, not too important There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. SGTM |
||
| } | ||
| }) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| <template> | ||
| <img | ||
| :src="isImageError ? DEFAULT_BANNER : imgSrc" | ||
| :alt="nodePack.name + ' banner'" | ||
| class="object-cover" | ||
| :style="{ width: cssWidth, height: cssHeight }" | ||
| @error="isImageError = true" | ||
| /> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed, ref } from 'vue' | ||
|
|
||
| import { components } from '@/types/comfyRegistryTypes' | ||
|
|
||
| const DEFAULT_BANNER = '/assets/images/fallback-gradient-avatar.svg' | ||
|
|
||
| const { | ||
| nodePack, | ||
| width = '100%', | ||
| height = '12rem' | ||
| } = defineProps<{ | ||
| nodePack: components['schemas']['Node'] & { banner?: string } // Temporary measure until banner is in backend | ||
| width?: string | ||
| height?: string | ||
| }>() | ||
|
|
||
| const isImageError = ref(false) | ||
| const shouldShowFallback = computed( | ||
| () => !nodePack.banner || nodePack.banner.trim() === '' || isImageError.value | ||
| ) | ||
| const imgSrc = computed(() => | ||
| shouldShowFallback.value ? DEFAULT_BANNER : nodePack.banner | ||
| ) | ||
|
|
||
| const convertToCssValue = (value: string | number) => | ||
| typeof value === 'number' ? `${value}rem` : value | ||
|
|
||
| const cssWidth = computed(() => convertToCssValue(width)) | ||
| const cssHeight = computed(() => convertToCssValue(height)) | ||
| </script> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,39 +1,29 @@ | ||
| <template> | ||
| <div | ||
| class="flex justify-between px-5 py-4 text-xs text-muted font-medium leading-3" | ||
| class="flex justify-between items-center px-4 py-2 text-xs text-muted font-medium leading-3" | ||
| > | ||
| <div class="flex items-center gap-2 cursor-pointer"> | ||
| <span v-if="publisherName" class="max-w-40 truncate"> | ||
| {{ publisherName }} | ||
| </span> | ||
| </div> | ||
| <div | ||
| v-if="nodePack.latest_version?.createdAt" | ||
| class="flex items-center gap-2 truncate" | ||
| > | ||
| {{ $t('g.updated') }} | ||
| {{ | ||
| $d(new Date(nodePack.latest_version.createdAt), { | ||
| dateStyle: 'medium' | ||
| }) | ||
| }} | ||
| <div v-if="nodePack.downloads" class="flex items-center gap-1.5"> | ||
| <i class="pi pi-download text-muted"></i> | ||
| <span>{{ formattedDownloads }}</span> | ||
| </div> | ||
| <PackInstallButton :node-packs="[nodePack]" /> | ||
| </div> | ||
| </template> | ||
|
|
||
| <script setup lang="ts"> | ||
| import { computed } from 'vue' | ||
| import { useI18n } from 'vue-i18n' | ||
|
|
||
| import PackInstallButton from '@/components/dialog/content/manager/button/PackInstallButton.vue' | ||
| import type { components } from '@/types/comfyRegistryTypes' | ||
|
|
||
| const { nodePack } = defineProps<{ | ||
| nodePack: components['schemas']['Node'] | ||
| }>() | ||
|
|
||
| const publisherName = computed(() => { | ||
| if (!nodePack) return null | ||
| const { n } = useI18n() | ||
|
|
||
| const { publisher, author } = nodePack | ||
| return publisher?.name ?? publisher?.id ?? author | ||
| }) | ||
| const formattedDownloads = computed(() => | ||
| nodePack.downloads ? n(nodePack.downloads) : '' | ||
| ) | ||
| </script> |
Uh oh!
There was an error while loading. Please reload this page.