Fix download bugs in browser
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ export class ProtoDefinitionSelectorComponent {
|
||||
}
|
||||
|
||||
protected async exportConfiguration() {
|
||||
if (__TAURI__) {
|
||||
if (typeof __TAURI__ !== undefined) {
|
||||
const filePath = await save({
|
||||
defaultPath: `bufpiv.json`,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user