mirror of
https://github.com/Ranchero-Software/NetNewsWire.git
synced 2024-12-24 00:30:51 +01:00
Make sure image loaders don't loop if onAppear gets repeatedly called
This commit is contained in:
parent
e7e3a0d5d7
commit
ee4d8b34b1
@ -23,6 +23,7 @@ final class ArticleIconImageLoader: ObservableObject {
|
||||
}
|
||||
|
||||
func loadImage(for article: Article) {
|
||||
guard image == nil else { return }
|
||||
self.article = article
|
||||
image = article.iconImage()
|
||||
}
|
||||
@ -50,7 +51,7 @@ private extension ArticleIconImageLoader {
|
||||
|
||||
for author in authors {
|
||||
if author.avatarURL == avatarURL {
|
||||
|
||||
image = article.iconImage()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
@ -21,8 +21,27 @@ final class FeedIconImageLoader: ObservableObject {
|
||||
}
|
||||
|
||||
func loadImage(for feed: Feed) {
|
||||
guard image == nil else { return }
|
||||
self.feed = feed
|
||||
|
||||
fetchImage()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension FeedIconImageLoader {
|
||||
|
||||
@objc func faviconDidBecomeAvailable(_ note: Notification) {
|
||||
fetchImage()
|
||||
}
|
||||
|
||||
@objc func webFeedIconDidBecomeAvailable(_ note: Notification) {
|
||||
guard let feed = feed as? WebFeed, let noteFeed = note.userInfo?[UserInfoKey.webFeed] as? WebFeed, feed == noteFeed else {
|
||||
return
|
||||
}
|
||||
fetchImage()
|
||||
}
|
||||
|
||||
func fetchImage() {
|
||||
if let webFeed = feed as? WebFeed {
|
||||
if let feedIconImage = appDelegate.webFeedIconDownloader.icon(for: webFeed) {
|
||||
image = feedIconImage
|
||||
@ -40,19 +59,3 @@ final class FeedIconImageLoader: ObservableObject {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private extension FeedIconImageLoader {
|
||||
|
||||
@objc func faviconDidBecomeAvailable(_ note: Notification) {
|
||||
guard let feed = feed else { return }
|
||||
loadImage(for: feed)
|
||||
}
|
||||
|
||||
@objc func webFeedIconDidBecomeAvailable(_ note: Notification) {
|
||||
guard let feed = feed as? WebFeed, let noteFeed = note.userInfo?[UserInfoKey.webFeed] as? WebFeed, feed == noteFeed else {
|
||||
return
|
||||
}
|
||||
loadImage(for: feed)
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ struct TimelineItemView: View {
|
||||
VStack {
|
||||
Text(verbatim: timelineItem.article.title ?? "N/A")
|
||||
.fontWeight(.semibold)
|
||||
.lineLimit(3)
|
||||
.lineLimit(AppDefaults.timelineNumberOfLines)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
.padding(.trailing, 4)
|
||||
Spacer()
|
||||
|
Loading…
Reference in New Issue
Block a user