mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
first attempt
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
"use client"
|
"use client"
|
||||||
|
|
||||||
import React, { useEffect, ReactNode } from "react"
|
import React, { useEffect, ReactNode } from "react"
|
||||||
|
import { watch, watchImmediate } from "tauri-plugin-fs-watch-api"
|
||||||
|
|
||||||
interface DeepLinkProviderProps {
|
interface DeepLinkProviderProps {
|
||||||
children: ReactNode
|
children: ReactNode
|
||||||
@@ -19,15 +20,52 @@ export function DeepLinkProvider({ children }: DeepLinkProviderProps) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// just a react thing
|
// Add event listeners
|
||||||
Object.entries(eventHandlers).forEach(([eventType, handler]) => {
|
Object.entries(eventHandlers).forEach(([eventType, handler]) => {
|
||||||
window.addEventListener(eventType, handler)
|
window.addEventListener(eventType, handler)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Set up file watching
|
||||||
|
let stopWatching: (() => void) | undefined
|
||||||
|
let stopRawWatcher: (() => void) | undefined
|
||||||
|
|
||||||
|
const setupFileWatchers = async () => {
|
||||||
|
try {
|
||||||
|
stopWatching = await watch(
|
||||||
|
// TODO: should not hard code this, should get it from jazz
|
||||||
|
"~/src/org/learn-anything/learn-anything.xyz/private/vaults/nikiv",
|
||||||
|
event => {
|
||||||
|
const { kind, path } = event
|
||||||
|
console.log("File watch event:", { kind, path })
|
||||||
|
},
|
||||||
|
{ recursive: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
stopRawWatcher = await watchImmediate(
|
||||||
|
["/path/a", "/path/b"],
|
||||||
|
event => {
|
||||||
|
const { type, paths, attrs } = event
|
||||||
|
console.log("Raw file watch event:", { type, paths, attrs })
|
||||||
|
},
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error setting up file watchers:", error)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setupFileWatchers()
|
||||||
|
|
||||||
|
// Cleanup function
|
||||||
return () => {
|
return () => {
|
||||||
|
// Remove event listeners
|
||||||
Object.entries(eventHandlers).forEach(([eventType, handler]) => {
|
Object.entries(eventHandlers).forEach(([eventType, handler]) => {
|
||||||
window.removeEventListener(eventType, handler)
|
window.removeEventListener(eventType, handler)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Stop file watchers
|
||||||
|
if (stopWatching) stopWatching()
|
||||||
|
if (stopRawWatcher) stopRawWatcher()
|
||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"@radix-ui/react-toggle": "^1.1.0",
|
"@radix-ui/react-toggle": "^1.1.0",
|
||||||
"@radix-ui/react-tooltip": "^1.1.2",
|
"@radix-ui/react-tooltip": "^1.1.2",
|
||||||
"@tanstack/react-virtual": "^3.10.7",
|
"@tanstack/react-virtual": "^3.10.7",
|
||||||
|
"@tauri-apps/plugin-fs-watch": "https://github.com/tauri-apps/tauri-plugin-fs-watch#v2",
|
||||||
"@tiptap/core": "^2.6.6",
|
"@tiptap/core": "^2.6.6",
|
||||||
"@tiptap/extension-blockquote": "^2.6.6",
|
"@tiptap/extension-blockquote": "^2.6.6",
|
||||||
"@tiptap/extension-bold": "^2.6.6",
|
"@tiptap/extension-bold": "^2.6.6",
|
||||||
@@ -88,6 +89,7 @@
|
|||||||
"streaming-markdown": "^0.0.14",
|
"streaming-markdown": "^0.0.14",
|
||||||
"tailwind-merge": "^2.5.2",
|
"tailwind-merge": "^2.5.2",
|
||||||
"tailwindcss-animate": "^1.0.7",
|
"tailwindcss-animate": "^1.0.7",
|
||||||
|
"tauri-plugin-fs-watch-api": "https://github.com/tauri-apps/tauri-plugin-fs-watch#v1",
|
||||||
"ts-node": "^10.9.2",
|
"ts-node": "^10.9.2",
|
||||||
"zod": "^3.23.8",
|
"zod": "^3.23.8",
|
||||||
"zsa": "^0.6.0"
|
"zsa": "^0.6.0"
|
||||||
|
|||||||
Reference in New Issue
Block a user