mirror of
https://github.com/chinchang/web-maker.git
synced 2025-07-23 15:01:14 +02:00
fix remote db access
This commit is contained in:
@@ -168,23 +168,23 @@ export const itemService = {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
window.db.getDb().then(remoteDb => {
|
const remoteDb = window.db.getDb();
|
||||||
const batch = writeBatch(remoteDb);
|
|
||||||
/* eslint-disable guard-for-in */
|
|
||||||
for (var id in items) {
|
|
||||||
items[id].createdBy = window.user.uid;
|
|
||||||
batch.set(doc(remoteDb, `items/${id}`), items[id]);
|
|
||||||
batch.update(doc(remoteDb, `users/${window.user.uid}`), {
|
|
||||||
[`items.${id}`]: true
|
|
||||||
});
|
|
||||||
|
|
||||||
// Set these items on our cached user object too
|
const batch = writeBatch(remoteDb);
|
||||||
window.user.items = window.user.items || {};
|
/* eslint-disable guard-for-in */
|
||||||
window.user.items[id] = true;
|
for (var id in items) {
|
||||||
}
|
items[id].createdBy = window.user.uid;
|
||||||
batch.commit().then(d.resolve);
|
batch.set(doc(remoteDb, `items/${id}`), items[id]);
|
||||||
/* eslint-enable guard-for-in */
|
batch.update(doc(remoteDb, `users/${window.user.uid}`), {
|
||||||
});
|
[`items.${id}`]: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set these items on our cached user object too
|
||||||
|
window.user.items = window.user.items || {};
|
||||||
|
window.user.items[id] = true;
|
||||||
|
}
|
||||||
|
batch.commit().then(d.resolve);
|
||||||
|
/* eslint-enable guard-for-in */
|
||||||
}
|
}
|
||||||
return d.promise;
|
return d.promise;
|
||||||
},
|
},
|
||||||
|
Reference in New Issue
Block a user