Skip to content

Commit 3c24e7e

Browse files
committed
fix(widgets): sort order migration
1 parent 2103802 commit 3c24e7e

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/store/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const persistConfig = {
3232
key: 'root',
3333
storage: reduxStorage,
3434
// increase version after store shape changes
35-
version: 53,
35+
version: 54,
3636
stateReconciler: autoMergeLevel2,
3737
blacklist: ['receive', 'ui'],
3838
migrate: createMigrate(migrations, { debug: __ENABLE_MIGRATION_DEBUG__ }),

src/store/migrations/index.ts

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,33 @@ const migrations = {
153153
},
154154
};
155155
},
156+
54: (state): PersistedState => {
157+
// migrate widgets sort order
158+
const newSortOrder = state.widgets.sortOrder
159+
.map((item) => {
160+
// Handle slashfeed items
161+
if (item.includes('slashfeed:')) {
162+
if (item.includes('Bitcoin Headlines')) return 'news';
163+
if (item.includes('Bitcoin Price')) return 'price';
164+
if (item.includes('Bitcoin Blocks')) return 'blocks';
165+
if (item.includes('Bitcoin Facts')) return 'facts';
166+
}
167+
// Non-slashfeed items pass through unchanged
168+
return item;
169+
})
170+
.filter((item, index, arr) => {
171+
// Remove duplicates
172+
return arr.indexOf(item) === index;
173+
});
174+
175+
return {
176+
...state,
177+
widgets: {
178+
...state.widgets,
179+
sortOrder: newSortOrder,
180+
},
181+
};
182+
},
156183
};
157184

158185
export default migrations;

0 commit comments

Comments
 (0)