Issue
I have a application using ionic + react with a page that a user can upload a image from camera or gallery in that page and i save the imagem as binary on the database (indexed db using dexie) so far so good everything works as expected But when the user press backbutton after the image selection and the database save code is not completed happens that the save never ocurs...
Question 1: is it normal behavior? that a code that is running just hang execution when pressing backbutton?
Question 2: there is something i can do to make a code execute no matter what and solve my problem?
some code to be added:
the button just calls a commit function that call this function internally:
const saveImageOffline = async (uuid: string, form: FormData) => {
const qtd: number = await dbGetTable('storedImages').where({ id: uuid }).count();
if (qtd > 0) {
await dbGetTable('storedImages').update(uuid, {
id: uuid,
content: form.get('image'),
});
} else {
await dbGetTable('storedImages').put({
id: uuid,
content: form.get('image'),
});
}
};
Solution
Well i dont know if this is the best approach but i made it work adding a function that calls a function inside a global context, then the saving process i have made throught this context function and it works now.
For now this was the solution, if anyone has a better one i really love to hear.
Answered By - vinicius gati
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.