From e3e5a99bd25f4cf39f206d6f4278e7464accb4f1 Mon Sep 17 00:00:00 2001 From: Krzysztof Jan Modras Date: Fri, 23 Aug 2019 10:10:38 +0200 Subject: [PATCH] Fix: prevent crashes on history deletion - fixes CLIQZ-IOS-1655 (#455) --- Client/Frontend/Home/HistoryPanel.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Client/Frontend/Home/HistoryPanel.swift b/Client/Frontend/Home/HistoryPanel.swift index 44f579ac5..b0b86dd9f 100644 --- a/Client/Frontend/Home/HistoryPanel.swift +++ b/Client/Frontend/Home/HistoryPanel.swift @@ -225,18 +225,19 @@ class HistoryPanel: SiteTableViewController, HomePanel { guard let site = siteForIndexPath(indexPath) else { return } - profile.history.removeHistoryForURL(site.url).uponQueue(.main) { result in } - /* Cliqz: system is expecting tableview to perform delete operation with in the same RunLoop, that's why we moved the deletion out of asynchronous callback to fix the animation issue. + profile.history.removeHistoryForURL(site.url).uponQueue(.main) { result in - */ + guard site == self.siteForIndexPath(indexPath) else { + self.reloadData() + return + } + self.tableView.beginUpdates() self.groupedSites.remove(site) self.tableView.deleteRows(at: [indexPath], with: .right) self.tableView.endUpdates() self.updateEmptyPanelState() - /* } - */ } func pinToTopSites(_ site: Site) {