Skip to content

Commit

Permalink
Merge pull request #4049 from brave/ios-113-crash-fixes
Browse files Browse the repository at this point in the history
iOS Rewards Crash Fixes
  • Loading branch information
kylehickinson authored Nov 21, 2019
2 parents 17c2b70 + 4dff681 commit 99fe6b1
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions vendor/brave-ios/Ledger/BATBraveLedger.mm
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,10 @@ - (void)fetchPublisherActivityFromURL:(NSURL *)URL
publisherBlob:(nullable NSString *)publisherBlob
tabId:(uint64_t)tabId
{
if (!URL.absoluteString) {
return;
}

GURL parsedUrl(URL.absoluteString.UTF8String);

if (!parsedUrl.is_valid()) {
Expand All @@ -399,7 +403,7 @@ - (void)fetchPublisherActivityFromURL:(NSURL *)URL
visitData->path = parsedUrl.PathForRequest();
visitData->url = origin.spec();

if (faviconURL) {
if (faviconURL.absoluteString) {
visitData->favicon_url = std::string(faviconURL.absoluteString.UTF8String);
}

Expand All @@ -413,13 +417,18 @@ - (void)fetchPublisherActivityFromURL:(NSURL *)URL

- (void)deleteActivityInfo:(const std::string &)publisher_key callback:(ledger::DeleteActivityInfoCallback )callback
{
const auto bridgedKey = [NSString stringWithUTF8String:publisher_key.c_str()];
if (publisher_key.size() == 0) {
// Nothing to delete?
callback(ledger::Result::LEDGER_ERROR);
return;
}
const auto __block bridgedKey = [NSString stringWithUTF8String:publisher_key.c_str()];
const auto stamp = ledger->GetReconcileStamp();
[BATLedgerDatabase deleteActivityInfoWithPublisherID:bridgedKey reconcileStamp:stamp completion:^(BOOL success) {
if (success) {
for (BATBraveLedgerObserver *observer in [self.observers copy]) {
if (observer.activityRemoved) {
observer.activityRemoved([NSString stringWithUTF8String:publisher_key.c_str()]);
observer.activityRemoved(bridgedKey);
}
}
}
Expand Down

0 comments on commit 99fe6b1

Please sign in to comment.