Skip to content

Commit

Permalink
Hide no discussion while update (#59)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanStepanok authored Jul 21, 2023
1 parent 11f2aad commit f731d6d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Discussion/Discussion/Presentation/Posts/PostsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 7 additions & 7 deletions Discussion/Discussion/Presentation/Posts/PostsViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
}
}
}
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit f731d6d

Please sign in to comment.