From 3c24e7eaa32ab544f65f6f923add7d627e393fda Mon Sep 17 00:00:00 2001 From: Philipp Walter Date: Mon, 24 Mar 2025 15:15:02 +0100 Subject: [PATCH] fix(widgets): sort order migration --- src/store/index.ts | 2 +- src/store/migrations/index.ts | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/store/index.ts b/src/store/index.ts index 1d3b54c70..f129ee7b6 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -32,7 +32,7 @@ const persistConfig = { key: 'root', storage: reduxStorage, // increase version after store shape changes - version: 53, + version: 54, stateReconciler: autoMergeLevel2, blacklist: ['receive', 'ui'], migrate: createMigrate(migrations, { debug: __ENABLE_MIGRATION_DEBUG__ }), diff --git a/src/store/migrations/index.ts b/src/store/migrations/index.ts index 00c837990..9d9897255 100644 --- a/src/store/migrations/index.ts +++ b/src/store/migrations/index.ts @@ -153,6 +153,33 @@ const migrations = { }, }; }, + 54: (state): PersistedState => { + // migrate widgets sort order + const newSortOrder = state.widgets.sortOrder + .map((item) => { + // Handle slashfeed items + if (item.includes('slashfeed:')) { + if (item.includes('Bitcoin Headlines')) return 'news'; + if (item.includes('Bitcoin Price')) return 'price'; + if (item.includes('Bitcoin Blocks')) return 'blocks'; + if (item.includes('Bitcoin Facts')) return 'facts'; + } + // Non-slashfeed items pass through unchanged + return item; + }) + .filter((item, index, arr) => { + // Remove duplicates + return arr.indexOf(item) === index; + }); + + return { + ...state, + widgets: { + ...state.widgets, + sortOrder: newSortOrder, + }, + }; + }, }; export default migrations;