mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-03-01 19:45:04 +01:00
ADD: option to hide contact
This commit is contained in:
parent
9d56d63c8f
commit
6a82c12576
3 changed files with 36 additions and 0 deletions
|
@ -44,6 +44,10 @@ export type TCounterpartyMetadata = {
|
||||||
* custom human-readable name we assign ourselves
|
* custom human-readable name we assign ourselves
|
||||||
*/
|
*/
|
||||||
label: string;
|
label: string;
|
||||||
|
/**
|
||||||
|
* some counterparties cannot be deleted because they sent a notif tx onchain, so we just mark them as hidden when user deletes
|
||||||
|
*/
|
||||||
|
hidden?: boolean;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -634,6 +634,7 @@
|
||||||
"pay_this_contact": "Pay this contact",
|
"pay_this_contact": "Pay this contact",
|
||||||
"rename_contact": "Rename contact",
|
"rename_contact": "Rename contact",
|
||||||
"copy_payment_code": "Copy Payment Code",
|
"copy_payment_code": "Copy Payment Code",
|
||||||
|
"hide_contact": "Hide contact",
|
||||||
"rename": "Rename",
|
"rename": "Rename",
|
||||||
"provide_name": "Provide new name for this contact",
|
"provide_name": "Provide new name for this contact",
|
||||||
"add_contact": "Add Contact",
|
"add_contact": "Add Contact",
|
||||||
|
|
|
@ -34,6 +34,7 @@ enum Actions {
|
||||||
pay,
|
pay,
|
||||||
rename,
|
rename,
|
||||||
copyToClipboard,
|
copyToClipboard,
|
||||||
|
hide,
|
||||||
}
|
}
|
||||||
|
|
||||||
const actionKeys: Action[] = [
|
const actionKeys: Action[] = [
|
||||||
|
@ -61,6 +62,14 @@ const actionKeys: Action[] = [
|
||||||
iconValue: 'doc.on.doc',
|
iconValue: 'doc.on.doc',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: Actions.hide,
|
||||||
|
text: loc.bip47.hide_contact,
|
||||||
|
icon: {
|
||||||
|
iconType: 'SYSTEM',
|
||||||
|
iconValue: 'eye.slash',
|
||||||
|
},
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
function onlyUnique(value: any, index: number, self: any[]) {
|
function onlyUnique(value: any, index: number, self: any[]) {
|
||||||
|
@ -160,6 +169,17 @@ export default function PaymentCodesList() {
|
||||||
|
|
||||||
_navigateToSend(pc);
|
_navigateToSend(pc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (String(id) === String(Actions.hide)) {
|
||||||
|
if (!(await confirm(loc.wallets.details_are_you_sure))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
counterpartyMetadata[pc] = { label: counterpartyMetadata?.[pc]?.label ?? '', hidden: true };
|
||||||
|
|
||||||
|
setReload(Math.random());
|
||||||
|
await saveToDisk();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const _navigateToSend = (pc: string) => {
|
const _navigateToSend = (pc: string) => {
|
||||||
|
@ -176,6 +196,8 @@ export default function PaymentCodesList() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderItem = (pc: string) => {
|
const renderItem = (pc: string) => {
|
||||||
|
if (counterpartyMetadata?.[pc]?.hidden) return null; // hidden contact, do not render
|
||||||
|
|
||||||
const color = createHash('sha256').update(pc).digest().toString('hex').substring(0, 6);
|
const color = createHash('sha256').update(pc).digest().toString('hex').substring(0, 6);
|
||||||
|
|
||||||
const displayName = shortenContactName(counterpartyMetadata?.[pc]?.label ?? pc);
|
const displayName = shortenContactName(counterpartyMetadata?.[pc]?.label ?? pc);
|
||||||
|
@ -229,6 +251,14 @@ export default function PaymentCodesList() {
|
||||||
const foundWallet = wallets.find(w => w.getID() === walletID) as unknown as HDSegwitBech32Wallet;
|
const foundWallet = wallets.find(w => w.getID() === walletID) as unknown as HDSegwitBech32Wallet;
|
||||||
assert(foundWallet, 'Internal error: cant find walletID ' + walletID);
|
assert(foundWallet, 'Internal error: cant find walletID ' + walletID);
|
||||||
|
|
||||||
|
if (counterpartyMetadata[newPc]?.hidden) {
|
||||||
|
// contact already present, just need to unhide it
|
||||||
|
counterpartyMetadata[newPc].hidden = false;
|
||||||
|
await saveToDisk();
|
||||||
|
setReload(Math.random());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const cl = new ContactList();
|
const cl = new ContactList();
|
||||||
|
|
||||||
if (!cl.isPaymentCodeValid(newPc)) {
|
if (!cl.isPaymentCodeValid(newPc)) {
|
||||||
|
@ -302,6 +332,7 @@ export default function PaymentCodesList() {
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
setLoadingText('Fetching transactions...');
|
setLoadingText('Fetching transactions...');
|
||||||
await foundWallet.fetchTransactions();
|
await foundWallet.fetchTransactions();
|
||||||
|
setLoadingText('');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue