View on GitHub
File Changes
  isRestoreActive?: boolean,
  restoreProgress?: number,
  isLegacy: boolean,
+
  mnemonicsConfirmationStatus: string,
};

                      
@observer
      isRestoreActive,
      restoreProgress,
      isLegacy,
+
      mnemonicsConfirmationStatus,
    } = this.props;

                      
    const componentStyles = classNames([
      styles.component,
      active ? styles.active : null,
      isLegacy ? styles.legacyItem : null,
      className,
+
      styles[`mnemonicsConfirmationStatus-${mnemonicsConfirmationStatus}`],
    ]);

                      
    return (
                isRestoreActive={wallet.isRestoreActive}
                restoreProgress={wallet.restoreProgress}
                isLegacy={wallet.isLegacy}
+
                mnemonicsConfirmationStatus={wallet.mnemonicsConfirmationStatus}
              />
            ))}
          </Scrollbars>
    cursor: default;
  }
}
+

                      
+
.mnemonicsConfirmationStatus-notification {
+
  background: red;
+
  &:after {
+
    background: red;
+
    border-radius: 50%;
+
    content: '';
+
    display: block;
+
    height: 10px;
+
    position: absolute;
+
    right: 10px;
+
    width: 10px;
+
  }
+
}
import { pick } from 'lodash';
import { observable, computed, action, runInAction } from 'mobx';
import BigNumber from 'bignumber.js';
+
import moment from 'moment';
+
import {
+
  MNEMONICS_CHECKING_NOTIFICATION,
+
  MNEMONICS_CHECKING_WARNING,
+
} from '../config/walletsConfig';
import {
  getWalletLocalData,
  updateWalletLocalData,
  },
};

                      
+
export const WalletStatuses = {
+
  OK: 'ok',
+
  WARNING: 'warning',
+
  NOTIFICATION: 'notification',
+
};
+

                      
+
export const WalletStatusesType = {
+
  NEVER_CHECKED: 'neverChecked',
+
  ALREADY_CHECKED: 'alreadyChecked',
+
};
+

                      
export type WalletProps = {
  id: string,
  name: string,
  @observable delegatedStakePool: ?StakePool;
  @observable createdAt: Date;
  @observable mnemonicsConfirmationDate: ?Date;
+
  @observable mnemonicsConfirmationStatus: string;
+
  @observable mnemonicsConfirmationStatusType: string;

                      
  constructor(data: WalletProps) {
    Object.assign(this, data);
  getWalletLocalData = async () => {
    const { id } = this;
    const { mnemonicsConfirmationDate } = await getWalletLocalData(id);
+
    const { status, type } = this.getWalletStatus(mnemonicsConfirmationDate);
    runInAction('set mnemonicsConfirmationDate', () => {
      this.mnemonicsConfirmationDate = mnemonicsConfirmationDate;
+
      this.mnemonicsConfirmationStatus = status;
+
      this.mnemonicsConfirmationStatusType = type;
    });
  };

                      
+
  getWalletStatus = (mnemonicsConfirmationDate: ?Date) => {
+
    const { walletCreationDate } = this;
+
    const dateToCheck = mnemonicsConfirmationDate || walletCreationDate;
+
    const daysSinceDate = moment().diff(moment(dateToCheck), 'days');
+
    let status = WalletStatuses.OK;
+
    if (daysSinceDate > MNEMONICS_CHECKING_NOTIFICATION)
+
      status = WalletStatuses.NOTIFICATION;
+
    else if (daysSinceDate > MNEMONICS_CHECKING_WARNING)
+
      status = WalletStatuses.WARNING;
+
    const type = mnemonicsConfirmationDate
+
      ? WalletStatusesType.ALREADY_CHECKED
+
      : WalletStatusesType.NEVER_CHECKED;
+
    return { status, type };
+
  };
+

                      
  @action updateWalletLocalData = async () => {
    const { id } = this;
    const mnemonicsConfirmationDate = new Date();
    this.mnemonicsConfirmationDate = mnemonicsConfirmationDate;
+
    this.mnemonicsConfirmationStatus = WalletStatuses.OK;
+
    this.mnemonicsConfirmationStatusType = WalletStatusesType.ALREADY_CHECKED;
    await updateWalletLocalData({
      id,
      mnemonicsConfirmationDate,
        get(w, 'syncState.tag') === WalletSyncStateTags.RESTORING,
      restoreProgress: get(w, 'syncState.data.percentage.quantity', 0),
      isLegacy: w.isLegacy,
+
      mnemonicsConfirmationDate: w.mnemonicsConfirmationDate,
+
      mnemonicsConfirmationStatus: w.mnemonicsConfirmationStatus,
+
      mnemonicsConfirmationStatusType: w.mnemonicsConfirmationStatusType,
+
      blah: true,
    }));
  }

                      
  isRestoreActive?: boolean,
  restoreProgress?: number,
  isLegacy: boolean,
+
  mnemonicsConfirmationStatus: string,
};