diff --git a/package-lock.json b/package-lock.json index 3b3ff4b99..e7fb7c2d8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bridge", - "version": "2.7.0", + "version": "2.7.2", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "bridge", - "version": "2.7.0", + "version": "2.7.2", "dependencies": { "@mdi/font": "^6.9.96", "@tauri-apps/api": "^1.2.0", diff --git a/package.json b/package.json index 69e7a36e4..62a2072c5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bridge", - "version": "2.7.1", + "version": "2.7.2", "private": true, "scripts": { "dev": "vite", diff --git a/src/components/Editors/Text/TextTab.ts b/src/components/Editors/Text/TextTab.ts index aa32b8609..cacdd42e7 100644 --- a/src/components/Editors/Text/TextTab.ts +++ b/src/components/Editors/Text/TextTab.ts @@ -261,10 +261,14 @@ export class TextTab extends FileTab { } protected async saveFile() { if (this.editorModel && !this.editorModel.isDisposed()) { + App.eventSystem.dispatch('beforeModifiedProject', null) + const writeWorked = await this.writeFile( this.editorModel.getValue() ) + App.eventSystem.dispatch('modifiedProject', null) + if (writeWorked) { this.setIsUnsaved(false) this.initialVersionId = diff --git a/src/components/Projects/ProjectManager.ts b/src/components/Projects/ProjectManager.ts index c03105ce5..c0f8965de 100644 --- a/src/components/Projects/ProjectManager.ts +++ b/src/components/Projects/ProjectManager.ts @@ -369,7 +369,10 @@ export class ProjectManager extends Signal { this.projectBeingModified++ } handleModifiedProjectEvent() { - this.projectBeingModified-- + // Sometimes a the writer await will resolve before the poller actually detects the change so we need to wait a tiny bit before unlocking to catch the delay + setTimeout(() => { + this.projectBeingModified-- + }, 1) } async handleWatchEvent(event: any) { if (this.selectedProject === null) return diff --git a/src/components/Toolbar/Category/download.ts b/src/components/Toolbar/Category/download.ts index f99e95da8..ab6b8bd09 100644 --- a/src/components/Toolbar/Category/download.ts +++ b/src/components/Toolbar/Category/download.ts @@ -1,17 +1,20 @@ +import { vuetify } from '../../App/Vuetify' +import { ToolbarButton } from '../ToolbarButton' import { App } from '/@/App' export function setupDownloadButton(app: App) { - App.toolbar.add({ - type: 'button', - id: 'download', - name: 'toolbar.download.name', - trigger() { - App.openUrl( - 'https://bridge-core.app/guide/download/', - undefined, - true - ) - }, - shouldRender: { value: !import.meta.env.VITE_IS_TAURI_APP }, - }) + App.toolbar.add( + new ToolbarButton( + 'mdi-download', + 'toolbar.download.name', + () => { + App.openUrl( + 'https://bridge-core.app/guide/download/', + undefined, + true + ) + }, + { value: !import.meta.env.VITE_IS_TAURI_APP } + ) + ) } diff --git a/src/components/Toolbar/Category/settings.ts b/src/components/Toolbar/Category/settings.ts index 09d9fd4d0..5275c6b1d 100644 --- a/src/components/Toolbar/Category/settings.ts +++ b/src/components/Toolbar/Category/settings.ts @@ -1,13 +1,15 @@ +import { ToolbarButton } from '../ToolbarButton' import { App } from '/@/App' export function setupSettingsButton(app: App) { - App.toolbar.add({ - type: 'button', - id: 'openSettings', - name: 'actions.settings.name', - trigger() { - app.windows.settings.open() - }, - shouldRender: { value: true }, - }) + App.toolbar.add( + new ToolbarButton( + 'mdi-cog', + 'actions.settings.name', + () => { + app.windows.settings.open() + }, + { value: true } + ) + ) } diff --git a/src/components/Toolbar/ToolbarButton.ts b/src/components/Toolbar/ToolbarButton.ts new file mode 100644 index 000000000..eecee6684 --- /dev/null +++ b/src/components/Toolbar/ToolbarButton.ts @@ -0,0 +1,32 @@ +import { v4 as uuid } from 'uuid' +import { EventDispatcher } from '../Common/Event/EventDispatcher' +import { UnwrapNestedRefs } from 'vue' + +export class ToolbarButton extends EventDispatcher { + public readonly id = uuid() + protected type = 'button' + constructor( + protected icon: string, + protected name: string, + protected callback: () => void, + protected shouldRender: UnwrapNestedRefs<{ value: boolean }> + ) { + super() + } + + toNestedMenu() { + return { + type: 'button', + icon: this.icon, + name: this.name, + onTrigger: () => this.trigger(), + } + } + + trigger() { + this.callback() + this.dispatch() + } + + dispose() {} +} diff --git a/src/components/Toolbar/ToolbarCategory.ts b/src/components/Toolbar/ToolbarCategory.ts index e68c5be63..54f1ec5ff 100644 --- a/src/components/Toolbar/ToolbarCategory.ts +++ b/src/components/Toolbar/ToolbarCategory.ts @@ -3,7 +3,7 @@ import { Action } from '/@/components/Actions/Action' import { IDisposable } from '/@/types/disposable' import { v4 as uuid } from 'uuid' import { EventDispatcher } from '../Common/Event/EventDispatcher' -import { Ref, del, reactive, ref, set } from 'vue' +import { del, reactive, set } from 'vue' import { Divider } from './Divider' export class ToolbarCategory extends EventDispatcher { @@ -11,8 +11,6 @@ export class ToolbarCategory extends EventDispatcher { protected type = 'category' public shouldRender = reactive({ value: true }) - protected isVisible = false - protected state: Record = reactive({}) protected disposableItems: Record = {} @@ -58,7 +56,6 @@ export class ToolbarCategory extends EventDispatcher { } trigger() { - this.isVisible = false this.dispatch() }