Trigger tip counter refresh on change (#3945)

* trigger for refresh

* trigger onSuccess for close or cancel

* remove stray import

* Apply suggestions from code review

Co-authored-by: Jaco Greeff <jacogr@gmail.com>

* alpha ordering

Co-authored-by: Jaco Greeff <jacogr@gmail.com>
This commit is contained in:
Thibaut Sardan 2020-10-30 10:00:00 +01:00 committed by GitHub
parent fc985cb3e0
commit dfc87bd7bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -22,6 +22,7 @@ interface Props {
hash: string;
isMember: boolean;
members: string[];
onRefresh: () => void;
onSelect: (hash: string, isSelected: boolean, value: BN) => void;
onlyUntipped: boolean;
tip: OpenTip | OpenTipTo225;
@ -75,7 +76,7 @@ function extractTipState (tip: OpenTip | OpenTipTo225, hash: string, allAccounts
};
}
function Tip ({ bestNumber, className = '', defaultId, hash, isMember, members, onSelect, onlyUntipped, tip }: Props): React.ReactElement<Props> | null {
function Tip ({ bestNumber, className = '', defaultId, hash, isMember, members, onRefresh, onSelect, onlyUntipped, tip }: Props): React.ReactElement<Props> | null {
const { t } = useTranslation();
const { allAccounts } = useAccounts();
@ -150,6 +151,7 @@ function Tip ({ bestNumber, className = '', defaultId, hash, isMember, members,
icon='times'
isDisabled={!isFinder}
label={t('Cancel')}
onSuccess={onRefresh}
params={[hash]}
tx='treasury.retractTip'
/>
@ -171,6 +173,7 @@ function Tip ({ bestNumber, className = '', defaultId, hash, isMember, members,
accountId={councilId}
icon='times'
label={t<string>('Close')}
onSuccess={onRefresh}
params={[hash]}
tx='treasury.closeTip'
/>

View File

@ -19,6 +19,7 @@ interface Props {
hashes?: string[] | null;
isMember: boolean;
members: string[];
onRefresh: () => void;
onSelectTip: (hash: string, isSelected: boolean, value: BN) => void,
}
@ -43,7 +44,7 @@ function extractTips (optTips?: Option<OpenTip>[], hashes?: string[] | null): Ti
);
}
function Tips ({ className = '', defaultId, hashes, isMember, members, onSelectTip }: Props): React.ReactElement<Props> {
function Tips ({ className = '', defaultId, hashes, isMember, members, onRefresh, onSelectTip }: Props): React.ReactElement<Props> {
const { t } = useTranslation();
const { api } = useApi();
const [onlyUntipped, setOnlyUntipped] = useState(false);
@ -89,6 +90,7 @@ function Tips ({ className = '', defaultId, hashes, isMember, members, onSelectT
isMember={isMember}
key={hash}
members={members}
onRefresh={onRefresh}
onSelect={onSelectTip}
onlyUntipped={onlyUntipped}
tip={tip}

View File

@ -77,6 +77,7 @@ function TipsEntry ({ className, hashes, isMember, members, trigger }: Props): R
hashes={hashes}
isMember={isMember}
members={members}
onRefresh={trigger}
onSelectTip={_selectTip}
/>
</div>