Skip to content

Commit 4de5637

Browse files
committed
refactor: fire phase 2 request immediately after phaes 1 is finished
1 parent 571ec28 commit 4de5637

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

app/pages/package/[[org]]/[name]/versions.vue

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ function getVersionTime(version: string): string | undefined {
8282
// ─── Version groups ───────────────────────────────────────────────────────────
8383
8484
const expandedGroups = ref(new Set<string>())
85-
const loadingGroup = ref<string | null>(null)
8685
8786
const versionGroups = computed(() => {
8887
const byKey = new Map<string, string[]>()
@@ -101,21 +100,23 @@ const versionGroups = computed(() => {
101100
}))
102101
})
103102
104-
async function toggleGroup(groupKey: string) {
103+
function toggleGroup(groupKey: string) {
105104
if (expandedGroups.value.has(groupKey)) {
106105
expandedGroups.value.delete(groupKey)
107-
return
106+
} else {
107+
expandedGroups.value.add(groupKey)
108108
}
109-
expandedGroups.value.add(groupKey)
110-
if (!fullVersionMap.value) {
111-
loadingGroup.value = groupKey
112-
try {
109+
}
110+
111+
watch(
112+
versionSummary,
113+
async summary => {
114+
if (summary) {
113115
await ensureFullDataLoaded()
114-
} finally {
115-
loadingGroup.value = null
116116
}
117-
}
118-
}
117+
},
118+
{ immediate: true },
119+
)
119120
120121
// ─── Version filter ───────────────────────────────────────────────────────────
121122
@@ -383,13 +384,7 @@ const flatItems = computed<FlatItem[]>(() => {
383384
<span class="w-4 h-4 flex items-center justify-center text-fg-subtle shrink-0">
384385
<Transition name="icon-swap" mode="out-in">
385386
<span
386-
v-if="loadingGroup === item.groupKey"
387-
key="loading"
388-
class="i-svg-spinners:ring-resize w-3 h-3"
389-
aria-hidden="true"
390-
/>
391-
<span
392-
v-else-if="isFilterActive"
387+
v-if="isFilterActive"
393388
key="search"
394389
class="i-lucide:funnel w-3 h-3"
395390
aria-hidden="true"
@@ -561,5 +556,4 @@ const flatItems = computed<FlatItem[]>(() => {
561556
opacity: 0;
562557
transform: scale(0.5);
563558
}
564-
565559
</style>

0 commit comments

Comments
 (0)