mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 15:47:08 +00:00
Add spyglass context and file watcher
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import type { ComponentChildren } from 'preact'
|
||||
import { getCurrentUrl } from 'preact-router'
|
||||
import { useEffect, useMemo, useState } from 'preact/hooks'
|
||||
import { Store } from '../Store.js'
|
||||
import { getGenerator } from '../Utils.js'
|
||||
import { useSpyglass } from '../contexts/Spyglass.jsx'
|
||||
import { useVersion } from '../contexts/Version.jsx'
|
||||
import { latestVersion } from '../services/DataFetcher.js'
|
||||
import { getGenerator } from '../Utils.js'
|
||||
import { Octicon } from './index.js'
|
||||
|
||||
type ErrorPanelProps = {
|
||||
@@ -17,11 +17,12 @@ type ErrorPanelProps = {
|
||||
}
|
||||
export function ErrorPanel({ error, prefix, reportable, onDismiss, body: body_, children }: ErrorPanelProps) {
|
||||
const { version } = useVersion()
|
||||
const { spyglass } = useSpyglass()
|
||||
const [stackVisible, setStackVisible] = useState(false)
|
||||
const [stack, setStack] = useState<string | undefined>(undefined)
|
||||
|
||||
const gen = getGenerator(getCurrentUrl())
|
||||
const source = gen ? Store.getBackup(gen.id) : undefined
|
||||
const source = gen ? spyglass?.getFile(spyglass.getUnsavedFileUri(gen)).doc?.getText() : undefined
|
||||
const name = (prefix ?? '') + (error instanceof Error ? error.message : error)
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
Reference in New Issue
Block a user