Merge pull request #3765 from BlueWallet/fix-storage-issues

FIX: storage issues
This commit is contained in:
GLaDOS 2021-09-07 21:41:43 +01:00 committed by GitHub
commit b0da33182b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 2 deletions

4
App.js
View file

@ -190,6 +190,10 @@ const App = () => {
* @private
*/
const processPushNotifications = async () => {
if (!walletsInitialized) {
console.log('not processing push notifications because wallets are not initialized');
return;
}
await new Promise(resolve => setTimeout(resolve, 200));
// sleep needed as sometimes unsuspend is faster than notification module actually saves notifications to async storage
const notifications2process = await Notifications.getStoredNotifications();

View file

@ -60,6 +60,7 @@ function Notifications(props) {
if (notification.data && notification.data.data) Object.assign(payload, notification.data.data);
delete payload.data;
// ^^^ weird, but sometimes payload data is not in `data` but in root level
console.log('got push notification', payload);
await Notifications.addNotification(payload);

View file

@ -35,7 +35,11 @@ export const BlueStorageProvider = ({ children }) => {
return BlueApp.setIsHandoffEnabled(value);
};
const saveToDisk = async () => {
const saveToDisk = async (force = false) => {
if (BlueApp.getWallets().length === 0 && !force) {
console.log('not saving empty wallets array');
return;
}
BlueApp.tx_metadata = txMetadata;
await BlueApp.saveToDisk();
setWallets([...BlueApp.getWallets()]);

View file

@ -200,7 +200,7 @@ const WalletDetails = () => {
Notifications.unsubscribe(wallet.getAllExternalAddresses(), [], []);
popToTop();
deleteWallet(wallet);
saveToDisk();
saveToDisk(true);
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
};