Skip to content

Commit

Permalink
Migrate emojiless accts to addy's emoji/color (#2167)
Browse files Browse the repository at this point in the history
* Migrate emojiless accts to addy's emoji/color

* unused func linter error
  • Loading branch information
nicoglennon committed Jul 6, 2021
1 parent 920d1b7 commit dae32a4
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/model/migrations.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ import {
getUserLists,
saveUserLists,
} from '@rainbow-me/handlers/localstorage/userLists';
import { returnStringFirstEmoji } from '@rainbow-me/helpers/emojiHandler';
import { updateWebDataEnabled } from '@rainbow-me/redux/showcaseTokens';
import { DefaultTokenLists } from '@rainbow-me/references';
import { defaultProfileUtils } from '@rainbow-me/utils';
import logger from 'logger';

export default async function runMigrations() {
Expand Down Expand Up @@ -304,10 +306,23 @@ export default async function runMigrations() {
let updatedWallets = { ...wallets };
for (let i = 0; i < walletKeys.length; i++) {
const wallet = wallets[walletKeys[i]];
const newAddresses = wallet.addresses.map(address => ({
...address,
color: newColorIndexes[address.color] || 0,
}));
const newAddresses = wallet.addresses.map(account => {
const accountEmoji = returnStringFirstEmoji(account?.label);
return {
...account,
...(!accountEmoji && {
label: `${defaultProfileUtils.addressHashedEmoji(
account.address
)} ${account.label}`,
}),
color:
(accountEmoji
? newColorIndexes[account.color]
: defaultProfileUtils.addressHashedColorIndex(
account.address
)) || 0,
};
});
const newWallet = { ...wallet, addresses: newAddresses };
updatedWallets[walletKeys[i]] = newWallet;
}
Expand Down

0 comments on commit dae32a4

Please sign in to comment.