1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-04 23:14:56 +01:00
metamask-extension/app/scripts/migrations/060.js
ryanml c9a539b5aa Removing support survey notification from What's New (#11118)
* Removing support notification from what's new

* Adding migration for support notification removal

* Expanding test cases, using async/await for storage comparison
2021-06-07 10:33:25 -02:30

36 lines
904 B
JavaScript

import { cloneDeep, isPlainObject } from 'lodash';
const version = 60;
const SUPPORT_NOTIFICATION_KEY = 2;
const SUPPORT_NOTIFICATION_DATE = '2020-08-31';
/**
* Removes the support survey notification
*/
export default {
version,
async migrate(originalVersionedData) {
const versionedData = cloneDeep(originalVersionedData);
versionedData.meta.version = version;
const state = versionedData.data;
const newState = transformState(state);
versionedData.data = newState;
return versionedData;
},
};
function transformState(state) {
const notifications = state?.NotificationController?.notifications;
if (isPlainObject(notifications)) {
if (
notifications[SUPPORT_NOTIFICATION_KEY]?.date ===
SUPPORT_NOTIFICATION_DATE
) {
delete state.NotificationController.notifications[
SUPPORT_NOTIFICATION_KEY
];
}
}
return state;
}