From a5fa8d28e9c868f586ab9d6a0a549eb7f6621246 Mon Sep 17 00:00:00 2001 From: Ivan Stepanok Date: Fri, 21 Jul 2023 17:23:26 +0300 Subject: [PATCH] Hide no discussion while update --- .../Discussion/Presentation/Posts/PostsView.swift | 2 +- .../Presentation/Posts/PostsViewModel.swift | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Discussion/Discussion/Presentation/Posts/PostsView.swift b/Discussion/Discussion/Presentation/Posts/PostsView.swift index e3936c3b3..954891545 100644 --- a/Discussion/Discussion/Presentation/Posts/PostsView.swift +++ b/Discussion/Discussion/Presentation/Posts/PostsView.swift @@ -157,7 +157,7 @@ public struct PostsView: View { Spacer(minLength: 84) } } else { - if !viewModel.isShowProgress { + if !viewModel.fetchInProgress { VStack(spacing: 0) { CoreAssets.discussionIcon.swiftUIImage .renderingMode(.template) diff --git a/Discussion/Discussion/Presentation/Posts/PostsViewModel.swift b/Discussion/Discussion/Presentation/Posts/PostsViewModel.swift index 7d93b50cd..a618bdff9 100644 --- a/Discussion/Discussion/Presentation/Posts/PostsViewModel.swift +++ b/Discussion/Discussion/Presentation/Posts/PostsViewModel.swift @@ -176,9 +176,11 @@ public class PostsViewModel: ObservableObject { if index == filteredPosts.count - 3 { if totalPages != 1 { if nextPage <= totalPages { - _ = await getPosts(courseID: courseID, - pageNumber: self.nextPage, - withProgress: withProgress) + _ = await getPosts( + courseID: courseID, + pageNumber: self.nextPage, + withProgress: withProgress + ) } } } @@ -202,7 +204,6 @@ public class PostsViewModel: ObservableObject { if threads.threads.indices.contains(0) { self.totalPages = threads.threads[0].numPages self.nextPage += 1 - fetchInProgress = false } case .followingPosts: threads.threads += try await interactor @@ -214,7 +215,6 @@ public class PostsViewModel: ObservableObject { if threads.threads.indices.contains(0) { self.totalPages = threads.threads[0].numPages self.nextPage += 1 - fetchInProgress = false } case .nonCourseTopics: threads.threads += try await interactor @@ -226,7 +226,6 @@ public class PostsViewModel: ObservableObject { if threads.threads.indices.contains(0) { self.totalPages = threads.threads[0].numPages self.nextPage += 1 - fetchInProgress = false } case .courseTopics(topicID: let topicID): threads.threads += try await interactor @@ -238,7 +237,6 @@ public class PostsViewModel: ObservableObject { if threads.threads.indices.contains(0) { self.totalPages = threads.threads[0].numPages self.nextPage += 1 - fetchInProgress = false } case .none: isShowProgress = false @@ -248,9 +246,11 @@ public class PostsViewModel: ObservableObject { filteredPosts = discussionPosts self.filteredPosts = self.discussionPosts isShowProgress = false + fetchInProgress = false return true } catch let error { isShowProgress = false + fetchInProgress = false if error.isInternetError { errorMessage = CoreLocalization.Error.slowOrNoInternetConnection } else {