Fix download bugs in browser

This commit is contained in:
2024-07-14 14:59:30 +09:30
parent 39a1a80ebb
commit bbed468e67
2 changed files with 15 additions and 15 deletions

View File

@@ -36,7 +36,7 @@ export class EditorComponent {
protected values = signal<any>(undefined);
protected downloadName = computed(
() => this.selectedFile() ?? `${this.selectedMessage.name}.json`
() => this.selectedFile() ?? `${this.selectedMessage().name}.json`
);
private serialisedValues = computed(() =>
JSON.stringify(this.values(), undefined, this.indentSize())
@@ -118,15 +118,12 @@ export class EditorComponent {
protected async save() {
const selectedFile = this.selectedFile();
if (__TAURI__) {
if (typeof __TAURI__ !== 'undefined') {
const serialised = this.serialisedValues();
try {
// TODO: Tauri is bugged on mac atm, remove this when resolved: https://github.com/tauri-apps/tauri/issues/4633
if (selectedFile) {
try {
await writeTextFile(selectedFile, serialised);
} catch (err) {
console.error('Failed to write to file ${this.selectedFile()}', err);
}
} else {
const filePath = await save({
defaultPath: `${this.selectedMessage().name}.json`,
@@ -135,6 +132,9 @@ export class EditorComponent {
await writeTextFile(filePath, serialised);
}
}
} catch (err) {
console.error(`Failed to save to file`, err);
}
} else {
this.downloader()?.nativeElement.click();
}

View File

@@ -197,7 +197,7 @@ export class ProtoDefinitionSelectorComponent {
}
protected async exportConfiguration() {
if (__TAURI__) {
if (typeof __TAURI__ !== undefined) {
const filePath = await save({
defaultPath: `bufpiv.json`,
});