Skip to content

Commit

Permalink
Select account and close modal on Watch (#301)
Browse files Browse the repository at this point in the history
  • Loading branch information
sammanadh authored Aug 1, 2022
1 parent 5c0b12e commit 724e88e
Showing 1 changed file with 22 additions and 6 deletions.
28 changes: 22 additions & 6 deletions src/renderer/components/WatchAccountButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import Form from 'react-bootstrap/Form';
import OverlayTrigger from 'react-bootstrap/OverlayTrigger';
import Popover from 'react-bootstrap/Popover';
import { logger } from '../common/globals';
import { setSelected } from '../data/SelectedAccountsList/selectedAccountsState';
import { useAppDispatch } from '../hooks';

function WatchAcountPopover(props: {
pinAccount: (pk: string, b: boolean) => void;
onWatch: (pk: string, b: boolean) => void;
}) {
const { pinAccount } = props;
const { onWatch } = props;

const pubKeyVal = '';

Expand Down Expand Up @@ -74,7 +76,7 @@ function WatchAcountPopover(props: {
type="button"
disabled={validationError || !toKey}
onClick={() => {
pinAccount(toKey, false);
onWatch(toKey, false);
}}
>
Watch
Expand All @@ -91,15 +93,29 @@ function WatchAccountButton(props: {
pinAccount: (pk: string, b: boolean) => void;
}) {
const { pinAccount } = props;
const [show, setShow] = useState(false);
const dispatch = useAppDispatch();

const handleWatch = (toKey, isPinned) => {
pinAccount(toKey, isPinned);
dispatch(setSelected(toKey));
setShow(false);
};

return (
<OverlayTrigger
trigger="click"
placement="bottom"
overlay={WatchAcountPopover({ pinAccount })}
overlay={WatchAcountPopover({ onWatch: handleWatch })}
rootClose
show={show}
>
<Button variant="success" size="sm">
<Button
variant="success"
size="sm"
onClick={() => {
setShow((prev) => !prev);
}}
>
Watch
</Button>
</OverlayTrigger>
Expand Down

0 comments on commit 724e88e

Please sign in to comment.