From 536fe057cfec38cf57958f5bf379f7cc4aeaad95 Mon Sep 17 00:00:00 2001 From: Denis Date: Thu, 11 Jun 2020 14:42:44 +0300 Subject: [PATCH] delete notification when address/transaction is deleted --- BeamWallet.xcodeproj/project.pbxproj | 4 ++-- BeamWallet/BeamSDK/AppModel.mm | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/BeamWallet.xcodeproj/project.pbxproj b/BeamWallet.xcodeproj/project.pbxproj index 3cbd1f67..e6159627 100644 --- a/BeamWallet.xcodeproj/project.pbxproj +++ b/BeamWallet.xcodeproj/project.pbxproj @@ -4204,7 +4204,7 @@ CLANG_WARN_ENUM_CONVERSION = NO; CODE_SIGN_ENTITLEMENTS = Resources/BeamWallet.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; DEVELOPMENT_TEAM = KNU2R94BJK; ENABLE_BITCODE = NO; @@ -4286,7 +4286,7 @@ CLANG_WARN_ENUM_CONVERSION = NO; CODE_SIGN_ENTITLEMENTS = Resources/BeamWallet.entitlements; CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 7; + CURRENT_PROJECT_VERSION = 8; DEVELOPMENT_TEAM = KNU2R94BJK; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( diff --git a/BeamWallet/BeamSDK/AppModel.mm b/BeamWallet/BeamSDK/AppModel.mm index c175df96..77cc11f8 100644 --- a/BeamWallet/BeamSDK/AppModel.mm +++ b/BeamWallet/BeamSDK/AppModel.mm @@ -1038,6 +1038,11 @@ -(void)deleteAddress:(NSString*_Nullable)address { if (walletID.FromHex(address.string)) { wallet->getAsync()->deleteAddress(walletID); + + NSString *notificationId = [self getNotificationByObject:address]; + if (notificationId!=nil) { + [self deleteNotification:notificationId]; + } } } @@ -1871,6 +1876,11 @@ -(void)deleteTransaction:(NSString*_Nonnull)ID { } wallet->getAsync()->deleteTx([self txIDfromString:ID]); + + NSString *notificationId = [self getNotificationByObject:ID]; + if (notificationId!=nil) { + [self deleteNotification:notificationId]; + } } -(void)cancelDeleteTransaction:(NSString*_Nonnull)ID { @@ -2658,6 +2668,17 @@ -(void)readNotificationByObject:(NSString*_Nonnull) objectId { } } +-(NSString*_Nullable)getNotificationByObject:(NSString*_Nonnull) objectId { + NSMutableArray *notifications = [NSMutableArray arrayWithArray:_notifications]; + for (BMNotification *notification in notifications) { + if([notification.pId isEqualToString:objectId]) { + return notification.nId; + } + } + + return nil; +} + -(void)deleteNotification:(NSString*_Nonnull) notifId { auto buffer = from_hex(notifId.string); Blob rawData(buffer.data(), static_cast(buffer.size()));