This commit is contained in:
anlicheng 2025-02-19 22:23:07 +08:00
parent 42eca56b59
commit c5508bdf7c

View File

@ -88,6 +88,9 @@ struct IndexView: View {
// //
if offset + contentHeight > scrollViewHeight - 50 { if offset + contentHeight > scrollViewHeight - 50 {
print("call me here11") print("call me here11")
Task {
await self.loadMoreUpdateDramas()
}
} }
} }
@ -105,21 +108,26 @@ struct IndexView: View {
self.dramas = result.dramas self.dramas = result.dramas
self.showUpdateDramas = Self.yes(updateDramas: result.updateDramas) self.showUpdateDramas = Self.yes(updateDramas: result.updateDramas)
} }
} }
} }
private func loadMoreUpdateDramas() async { private func loadMoreUpdateDramas() async {
// guard !self.isLoading else { guard !self.isLoading else {
// return return
// } }
//
// self.isLoading = true
//
// if let data = await API.loadMoreUpdateDramas() {
// try! JSONDecoder().decode([UpdateDramaItem].self, from: data)
// }
self.isLoading = true
let response = await API.loadMoreUpdateDramas(as: [UpdateDramaItem].self)
if case let .result(items) = response {
let showItems = Self.yes(updateDramas: items)
self.showUpdateDramas.append(contentsOf: showItems)
}
self.isLoading = false
} }
private func addItem() { private func addItem() {