Skip to content

Commit af81873

Browse files
committed
Fix tray Quit and duplicate tray icon; drop idle polling and unused deps
1 parent 5b6d71d commit af81873

8 files changed

Lines changed: 77 additions & 2491 deletions

File tree

package-lock.json

Lines changed: 48 additions & 2271 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,9 @@
1515
"@tauri-apps/plugin-opener": "^2",
1616
"@tauri-apps/plugin-process": "^2.3.1",
1717
"@tauri-apps/plugin-updater": "^2.10.0",
18-
"@uiw/react-md-editor": "^4.0.11",
1918
"framer-motion": "^12.34.0",
2019
"react": "^19.1.0",
2120
"react-dom": "^19.1.0",
22-
"react-markdown": "^10.1.0",
23-
"rehype-raw": "^7.0.0",
2421
"zustand": "^5.0.11"
2522
},
2623
"devDependencies": {

src-tauri/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,14 @@ pub fn run() {
104104
.build(tauri::generate_context!())
105105
.expect("error while running tauri application")
106106
.run(|_app_handle, event| {
107-
if let tauri::RunEvent::ExitRequested { api, .. } = event {
108-
// Prevent the app from exiting when all windows are closed.
109-
// The app stays alive in the system tray so global shortcuts still work.
110-
api.prevent_exit();
107+
if let tauri::RunEvent::ExitRequested { code, api, .. } = event {
108+
// Keep the app alive in the tray ONLY when it's the windows closing
109+
// (code == None) — so global shortcuts keep working. An explicit Quit
110+
// from the tray calls `app.exit(0)`, which sets code == Some(0); in that
111+
// case we must let the app actually exit.
112+
if code.is_none() {
113+
api.prevent_exit();
114+
}
111115
}
112116
});
113117
}

src-tauri/tauri.conf.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,6 @@
1414
"macOSPrivateApi": true,
1515
"security": {
1616
"csp": null
17-
},
18-
"trayIcon": {
19-
"iconPath": "icons/icon.png",
20-
"iconAsTemplate": true,
21-
"id": "main-tray"
2217
}
2318
},
2419
"bundle": {

src/components/HighlighterPicker.tsx

Lines changed: 0 additions & 41 deletions
This file was deleted.

src/components/MarkdownRenderer.tsx

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/components/NoteWindow.tsx

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,34 @@ export function NoteWindow({ noteId }: NoteWindowProps) {
4747
loadNote(noteId);
4848
}, [noteId, loadNote]);
4949

50+
// Only poll for external (Obsidian) edits when a vault is actually connected.
51+
// When it isn't (the common case) nothing external changes the note, so we skip
52+
// the per-window polling entirely to save CPU/battery.
53+
const [syncing, setSyncing] = useState(false);
54+
useEffect(() => {
55+
let active = true;
56+
const check = () =>
57+
invoke<string | null>('get_sync_status')
58+
.then((v) => active && setSyncing(!!v))
59+
.catch(() => {});
60+
check();
61+
const id = setInterval(check, 20000); // re-check vault status occasionally (cheap)
62+
return () => {
63+
active = false;
64+
clearInterval(id);
65+
};
66+
}, []);
67+
5068
// Pick up edits made to this note inside Obsidian. Only refresh while the user is
5169
// NOT typing in this note's editor, so we never clobber in-progress input.
5270
useEffect(() => {
71+
if (!syncing) return;
5372
const interval = setInterval(() => {
5473
const editingHere = document.activeElement?.classList.contains('note-editable');
5574
if (!editingHere) pullExternal();
56-
}, 2500);
75+
}, 3000);
5776
return () => clearInterval(interval);
58-
}, [pullExternal]);
77+
}, [syncing, pullExternal]);
5978

6079
useEffect(() => {
6180
const handleClickOutside = () => {

src/components/SpiralBinding.tsx

Lines changed: 0 additions & 100 deletions
This file was deleted.

0 commit comments

Comments
 (0)