From efe0689646745df1c090080f86a62357a82cd0b8 Mon Sep 17 00:00:00 2001 From: Taylor Whatley <32211852+1whatleytay@users.noreply.github.com> Date: Mon, 18 Nov 2024 13:06:16 -0500 Subject: [PATCH] Fix tab mixup bug --- .github/workflows/build-tauri.yml | 4 +-- src-tauri/src/access_manager.rs | 14 +++++------ src/utils/editor.ts | 1 - src/utils/events.ts | 42 ++++++++++++++++++------------- src/utils/tabs.ts | 2 +- 5 files changed, 34 insertions(+), 29 deletions(-) diff --git a/.github/workflows/build-tauri.yml b/.github/workflows/build-tauri.yml index aae840b..89b4cc5 100644 --- a/.github/workflows/build-tauri.yml +++ b/.github/workflows/build-tauri.yml @@ -33,8 +33,8 @@ jobs: APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }} APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }} with: - tagName: app-v__VERSION__ # the action automatically replaces \_\_VERSION\_\_ with the app version - releaseName: 'Saturn v__VERSION__' + tagName: app-v0.1.10d # the action automatically replaces \_\_VERSION\_\_ with the app version + releaseName: 'Saturn v0.1.10d' releaseBody: 'See attached builds.' releaseDraft: true prerelease: false diff --git a/src-tauri/src/access_manager.rs b/src-tauri/src/access_manager.rs index 6bbbda5..f772e46 100644 --- a/src-tauri/src/access_manager.rs +++ b/src-tauri/src/access_manager.rs @@ -126,16 +126,16 @@ impl AccessManager { match event.kind { notify::EventKind::Create(_) => { - // app.emit_all("save:create", path).ok(); + app.emit_all("save:create", path).ok(); } notify::EventKind::Remove(_) => { - // app.emit_all("save:remove", path).ok(); + app.emit_all("save:remove", path).ok(); } notify::EventKind::Modify(ModifyKind::Name(_)) => { if path.exists() { - // app.emit_all("save:create", path).ok(); + app.emit_all("save:create", path).ok(); } else { - // app.emit_all("save:remove", path).ok(); + app.emit_all("save:remove", path).ok(); } } notify::EventKind::Modify(ModifyKind::Data(_) | ModifyKind::Any) => { @@ -145,9 +145,9 @@ impl AccessManager { } if let Ok(data) = fs::read_to_string(path) { - // app.emit_all("save:modify", AccessModify { - // path: path.to_string_lossy().to_string(), data: Text(data) - // }).ok(); + app.emit_all("save:modify", AccessModify { + path: path.to_string_lossy().to_string(), data: Text(data) + }).ok(); } } _ => {} diff --git a/src/utils/editor.ts b/src/utils/editor.ts index 7655773..bde85d1 100644 --- a/src/utils/editor.ts +++ b/src/utils/editor.ts @@ -176,7 +176,6 @@ export class Editor { this.redoOperations = [] - console.log('try again') this.onDirty(line, count, this.data.slice(line, line + insert)) } diff --git a/src/utils/events.ts b/src/utils/events.ts index 734f827..e2994fc 100644 --- a/src/utils/events.ts +++ b/src/utils/events.ts @@ -29,7 +29,6 @@ import { } from '../state/state' import { appWindow } from '@tauri-apps/api/window' import { watch } from 'vue' -import { MidiNote, playNote } from './midi' import { splitLines } from './split-lines' import { exportBinaryContents } from './query/serialize-files' @@ -282,23 +281,30 @@ export async function setupEvents() { } }) - // await listen('save:modify', (event) => { - // const modification = event.payload as { - // path: string, - // data: any - // } - // - // if (typeof modification.data !== 'string') { - // return - // } - // - // for (const tab of tabsState.tabs) { - // if (tab.path === modification.path) { - // editor.value.replaceAll(modification.data) - // tab.marked = false - // } - // } - // }) + await listen('save:modify', (event) => { + const modification = event.payload as { + path: string, + data: any + } + + if (typeof modification.data !== 'string') { + return + } + + const current = tab() + + for (const tab of tabsState.tabs) { + if (tab.path === modification.path) { + if (current?.uuid === tab.uuid) { + editor.value.replaceAll(modification.data) + } else { + tab.lines = splitLines(modification.data) + } + + tab.marked = false + } + } + }) await appWindow.onFileDropEvent(async (event) => { if (event.payload.type === 'drop') { diff --git a/src/utils/tabs.ts b/src/utils/tabs.ts index 4c6e905..90936c5 100644 --- a/src/utils/tabs.ts +++ b/src/utils/tabs.ts @@ -199,7 +199,7 @@ export function useTabs(): TabsResult { const values = localStorage.getItem(backupNameKey) if (values) { - const list = JSON.stringify(values) + const list = JSON.parse(values) for (const item of list) { localStorage.removeItem(item)