The iOS manufacturing app, constructed from Expo Go, efficiently downloaded a considerable amount of information (over 40,000 merchandise). Nonetheless, when making an attempt to pick information from these things, the app crashes. How can this situation be mounted?
That is insert 40000 merchandise and over 100 inventory areas from odoo in perform ProductList()
async perform getProductListDownload() {
strive {
const consequence = await odoo.name('get_product_list_mobile', {
mannequin: 'product.product',
args: ['product.product'],
});
if (consequence) {
for (const product of consequence) {
await insertProductList( [],
);
}
console.log('All merchandise inserted efficiently.');
} else {
console.error('Did not fetch product record:', consequence);
}
} catch (error) {
console.error('Error in getProductListDownload:', error);
}
}
async perform getWarehouseOfUser() {
strive {
const consequence = await odoo.learn({
mannequin: "res.customers",
id: userId,
fields: ["allowed_warehouse_ids"],
context:{
allowed_company_ids:[
odoo.company_id
]
}
});
const allowedWarehouseIds = consequence[0]?.allowed_warehouse_ids || [];
if (allowedWarehouseIds.size > 0) {
for (const warehouseId of allowedWarehouseIds) {
strive {
const warehouse = await odoo.learn({
mannequin: "inventory.warehouse",
id: warehouseId,
fields: ["id", "name", "lot_stock_id", "company_id"],
});
const warehouseData = Array.isArray(warehouse) ? warehouse[0] : warehouse;
if (warehouseData) {
const lotStockId = warehouseData.lot_stock_id?.[0] || null;
const lotStockName = warehouseData.lot_stock_id?.[1] || "";
const companyId = warehouseData.company_id?.[0] || null;
const companyName = warehouseData.company_id?.[1] || "";
await insertStockWarehouseList({
id: warehouseData.id,
identify: warehouseData.identify,
lot_stock_id: lotStockId,
company_id: companyId
});
if (lotStockId && lotStockName) {
await insertStockLocationList({
id: lotStockId,
identify: lotStockName,
company_id: companyId
});
console.log(`Location ${lotStockId} inserted efficiently.`);
} else {
console.log(`Skipping insertion for warehouse ${warehouseId}: Lacking lot_stock_id or lot_stock_name.`);
}
}
} catch (error) {
console.error(`Did not fetch warehouse ID: ${warehouseId}`, error);
}
}
} else {
console.log("No allowed warehouses discovered.");
}
} catch (error) {
console.log("Error in getWarehouseOfUser:", error);
}
}
That is InventoryForm() perform’s stock counting code
const getProductData = async (restrict = 100) => {
strive {
const db = await SQLite.openDatabaseAsync('oderp.db');
const consequence = await db.getAllAsync(`SELECT * FROM product_product LIMIT ?`, [limit]);
return consequence;
} catch (e) {
console.error('Error fetching product information:', e);
return [];
}
};
const searchProduct = async (question) => {
strive {
const db = await SQLite.openDatabaseAsync('oderp.db');
const consequence = await db.getAllAsync(
`SELECT * FROM product_product WHERE identify LIKE ? OR default_code LIKE ? LIMIT 50`,
[`%${query}%`, `%${query}%`]
);
return consequence;
} catch (e) {
console.error('Error looking product:', e);
return [];
}
};
const getLocationData = async () => {
strive {
const db = await SQLite.openDatabaseAsync('oderp.db');
const consequence = await db.getAllAsync('SELECT id, identify FROM stock_location');
return consequence;
} catch (e) {
console.error('Error fetching location information:', e);
return [];
}
};
const searchLocation = async (question) => {
strive {
const db = await SQLite.openDatabaseAsync('oderp.db');
const consequence = await db.getAllAsync(
`SELECT * FROM stock_location WHERE identify LIKE ? LIMIT 50`,
[`%${query}%`]
);
return consequence;
} catch (e) {
console.error('Error looking location:', e);
return [];
}
};
useEffect(() => {
const fetchProductData = async () => {
const merchandise = await getProductData();
console.log("--------fetch product-----")
setProductOptions(merchandise);
};
fetchProductData();
}, []);
useEffect(() => {
const fetchLocationData = async () => {
const areas = await getLocationData();
console.log("------locations----", areas)
setLocationOptions(areas);
};
fetchLocationData();
}, []);
The app on TestFlight initially downloads 40,000 objects. After that, when navigating to the stock counting display screen and performing choose or search operations on the downloaded 40,000 objects, the display screen freezes after which crashes.
Within the Expo Go growth surroundings, it really works usually.
Please, assist me 🙂