feat(desktop): unified diff toggle

This commit is contained in:
Adam
2025-12-31 09:23:24 -06:00
parent ebf5ad25c5
commit 2ec6a21cc0
9 changed files with 91 additions and 31 deletions

View File

@@ -1,7 +1,7 @@
import { FileDiff } from "@pierre/diffs"
import { createEffect, createMemo, onCleanup, splitProps } from "solid-js"
import { createDefaultOptions, type DiffProps, styleVariables } from "../pierre"
import { workerPool } from "../pierre/worker"
import { getWorkerPool } from "../pierre/worker"
// interface ThreadMetadata {
// threadId: string
@@ -20,26 +20,23 @@ export function Diff<T>(props: DiffProps<T>) {
...createDefaultOptions(props.diffStyle),
...others,
},
workerPool,
getWorkerPool(props.diffStyle),
),
)
const cleanupFunctions: Array<() => void> = []
createEffect(() => {
const diff = fileDiff()
container.innerHTML = ""
fileDiff().render({
diff.render({
oldFile: local.before,
newFile: local.after,
lineAnnotations: local.annotations,
containerWrapper: container,
})
})
onCleanup(() => {
// Clean up FileDiff event handlers and dispose SolidJS components
fileDiff()?.cleanUp()
cleanupFunctions.forEach((dispose) => dispose())
onCleanup(() => {
diff.cleanUp()
})
})
return <div data-component="diff" style={styleVariables} ref={container} />