Skip to content

Commit

Permalink
Remove reverse resolve name when toggling off.
Browse files Browse the repository at this point in the history
  • Loading branch information
rocky-fleek committed May 10, 2022
1 parent 158d46c commit 46fe3e7
Showing 1 changed file with 31 additions and 4 deletions.
35 changes: 31 additions & 4 deletions source/Popup/Views/WalletDetails/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useRef } from 'react';
import React, { useState, useRef, useEffect } from 'react';
import clsx from 'clsx';
import { useTranslation } from 'react-i18next';
import Picker from 'emoji-picker-react';
Expand All @@ -21,7 +21,7 @@ import {
LinkButton,
} from '@ui';
import { setUseICNS } from '@modules/storageManager';
import { setUseICNS as setReduxUseICNS } from '@redux/icns';
import { setICNSData, setUseICNS as setReduxUseICNS } from '@redux/icns';

import useStyles from './styles';
import DetailItem from './components/DetailItem';
Expand Down Expand Up @@ -91,10 +91,37 @@ const WalletDetails = () => {
};

const handleToggleICNS = (event) => {
dispatch(setReduxUseICNS(event.target.checked));
setUseICNS(event.target.checked, walletNumber);
const { checked } = event.target;
dispatch(setReduxUseICNS(checked));
setUseICNS(checked, walletNumber);
if (!checked) {
sendMessage({
type: HANDLER_TYPES.SET_REVERSE_RESOLVED_NAME,
params: '',
}, (response) => {
if (response.error) {
console.log('Error when resetting your reverse resolved name', response.error); // TODO HANDLE ERROR (shouldnt happen tho)
} else {
sendMessage({
type: HANDLER_TYPES.GET_ICNS_DATA,
params: { refresh: true },
}, (icnsData) => {
dispatch(setICNSData(icnsData));
});
}
});
}
};

useEffect(() => {
sendMessage({
type: HANDLER_TYPES.GET_ICNS_DATA,
params: { refresh: true },
}, (icnsData) => {
dispatch(setICNSData(icnsData));
});
}, []);

const hasActiveResolvedICNS = resolved && useICNS;
return (
<Layout>
Expand Down

0 comments on commit 46fe3e7

Please sign in to comment.