I have a large amount of data that needs to be added to the firestore, which makes my app crash onto the main screen of my iPhone 6.
After taking steps like preventing continuous request sending or notifying the user of the progress I have minimized the application crash but not thoroughly.
upload complete image => add data to firestore
I am using expo + iphone 6
Is there an application on the PC that can test expo app performance?
save = async () => {
if (this.state.ready === true) {
this.setState({ showAlert: true, ready: false })
const a = []
this.state.image.map(async (res, index) => {
a.push(new Promise((resolve, reject) => {
resolve(Fire.shared.uploadanh(res, `product/${Fire.shared.uid}/${Date.now() + index}`))
}))
})
Promise.all(a).then((res) => {
firebase.firestore().collection("user").doc(Fire.shared.uid).collection('Product').add({
image: res,
name: this.state.name,
danhmuc: this.state.danhmuc,
nghanhhang: this.state.nghanhhang,
giaban: this.state.giaban,
xuatxu: this.state.xuatxu,
soluong: this.state.soluong,
phiban: this.state.phiban,
mota: this.state.mota,
thuonghieu: this.state.thuonghieu,
kg: this.state.kg,
...(this.state.hansudung && this.state.hansudung !== "" ? { hansudung: this.state.hansudung } : {}),
...(this.state.dungtich && this.state.dungtich !== "" ? { dungtich: this.state.dungtich } : {}),
...(this.state.baohanh && this.state.baohanh !== "" ? { baohanh: this.state.baohanh } : {}),
...(this.state.pin && this.state.pin !== "" ? { pin: this.state.pin } : {}),
...(this.state.hdh && this.state.hdh !== "" ? { hdh: this.state.hdh } : {}),
...(this.state.sizePhone && this.state.sizePhone !== "" ? { sizePhone: this.state.sizePhone } : {}),
...(this.state.memory && this.state.memory !== "" ? { memory: this.state.memory } : {}),
...(this.state.color.length > 0 ? { color: this.state.color } : {}),
...(this.state.size.length > 0 ? { size: this.state.size } : {}),
...(this.state.Material.length > 0 ? { Material: this.state.Material } : {}),
}).then((docRef) => {
alert(this.state.Material);
this.setState({ showAlert: false, ready: true })
}).catch(error => alert(error));
});
}
}