1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-18 12:31:12 +02:00

make item fetching from db independent of user.items

This commit is contained in:
Kushagra Gour
2024-05-07 13:19:33 +05:30
parent b751097a8e
commit 3d0f5ba6d9

View File

@@ -37,13 +37,7 @@ export const itemService = {
async getAllItems(shouldFetchLocally) { async getAllItems(shouldFetchLocally) {
var t = Date.now(); var t = Date.now();
var d = deferred(); var d = deferred();
let itemIds = await this.getUserItemIds(shouldFetchLocally);
itemIds = Object.getOwnPropertyNames(itemIds || {});
// log('itemids', itemIds);
if (!itemIds.length) {
d.resolve([]);
}
const items = []; const items = [];
if (window.user && !shouldFetchLocally) { if (window.user && !shouldFetchLocally) {
@@ -65,6 +59,13 @@ export const itemService = {
} }
); );
} else { } else {
let itemIds = await this.getUserItemIds(shouldFetchLocally);
itemIds = Object.getOwnPropertyNames(itemIds || {});
if (!itemIds.length) {
d.resolve([]);
}
for (let i = 0; i < itemIds.length; i++) { for (let i = 0; i < itemIds.length; i++) {
/* eslint-disable no-loop-func */ /* eslint-disable no-loop-func */
window.db.local.get(itemIds[i], itemResult => { window.db.local.get(itemIds[i], itemResult => {