From 8123ef708b7a78fa3263802ce7bb7d141d87b1d8 Mon Sep 17 00:00:00 2001
From: Bruno Muniz Azevedo Filho <bruno@elixxir.io>
Date: Wed, 17 Aug 2022 16:10:17 -0300
Subject: [PATCH] Ignoring cache for banned list

---
 Sources/Integration/Session/Session+Contacts.swift         | 3 +--
 Sources/ReportingFeature/FetchBannedList.swift             | 3 ++-
 Sources/SearchFeature/ViewModels/SearchLeftViewModel.swift | 4 +++-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/Sources/Integration/Session/Session+Contacts.swift b/Sources/Integration/Session/Session+Contacts.swift
index 3a462dbe..d30f78c2 100644
--- a/Sources/Integration/Session/Session+Contacts.swift
+++ b/Sources/Integration/Session/Session+Contacts.swift
@@ -244,7 +244,6 @@ extension Session {
         ///
         //try dbManager.deleteContact(contact)
 
-        _ = try? dbManager.deleteMessages(Message.Query(chat: .direct(myId, contact.id)))
         var contact = contact
         contact.email = nil
         contact.phone = nil
@@ -254,6 +253,6 @@ extension Session {
         contact.isBlocked = true
         contact.authStatus = .stranger
         contact.nickname = contact.username
-        _ = try? dbManager.saveContact(contact)
+        _ = try! dbManager.saveContact(contact)
     }
 }
diff --git a/Sources/ReportingFeature/FetchBannedList.swift b/Sources/ReportingFeature/FetchBannedList.swift
index 55617df4..4ab2b3ee 100644
--- a/Sources/ReportingFeature/FetchBannedList.swift
+++ b/Sources/ReportingFeature/FetchBannedList.swift
@@ -20,7 +20,8 @@ extension FetchBannedList {
     public static let live = FetchBannedList { completion in
         let url = URL(string: "https://elixxir-bins.s3.us-west-1.amazonaws.com/client/bannedUsers/bannedTesting.csv")!
         let session = URLSession.shared
-        let task = session.dataTask(with: url) { data, response, error in
+        let request = URLRequest(url: url, cachePolicy: .reloadIgnoringLocalAndRemoteCacheData)
+        let task = session.dataTask(with: request) { data, response, error in
             if let error = error {
                 completion(.failure(.network(error as! URLError)))
                 return
diff --git a/Sources/SearchFeature/ViewModels/SearchLeftViewModel.swift b/Sources/SearchFeature/ViewModels/SearchLeftViewModel.swift
index 4f7aa6ef..d5ea157d 100644
--- a/Sources/SearchFeature/ViewModels/SearchLeftViewModel.swift
+++ b/Sources/SearchFeature/ViewModels/SearchLeftViewModel.swift
@@ -144,7 +144,9 @@ final class SearchLeftViewModel {
         var snapshot = SearchSnapshot()
 
         if var user = user {
-            if let contact = try? session.dbManager.fetchContacts(.init(id: [user.id])).first {
+            if let contact = try! session.dbManager.fetchContacts(.init(id: [user.id])).first {
+                user.isBanned = contact.isBanned
+                user.isBlocked = contact.isBlocked
                 user.authStatus = contact.authStatus
             }
 
-- 
GitLab