Skip to content

Commit

Permalink
DEXW-2351: remove legacy user settings during migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Voronin committed Nov 15, 2019
1 parent 630b399 commit d9d98cd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/modules/app/services/DefaultSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@
return Object.prototype.hasOwnProperty.call(this.commonDefaults, start);
}

getDefaultSettings() {
return this.defaults;
}

}

return {
Expand Down
15 changes: 13 additions & 2 deletions src/modules/app/services/StorageExporter.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
(function () {
'use strict';

const { pickBy, hasIn } = require('ramda');

class StorageExporter {

static $inject = [
'$log',
'storage',
'multiAccount'
'multiAccount',
'defaultSettings'
];

/**
* @param {ng.ILogService} $log
* @param {app.utils.Storage} storage
* @param {app.MultiAccount} multiAccount
*/
constructor($log, storage, multiAccount) {
constructor($log, storage, multiAccount, defaultSettings) {
this.$log = $log;
this.storage = storage;
this.multiAccount = multiAccount;
this.defaultSettings = defaultSettings;
}

/**
Expand Down Expand Up @@ -49,6 +53,13 @@
}
}

const predicate = (value, key) => hasIn(key, this.defaultSettings.create().getDefaultSettings());

for (const user of Object.entries(storageData.usersList)) {
delete user.settings.encryptionRounds;
user.settings = pickBy(predicate)(user.settings);
}

return this.multiAccount.export(privateKeyFrom, publicKeyTo, storageData);
}

Expand Down

0 comments on commit d9d98cd

Please sign in to comment.