From 1bb8d5ea966a82f477fc19d51a278a9c8352c841 Mon Sep 17 00:00:00 2001 From: Levitating Pineapple Date: Fri, 30 Aug 2024 22:23:53 +0300 Subject: [PATCH] background date visibility --- apps/ios/Shared/Views/Chat/ChatView.swift | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/ios/Shared/Views/Chat/ChatView.swift b/apps/ios/Shared/Views/Chat/ChatView.swift index 6dc88d21cc..b84fb55adb 100644 --- a/apps/ios/Shared/Views/Chat/ChatView.swift +++ b/apps/ios/Shared/Views/Chat/ChatView.swift @@ -519,14 +519,20 @@ struct ChatView: View { } private func setDate(visibility isVisible: Bool) { - if isVisible { - if !isNearBottom, - !isDateVisible, - let date, !Calendar.current.isDateInToday(date) { - withAnimation { isDateVisible = true } + Task { + if isVisible { + if !isNearBottom, + !isDateVisible, + let date, !Calendar.current.isDateInToday(date) { + await MainActor.run { + withAnimation { isDateVisible = true } + } + } + } else if isDateVisible { + await MainActor.run { + withAnimation { isDateVisible = false } + } } - } else if isDateVisible { - withAnimation { isDateVisible = false } } }