mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-27 02:52:43 +00:00
Copy exisitng key data to new keys
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import localStorageKeyMap from './localStorageKeyMap.json' with { type: 'json' };
|
||||
|
||||
const updateLocalStorage = function(){
|
||||
// Return if no window and thus no local storage
|
||||
if(typeof window === 'undefined') return;
|
||||
|
||||
// Return if the local storage key map has no content
|
||||
if(Object.keys(localStorageKeyMap).length == 0) return;
|
||||
|
||||
const storage = window.localStorage;
|
||||
|
||||
Object.keys(localStorageKeyMap).forEach((key)=>{
|
||||
if(storage[key]){
|
||||
const data = storage.getItem(key);
|
||||
storage.setItem(localStorageKeyMap[key], data);
|
||||
// storage.removeItem(key);
|
||||
}
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
export { updateLocalStorage };
|
||||
Reference in New Issue
Block a user