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)
|
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.
|
// View is scrolled so high that we can hide view.
|
||||||
if offset > 170 {
|
if offset > 170 {
|
||||||
|
self.applicationState.amountOfNewStatuses = 0
|
||||||
self.hideNewStatusesView()
|
self.hideNewStatusesView()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ struct ImageRow: View {
|
||||||
@State private var uiImage:UIImage?
|
@State private var uiImage:UIImage?
|
||||||
@State private var showThumbImage = false
|
@State private var showThumbImage = false
|
||||||
@State private var error: Error?
|
@State private var error: Error?
|
||||||
|
@State private var cancelled = true
|
||||||
|
|
||||||
init(statusData: StatusData) {
|
init(statusData: StatusData) {
|
||||||
self.status = statusData
|
self.status = statusData
|
||||||
|
@ -92,13 +93,19 @@ struct ImageRow: View {
|
||||||
}
|
}
|
||||||
.frame(width: self.imageWidth, height: self.imageHeight)
|
.frame(width: self.imageWidth, height: self.imageHeight)
|
||||||
} else {
|
} 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 {
|
ZStack {
|
||||||
BlurredImage(blurhash: attachmentData.blurhash)
|
BlurredImage(blurhash: attachmentData.blurhash)
|
||||||
.frame(width: self.imageWidth, height: self.imageHeight)
|
.frame(width: self.imageWidth, height: self.imageHeight)
|
||||||
|
|
||||||
ErrorView(error: error) {
|
ErrorView(error: error) {
|
||||||
self.error = nil
|
|
||||||
await self.downloadImage(attachmentData: attachmentData)
|
await self.downloadImage(attachmentData: attachmentData)
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
|
@ -130,10 +137,17 @@ struct ImageRow: View {
|
||||||
self.uiImage = downloadedImage
|
self.uiImage = downloadedImage
|
||||||
|
|
||||||
HomeTimelineService.shared.update(attachment: attachmentData, withData: imageData, imageWidth: size.width, imageHeight: size.height)
|
HomeTimelineService.shared.update(attachment: attachmentData, withData: imageData, imageWidth: size.width, imageHeight: size.height)
|
||||||
|
self.error = nil
|
||||||
|
self.cancelled = false
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
|
if !Task.isCancelled {
|
||||||
ErrorService.shared.handle(error, message: "Cannot download the image.")
|
ErrorService.shared.handle(error, message: "Cannot download the image.")
|
||||||
self.error = error
|
self.error = error
|
||||||
|
} else {
|
||||||
|
ErrorService.shared.handle(error, message: "Download image has been canceled.")
|
||||||
|
self.cancelled = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue