Skip to content

Commit 0ee6db1

Browse files
committed
[refactor](watch) refactor file watching module
1 parent a27d4d5 commit 0ee6db1

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

apps/picsharp-app/src-tauri/src/command.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ pub async fn ipc_open_system_preference_notifications() -> Response {
137137
}
138138

139139
// If all commands fail, try to open generic settings
140-
let fallback_commands = vec![
140+
let fallback_commands: Vec<(&_, Vec<_>)> = vec![
141141
("gnome-control-center", vec![]),
142142
("systemsettings5", vec![]),
143143
("xfce4-settings-manager", vec![]),

apps/picsharp-app/src/pages/compression/watch.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,22 @@ function CompressionWatch() {
218218
eventSource.addEventListener('self-enoent', async () => {
219219
console.log('[Sidecar] Watch EventSource self-enoent');
220220
eventSource?.close();
221-
await alert(t('tips.file_watch_target_changed'));
222221
regain();
222+
alert(t('tips.file_watch_target_changed'));
223+
});
224+
eventSource.addEventListener('fault', async (event) => {
225+
console.log('[Sidecar] Watch EventSource fault', event);
223226
});
224227
eventSource.addEventListener('error', async (event) => {
225228
console.log('[Sidecar] Watch EventSource error', event);
226229
await sleep(1000);
230+
regain();
227231
if (isFirstInit.current) {
228232
isFirstInit.current = false;
229233
messageApi?.error(t('tips.file_watch_not_running'));
230234
} else {
231-
await alert(t('tips.file_watch_abort'));
235+
alert(t('tips.file_watch_abort'));
232236
}
233-
regain();
234237
});
235238
}
236239
if (!watchingFolder) {

0 commit comments

Comments
 (0)