Improvements on home timeline.
This commit is contained in:
parent
cb4475dc59
commit
709888a560
|
@ -15,6 +15,6 @@ public class ErrorService {
|
|||
ToastrService.shared.showError(subtitle: message)
|
||||
}
|
||||
|
||||
print("Error: \(error.localizedDescription)")
|
||||
print("Error ['\(message)']: \(error.localizedDescription)")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -157,6 +157,7 @@ struct HomeFeedView: View {
|
|||
|
||||
// View is scrolled so high that we can hide view.
|
||||
if offset > 170 {
|
||||
self.applicationState.amountOfNewStatuses = 0
|
||||
self.hideNewStatusesView()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,6 +19,7 @@ struct ImageRow: View {
|
|||
@State private var uiImage:UIImage?
|
||||
@State private var showThumbImage = false
|
||||
@State private var error: Error?
|
||||
@State private var cancelled = true
|
||||
|
||||
init(statusData: StatusData) {
|
||||
self.status = statusData
|
||||
|
@ -92,13 +93,19 @@ struct ImageRow: View {
|
|||
}
|
||||
.frame(width: self.imageWidth, height: self.imageHeight)
|
||||
} else {
|
||||
if let error {
|
||||
if cancelled {
|
||||
BlurredImage(blurhash: attachmentData.blurhash)
|
||||
.frame(width: self.imageWidth, height: self.imageHeight)
|
||||
.task {
|
||||
await self.downloadImage(attachmentData: attachmentData)
|
||||
}
|
||||
}
|
||||
else if let error {
|
||||
ZStack {
|
||||
BlurredImage(blurhash: attachmentData.blurhash)
|
||||
.frame(width: self.imageWidth, height: self.imageHeight)
|
||||
|
||||
ErrorView(error: error) {
|
||||
self.error = nil
|
||||
await self.downloadImage(attachmentData: attachmentData)
|
||||
}
|
||||
.padding()
|
||||
|
@ -130,10 +137,17 @@ struct ImageRow: View {
|
|||
self.uiImage = downloadedImage
|
||||
|
||||
HomeTimelineService.shared.update(attachment: attachmentData, withData: imageData, imageWidth: size.width, imageHeight: size.height)
|
||||
self.error = nil
|
||||
self.cancelled = false
|
||||
}
|
||||
} catch {
|
||||
ErrorService.shared.handle(error, message: "Cannot download the image.")
|
||||
self.error = error
|
||||
if !Task.isCancelled {
|
||||
ErrorService.shared.handle(error, message: "Cannot download the image.")
|
||||
self.error = error
|
||||
} else {
|
||||
ErrorService.shared.handle(error, message: "Download image has been canceled.")
|
||||
self.cancelled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue