remove fs watch v1 incorrect api use

This commit is contained in:
Nikita
2024-09-05 11:56:44 +03:00
parent 217f4f15e3
commit 60ac19651a
3 changed files with 139 additions and 143 deletions
+5 -5
View File
@@ -1,7 +1,7 @@
"use client" "use client"
import { useAccount } from "@/lib/providers/jazz-provider" import { useAccount } from "@/lib/providers/jazz-provider"
import { open } from "@tauri-apps/plugin-dialog" // import { open } from "@tauri-apps/plugin-dialog"
export default function TauriRoute() { export default function TauriRoute() {
const { me } = useAccount({ const { me } = useAccount({
@@ -12,7 +12,7 @@ export default function TauriRoute() {
// TODO: ugly code, just to get folder connecting working // TODO: ugly code, just to get folder connecting working
return ( return (
<div className="mb-5 flex flex-col"> <div className="mb-5 flex flex-col">
{me?.root?.connectedFolderPath && ( {/* {me?.root?.connectedFolderPath && (
<div className="flex flex-col gap-4"> <div className="flex flex-col gap-4">
<div>Connected folder: {me.root.connectedFolderPath}</div> <div>Connected folder: {me.root.connectedFolderPath}</div>
<button <button
@@ -39,8 +39,8 @@ export default function TauriRoute() {
Disconnect folder Disconnect folder
</button> </button>
</div> </div>
)} )} */}
{!me?.root?.connectedFolderPath && ( {/* {!me?.root?.connectedFolderPath && (
<button <button
onClick={async () => { onClick={async () => {
const folderPath = await open({ const folderPath = await open({
@@ -55,7 +55,7 @@ export default function TauriRoute() {
> >
Connect folder Connect folder
</button> </button>
)} )} */}
{/* TODO: loads a lot more data than expected */} {/* TODO: loads a lot more data than expected */}
{/* {JSON.stringify(me?.root?.personalPages)} */} {/* {JSON.stringify(me?.root?.personalPages)} */}
</div> </div>
+24 -26
View File
@@ -1,7 +1,6 @@
"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
@@ -29,32 +28,31 @@ export function DeepLinkProvider({ children }: DeepLinkProviderProps) {
let stopWatching: (() => void) | undefined let stopWatching: (() => void) | undefined
let stopRawWatcher: (() => void) | undefined let stopRawWatcher: (() => void) | undefined
const setupFileWatchers = async () => { // const setupFileWatchers = async () => {
try { // try {
stopWatching = await watch( // stopWatching = await watch(
// TODO: should not hard code this, should get it from jazz // // TODO: should not hard code this, should get it from jazz
"~/src/org/learn-anything/learn-anything.xyz/private/vaults/nikiv", // "~/src/org/learn-anything/learn-anything.xyz/private/vaults/nikiv",
event => { // event => {
const { kind, path } = event // const { kind, path } = event
console.log("File watch event:", { kind, path }) // console.log("File watch event:", { kind, path })
}, // },
{ recursive: true } // { recursive: true }
) // )
stopRawWatcher = await watchImmediate( // stopRawWatcher = await watchImmediate(
["/path/a", "/path/b"], // ["/path/a", "/path/b"],
event => { // event => {
const { type, paths, attrs } = event // const { type, paths, attrs } = event
console.log("Raw file watch event:", { type, paths, attrs }) // console.log("Raw file watch event:", { type, paths, attrs })
}, // },
{} // {}
) // )
} catch (error) { // } catch (error) {
console.error("Error setting up file watchers:", error) // console.error("Error setting up file watchers:", error)
} // }
} // }
// setupFileWatchers()
setupFileWatchers()
// Cleanup function // Cleanup function
return () => { return () => {
-2
View File
@@ -33,7 +33,6 @@
"@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",
@@ -89,7 +88,6 @@
"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"