mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-07 18:32:40 +00:00
Copy exisitng key data to new keys
This commit is contained in:
@@ -4,6 +4,8 @@ import './homebrew.less';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { StaticRouter as Router, Route, Routes, useParams, useSearchParams } from 'react-router';
|
import { StaticRouter as Router, Route, Routes, useParams, useSearchParams } from 'react-router';
|
||||||
|
|
||||||
|
import { updateLocalStorage } from './utils/updateLocalStorage/updateLocalStorageKeys.js';
|
||||||
|
|
||||||
import HomePage from './pages/homePage/homePage.jsx';
|
import HomePage from './pages/homePage/homePage.jsx';
|
||||||
import EditPage from './pages/editPage/editPage.jsx';
|
import EditPage from './pages/editPage/editPage.jsx';
|
||||||
import UserPage from './pages/userPage/userPage.jsx';
|
import UserPage from './pages/userPage/userPage.jsx';
|
||||||
@@ -48,6 +50,8 @@ const Homebrew = (props)=>{
|
|||||||
global.enable_themes = enable_themes;
|
global.enable_themes = enable_themes;
|
||||||
global.config = config;
|
global.config = config;
|
||||||
|
|
||||||
|
updateLocalStorage();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Router location={url}>
|
<Router location={url}>
|
||||||
<div className='homebrew'>
|
<div className='homebrew'>
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"AUTOSAVE_ON" : "HB_editor_autoSaveOn",
|
||||||
|
"HOMEBREWERY-EDITOR-THEME" : "HB_editor_theme",
|
||||||
|
"liveScroll" : "HB_editor_liveScroll",
|
||||||
|
"naturalcrit-pane-split" : "HB_editor_splitWidth",
|
||||||
|
"HOMEBREWERY-LISTPAGE-SORTDIR" : "HB_listPage_sortDir",
|
||||||
|
"HOMEBREWERY-LISTPAGE-SORTTYPE" : "HB_listPage_sortType",
|
||||||
|
"HOMEBREWERY-LISTPAGE-VISIBILITY" : "HB_listPage_visibility_group",
|
||||||
|
"dismiss_notif_drive" : "HB_dismissNotif_drive",
|
||||||
|
"dismiss_notif_faq" : "HB_dismissNotif_faq",
|
||||||
|
"dismiss_notif_update_v3.18" : "HB_dismissNotif_update_v3.18",
|
||||||
|
"dismiss_v134 update" : "HB_dismissNotif_update_v134",
|
||||||
|
"hbAdminTab" : "HB_adminPage_currentTab",
|
||||||
|
"homebrewery-new" : "HB_newPage_content",
|
||||||
|
"homebrewery-new-meta" : "HB_newPage_metadata",
|
||||||
|
"homebrewery-new-style" : "HB_newPage_style",
|
||||||
|
"homebrewery-recently-edited" : "HB_nav_recentlyEdited",
|
||||||
|
"homebrewery-recently-viewed" : "HB_nav_recentlyViewed"
|
||||||
|
}
|
||||||
@@ -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