Skip to content

Commit

Permalink
Fix tab mixup bug
Browse files Browse the repository at this point in the history
  • Loading branch information
1whatleytay committed Nov 18, 2024
1 parent 0e8dffa commit efe0689
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 29 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build-tauri.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src-tauri/src/access_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -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();
}
}
_ => {}
Expand Down
1 change: 0 additions & 1 deletion src/utils/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ export class Editor {

this.redoOperations = []

console.log('try again')
this.onDirty(line, count, this.data.slice(line, line + insert))
}

Expand Down
42 changes: 24 additions & 18 deletions src/utils/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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') {
Expand Down
2 changes: 1 addition & 1 deletion src/utils/tabs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit efe0689

Please sign in to comment.