Skip to content

Commit 3f3346d

Browse files
authored
feat: improves loader random order of boxes (#3416)
1 parent ef6e056 commit 3f3346d

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

assets/components/LogViewer/EventSource.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<InfiniteLoader :onLoadMore="fetchMore" :enabled="!loadingMore && messages.length > 10" />
33
<ul class="flex animate-pulse flex-col gap-4 p-4" v-if="loading || (noLogs && waitingForMoreLog)">
4-
<div class="flex flex-row gap-2" v-for="size in shuffle(['w-3/5', 'w-2/3', 'w-9/12', 'w-1/2', 'w-1/3', 'w-3/4'])">
4+
<div class="flex flex-row gap-2" v-for="size in sizes">
55
<div class="h-3 w-40 shrink-0 rounded-full bg-base-content/50 opacity-50"></div>
66
<div class="h-3 rounded-full bg-base-content/50 opacity-50" :class="size"></div>
77
</div>
@@ -20,7 +20,7 @@ const { entity, streamSource } = $defineProps<{
2020
entity: T;
2121
}>();
2222
23-
const { messages, loadOlderLogs, isLoadingMore, opened, loading, error } = streamSource($$(entity));
23+
const { messages, loadOlderLogs, isLoadingMore, opened, loading, error, eventSourceURL } = streamSource($$(entity));
2424
const { loadingMore } = useLoggingContext();
2525
const color = computed(() => {
2626
if (error.value) return "error";
@@ -48,4 +48,8 @@ const fetchMore = async () => {
4848
const shuffle = (items: any[]) => {
4949
return items.sort(() => Math.random() - 0.5);
5050
};
51+
52+
const sizes = computedWithControl(eventSourceURL, () =>
53+
shuffle(["w-3/5", "w-2/3", "w-9/12", "w-1/2", "w-1/3", "w-3/4"]),
54+
);
5155
</script>

assets/composable/eventStreams.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,14 @@ function useLogStream(url: Ref<string>, loadMoreUrl?: Ref<string>) {
218218
}
219219
});
220220

221-
return { messages, loadOlderLogs, isLoadingMore, hasComplexLogs, opened, error, loading };
221+
return {
222+
messages,
223+
loadOlderLogs,
224+
isLoadingMore,
225+
hasComplexLogs,
226+
opened,
227+
error,
228+
loading,
229+
eventSourceURL: urlWithParams,
230+
};
222231
}

0 commit comments

Comments
 (0)