tell the save dialog the file extension (#2303)
Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -14,9 +14,21 @@ interface ModelingAppFile {
|
|||||||
const save_ = async (file: ModelingAppFile) => {
|
const save_ = async (file: ModelingAppFile) => {
|
||||||
try {
|
try {
|
||||||
if (isTauri()) {
|
if (isTauri()) {
|
||||||
|
const extension = file.name.split('.').pop() || null
|
||||||
|
let extensions: string[] = []
|
||||||
|
if (extension !== null) {
|
||||||
|
extensions.push(extension)
|
||||||
|
}
|
||||||
|
|
||||||
// Open a dialog to save the file.
|
// Open a dialog to save the file.
|
||||||
const filePath = await save({
|
const filePath = await save({
|
||||||
defaultPath: file.name,
|
defaultPath: file.name,
|
||||||
|
filters: [
|
||||||
|
{
|
||||||
|
name: 'model',
|
||||||
|
extensions: extensions,
|
||||||
|
},
|
||||||
|
],
|
||||||
})
|
})
|
||||||
|
|
||||||
if (filePath === null) {
|
if (filePath === null) {
|
||||||
@ -48,7 +60,7 @@ export async function exportSave(data: ArrayBuffer) {
|
|||||||
// This converts the ArrayBuffer to a Rust equivalent Vec<u8>.
|
// This converts the ArrayBuffer to a Rust equivalent Vec<u8>.
|
||||||
let uintArray = new Uint8Array(data)
|
let uintArray = new Uint8Array(data)
|
||||||
|
|
||||||
const files: ModelingAppFile[] = deserialize_files(uintArray)
|
let files: ModelingAppFile[] = deserialize_files(uintArray)
|
||||||
|
|
||||||
if (files.length > 1) {
|
if (files.length > 1) {
|
||||||
let zip = new JSZip()
|
let zip = new JSZip()
|
||||||
|
Reference in New Issue
Block a user