From 7cec64fc9a416f782237920dfd457cdcebd10dd8 Mon Sep 17 00:00:00 2001 From: cranci1 <100066266+cranci1@users.noreply.github.com> Date: Tue, 31 Dec 2024 09:07:41 +0100 Subject: [PATCH] fixed main thread issue --- Sora/Utils/History/HistoryManager.swift | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sora/Utils/History/HistoryManager.swift b/Sora/Utils/History/HistoryManager.swift index dd353fd..cbc7fe2 100644 --- a/Sora/Utils/History/HistoryManager.swift +++ b/Sora/Utils/History/HistoryManager.swift @@ -16,7 +16,9 @@ class HistoryManager: ObservableObject { init() { NotificationCenter.default.publisher(for: UserDefaults.didChangeNotification) .sink { [weak self] _ in - self?.searchHistory = UserDefaults.standard.stringArray(forKey: "SearchHistory") ?? [] + DispatchQueue.main.async { + self?.searchHistory = UserDefaults.standard.stringArray(forKey: "SearchHistory") ?? [] + } } .store(in: &cancellables) }