mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2024-11-19 01:40:12 +01:00
Update CompanionDelegates.tsx
This commit is contained in:
parent
a8674aed0e
commit
ae15a4a77f
@ -53,6 +53,7 @@ const CompanionDelegates = () => {
|
||||
const notifications2process = await getStoredNotifications();
|
||||
await clearStoredNotifications();
|
||||
await setApplicationIconBadgeNumber(0);
|
||||
|
||||
const deliveredNotifications = await getDeliveredNotifications();
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
@ -61,63 +62,110 @@ const CompanionDelegates = () => {
|
||||
console.error('Failed to remove delivered notifications:', error);
|
||||
}
|
||||
}, 5000);
|
||||
return notifications2process;
|
||||
} catch (error) {
|
||||
console.error('Failed to process notifications:', error);
|
||||
return [];
|
||||
}
|
||||
|
||||
for (const payload of notifications2process) {
|
||||
const wasTapped = payload.foreground === false || (payload.foreground === true && payload.userInteraction);
|
||||
// Process notifications
|
||||
for (const payload of notifications2process) {
|
||||
const wasTapped = payload.foreground === false || (payload.foreground === true && payload.userInteraction);
|
||||
|
||||
console.log('processing push notification:', payload);
|
||||
let wallet;
|
||||
switch (+payload.type) {
|
||||
case 2:
|
||||
case 3:
|
||||
wallet = wallets.find(w => w.weOwnAddress(payload.address));
|
||||
break;
|
||||
case 1:
|
||||
case 4:
|
||||
wallet = wallets.find(w => w.weOwnTransaction(payload.txid || payload.hash));
|
||||
break;
|
||||
}
|
||||
console.log('processing push notification:', payload);
|
||||
let wallet;
|
||||
switch (+payload.type) {
|
||||
case 2:
|
||||
case 3:
|
||||
wallet = wallets.find(w => w.weOwnAddress(payload.address));
|
||||
break;
|
||||
case 1:
|
||||
case 4:
|
||||
wallet = wallets.find(w => w.weOwnTransaction(payload.txid || payload.hash));
|
||||
break;
|
||||
}
|
||||
|
||||
if (wallet) {
|
||||
const walletID = wallet.getID();
|
||||
fetchAndSaveWalletTransactions(walletID);
|
||||
if (wasTapped) {
|
||||
if (payload.type !== 3 || wallet.chain === Chain.OFFCHAIN) {
|
||||
navigationRef.dispatch(
|
||||
CommonActions.navigate({
|
||||
name: 'WalletTransactions',
|
||||
if (wallet) {
|
||||
const walletID = wallet.getID();
|
||||
fetchAndSaveWalletTransactions(walletID);
|
||||
if (wasTapped) {
|
||||
if (payload.type !== 3 || wallet.chain === Chain.OFFCHAIN) {
|
||||
navigationRef.dispatch(
|
||||
CommonActions.navigate({
|
||||
name: 'WalletTransactions',
|
||||
params: {
|
||||
walletID,
|
||||
walletType: wallet.type,
|
||||
},
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
navigationRef.navigate('ReceiveDetailsRoot', {
|
||||
screen: 'ReceiveDetails',
|
||||
params: {
|
||||
walletID,
|
||||
walletType: wallet.type,
|
||||
address: payload.address,
|
||||
},
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
navigationRef.navigate('ReceiveDetailsRoot', {
|
||||
screen: 'ReceiveDetails',
|
||||
params: {
|
||||
walletID,
|
||||
address: payload.address,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
console.log('could not find wallet while processing push notification, NOP');
|
||||
}
|
||||
}
|
||||
|
||||
if (deliveredNotifications.length > 0) {
|
||||
for (const payload of deliveredNotifications) {
|
||||
const wasTapped = payload.foreground === false || (payload.foreground === true && payload.userInteraction);
|
||||
|
||||
console.log('processing push notification:', payload);
|
||||
let wallet;
|
||||
switch (+payload.type) {
|
||||
case 2:
|
||||
case 3:
|
||||
wallet = wallets.find(w => w.weOwnAddress(payload.address));
|
||||
break;
|
||||
case 1:
|
||||
case 4:
|
||||
wallet = wallets.find(w => w.weOwnTransaction(payload.txid || payload.hash));
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
if (wallet) {
|
||||
const walletID = wallet.getID();
|
||||
fetchAndSaveWalletTransactions(walletID);
|
||||
if (wasTapped) {
|
||||
if (payload.type !== 3 || wallet.chain === Chain.OFFCHAIN) {
|
||||
navigationRef.dispatch(
|
||||
CommonActions.navigate({
|
||||
name: 'WalletTransactions',
|
||||
params: {
|
||||
walletID,
|
||||
walletType: wallet.type,
|
||||
},
|
||||
}),
|
||||
);
|
||||
} else {
|
||||
navigationRef.navigate('ReceiveDetailsRoot', {
|
||||
screen: 'ReceiveDetails',
|
||||
params: {
|
||||
walletID,
|
||||
address: payload.address,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
console.log('could not find wallet while processing push notification, NOP');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
console.log('could not find wallet while processing push notification, NOP');
|
||||
}
|
||||
}
|
||||
|
||||
if (deliveredNotifications.length > 0) {
|
||||
refreshAllWalletTransactions();
|
||||
if (deliveredNotifications.length > 0) {
|
||||
refreshAllWalletTransactions();
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to process push notifications:', error);
|
||||
}
|
||||
|
||||
return false;
|
||||
}, [fetchAndSaveWalletTransactions, refreshAllWalletTransactions, wallets]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user