1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-26 08:11:17 +02:00

try saving with refreshed ids when importing to DB fails

This commit is contained in:
Kushagra Gour
2024-06-25 14:54:45 +05:30
parent e8ad1b1599
commit f80a99f15e
2 changed files with 56 additions and 15 deletions

View File

@@ -672,3 +672,16 @@ export function persistAuthUserLocally(user) {
keys.map(key => (obj[key] = user[key]));
window.localStorage.setItem('user', JSON.stringify(obj));
}
/**
* items is an object of {itemId: item}. This fn changes all the keys to new item IDs
* */
export function refreshItemIds(items) {
const newItems = {};
for (var id in items) {
const newId = generateRandomId();
items[id].id = newId;
newItems[newId] = items[id];
}
return newItems;
}