Change image loading to promise

Signed-off-by: Justin Georgi <justin.georgi@gmail.com>
This commit is contained in:
2023-11-29 21:37:40 -07:00
parent 0cc9ad385f
commit 3f314e5f1d

View File

@@ -314,15 +314,23 @@
});
},
getImage () {
var self = this
const searchImage = this.$refs.image_chooser.files[0]
//Promise goes here?
this.imageView = URL.createObjectURL(searchImage)
this.reader.readAsDataURL(searchImage)
this.imageLoaded = true
this.resultData = {}
this.selectedChip = -1
const box = this.$refs.structure_box
box.style.display = 'none'
let loadImage =new Promise((resolve, reject) => {
this.imageView = URL.createObjectURL(searchImage)
this.reader.readAsDataURL(searchImage)
resolve()
})
loadImage.then(() => {
this.imageLoaded = true
this.resultData = {}
this.selectedChip = -1
const box = this.$refs.structure_box
box.style.display = 'none'
}).catch((e) => {
console.log(e.message)
f7.dialog.alert('Error loading image')
})
}
}
}