saveItems(items) {
		var d = deferred();
		// When not logged in
		if (!window.user) {
			// save new items
			window.db.local.set(items, d.resolve);
			// Push in new item IDs
			window.db.local.get(
				{
					items: {}
				},
				function (result) {
					/* eslint-disable guard-for-in */
					for (var id in items) {
						result.items[id] = true;
					}
					window.db.local.set({
						items: result.items
					});
					/* eslint-enable guard-for-in */
				}
			);
		} else {
			const remoteDb = window.db.getDb();

			function save(items) {
				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
					});
				}
				return batch.commit();
				/* eslint-enable guard-for-in */
			}

			function onSuccess(items) {
				window.user.items = window.user.items || {};
				for (var id in items) {
					// Set these items on our cached user object too
					window.user.items[id] = true;
				}
				d.resolve();
			}

			save(items)
				.then(() => {
					onSuccess(items);
				})
				.catch(e => {
					// The only reason we know for this failing is the same creations were
					// imported in other account. And hence they can't again be saved in the
					// DB with same ID and different `createdBy`
					// So now we save them with different IDs
					log('Saving imported items failed. Trying with refreshed IDs now...');
					const refreshedItems = refreshItemIds(items);
					save(refreshedItems)
						.then(() => {
							onSuccess(refreshedItems);
						})
						.catch(e => {
							log('Error saving items', e);
							alert('Your items could not be saved. Please try again later.');
						});
				});
		}
		return d.promise;
	}
Saves the passed items in the database.
@param {Array} items to be saved in DB