···
CompatibleOperationOrTombstone,
} from "@atcute/did-plc";
7
-
import { createResource, createSignal, For, Show } from "solid-js";
8
+
import { createEffect, createResource, createSignal, For, Show } from "solid-js";
import { localDateFromTimestamp } from "../utils/date.js";
import { createOperationHistory, DiffEntry, groupBy } from "../utils/plc-logs.js";
···
export const PlcLogView = (props: { did: string }) => {
const [activePlcEvent, setActivePlcEvent] = createSignal<PlcEvent | undefined>();
16
+
const [validLog, setValidLog] = createSignal<boolean | undefined>(undefined);
17
+
const [rawLogs, setRawLogs] = createSignal<IndexedEntryLog | undefined>(undefined);
const shouldShowDiff = (diff: DiffEntry) =>
!activePlcEvent() || diff.type.startsWith(activePlcEvent()!);
···
const json = await res.json();
const logs = defs.indexedEntryLog.parse(json);
32
+
const opHistory = createOperationHistory(logs).reverse();
33
+
return Array.from(groupBy(opHistory, (item) => item.orig));
36
+
const validateLog = async (logs: IndexedEntryLog) => {
await processIndexedEntryLog(props.did as any, logs);
33
-
const opHistory = createOperationHistory(logs).reverse();
34
-
return Array.from(groupBy(opHistory, (item) => item.orig));
createResource<[IndexedEntry<CompatibleOperationOrTombstone>, DiffEntry[]][]>(fetchPlcLogs);
49
+
createEffect(() => {
50
+
const logs = rawLogs();
52
+
setValidLog(undefined);
53
+
// Defer validation to next tick to avoid blocking rendering
54
+
setTimeout(() => validateLog(logs), 0);
const FilterButton = (props: { icon: string; event: PlcEvent; label: string }) => {
const isActive = () => activePlcEvent() === props.event;
···
234
-
<div class="flex w-full flex-col gap-4 wrap-anywhere">
252
+
<div class="flex w-full flex-col gap-3 wrap-anywhere">
<div class="flex flex-col gap-2">
<div class="flex items-center gap-1.5 text-sm">
<div class="iconify lucide--filter" />
···
273
+
<div class="flex items-center gap-1.5 text-sm font-medium">
274
+
<Show when={validLog() === true}>
275
+
<span class="iconify lucide--check-circle-2 text-green-500 dark:text-green-400"></span>
276
+
<span>Valid log</span>
278
+
<Show when={validLog() === false}>
279
+
<span class="iconify lucide--x-circle text-red-500 dark:text-red-400"></span>
280
+
<span>Log validation failed</span>
282
+
<Show when={validLog() === undefined}>
283
+
<span class="iconify lucide--loader-circle animate-spin"></span>
284
+
<span>Validating log...</span>
<div class="flex flex-col gap-3">