Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide the "no discussion" message while update #59

Merged
merged 1 commit into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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