feat(desktop): unified diff toggle
This commit is contained in:
parent
ebf5ad25c5
commit
2ec6a21cc0
9 changed files with 91 additions and 31 deletions
|
|
@ -1,10 +1,20 @@
|
|||
import type { WorkerPoolManager } from "@pierre/diffs/worker"
|
||||
import { createSimpleContext } from "./helper"
|
||||
|
||||
const ctx = createSimpleContext<WorkerPoolManager | undefined, { pool: WorkerPoolManager | undefined }>({
|
||||
export type WorkerPools = {
|
||||
unified: WorkerPoolManager | undefined
|
||||
split: WorkerPoolManager | undefined
|
||||
}
|
||||
|
||||
const ctx = createSimpleContext<WorkerPools, { pools: WorkerPools }>({
|
||||
name: "WorkerPool",
|
||||
init: (props) => props.pool,
|
||||
init: (props) => props.pools,
|
||||
})
|
||||
|
||||
export const WorkerPoolProvider = ctx.provider
|
||||
export const useWorkerPool = ctx.use
|
||||
|
||||
export function useWorkerPool(diffStyle: "unified" | "split" | undefined) {
|
||||
const pools = ctx.use()
|
||||
if (diffStyle === "split") return pools.split
|
||||
return pools.unified
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue