MCPcopy Create free account
hub / github.com/MiniMax-AI/OpenRoom / migrateOldFormat

Function migrateOldFormat

apps/webuiapps/src/lib/modManager.ts:198–221  ·  view source on GitHub ↗

Migrate old separate config/state format to collection

()

Source from the content-addressed store, hash-verified

196
197/** Migrate old separate config/state format to collection */
198function migrateOldFormat(): ModCollection | null {
199 try {
200 const cfgRaw = localStorage.getItem('openroom_mod_config');
201 const stRaw = localStorage.getItem('openroom_mod_state');
202 if (cfgRaw) {
203 const cfg = JSON.parse(cfgRaw) as ModConfig;
204 if (cfg.mod_name && !cfg.id) {
205 const migrated: ModConfig = { ...cfg, id: DEFAULT_MOD_ID };
206 const st = stRaw ? (JSON.parse(stRaw) as ModState) : defaultState(migrated);
207 const collection: ModCollection = {
208 activeId: DEFAULT_MOD_ID,
209 items: { [DEFAULT_MOD_ID]: { config: migrated, state: st } },
210 };
211 localStorage.setItem(STORAGE_KEY, JSON.stringify(collection));
212 localStorage.removeItem('openroom_mod_config');
213 localStorage.removeItem('openroom_mod_state');
214 return collection;
215 }
216 }
217 } catch {
218 // ignore
219 }
220 return null;
221}
222
223export async function loadModCollection(): Promise<ModCollection | null> {
224 try {

Callers 1

loadModCollectionSyncFunction · 0.70

Calls 1

defaultStateFunction · 0.85

Tested by

no test coverage detected