Skip to content

Commit

Permalink
delete notification when address/transaction is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisDemyanko committed Jun 11, 2020
1 parent fc8fd5e commit 536fe05
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions BeamWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = (
Expand Down
21 changes: 21 additions & 0 deletions BeamWallet/BeamSDK/AppModel.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
}
}

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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<uint32_t>(buffer.size()));
Expand Down

0 comments on commit 536fe05

Please sign in to comment.