diff --git a/src/views/logs.tsx b/src/views/logs.tsx index 46630f6..544249a 100644 --- a/src/views/logs.tsx +++ b/src/views/logs.tsx @@ -4,6 +4,7 @@ import { IndexedEntry, IndexedEntryLog, } from "@atcute/did-plc"; +import { useLocation } from "@solidjs/router"; import { createEffect, createResource, createSignal, For, onCleanup, Show } from "solid-js"; import { localDateFromTimestamp } from "../utils/date.js"; import { createOperationHistory, DiffEntry, groupBy } from "../utils/plc-logs.js"; @@ -13,6 +14,7 @@ import { plcDirectory } from "./settings.jsx"; type PlcEvent = "handle" | "rotation_key" | "service" | "verification_method"; export const PlcLogView = (props: { did: string }) => { + const location = useLocation(); const [activePlcEvent, setActivePlcEvent] = createSignal(); const [validLog, setValidLog] = createSignal(undefined); const [rawLogs, setRawLogs] = createSignal(undefined); @@ -53,6 +55,17 @@ export const PlcLogView = (props: { did: string }) => { } }); + createEffect(() => { + const hash = location.hash; + if (hash.startsWith("#logs:")) { + const createdAt = hash.slice(6); + requestAnimationFrame(() => { + const element = document.getElementById(`log-${createdAt}`); + if (element) element.scrollIntoView({ behavior: "instant", block: "start" }); + }); + } + }); + const FilterButton = (props: { event: PlcEvent; label: string }) => { const isActive = () => activePlcEvent() === props.event; const toggleFilter = () => setActivePlcEvent(isActive() ? undefined : props.event); @@ -275,20 +288,37 @@ export const PlcLogView = (props: { did: string }) => {
- {([entry, diffs]) => ( - -
- - {localDateFromTimestamp(new Date(entry.createdAt).getTime())} - -
- - {(diff) => } - + {([entry, diffs]) => { + const isHighlighted = () => location.hash === `#logs:${entry.createdAt}`; + return ( + + -
- - )} + + ); + }}
diff --git a/src/views/repo.tsx b/src/views/repo.tsx index 6e2c19f..7cfe28c 100644 --- a/src/views/repo.tsx +++ b/src/views/repo.tsx @@ -93,8 +93,7 @@ export const RepoView = () => { if (!!error() && props.tab === "identity") return true; return false; } - if (props.tab === "collections") return location.hash.startsWith("#collections"); - return location.hash === `#${props.tab}`; + return location.hash.startsWith(`#${props.tab}`); }; return ( @@ -390,7 +389,7 @@ export const RepoView = () => {
- +
Error: {err.message}
} >