mirror of
https://github.com/yattee/yattee.git
synced 2025-10-11 01:48:12 +00:00
Channels performance improvements
Add settings: Show channel avatars in channels lists Show channel avatars in videos lists Fix #508
This commit is contained in:
@@ -9,11 +9,13 @@ struct ChannelAvatarView: View {
|
||||
@ObservedObject private var accounts = AccountsModel.shared
|
||||
@ObservedObject private var subscribedChannels = SubscribedChannelsModel.shared
|
||||
|
||||
@State private var url: URL?
|
||||
|
||||
var body: some View {
|
||||
ZStack(alignment: .bottomTrailing) {
|
||||
Group {
|
||||
Group {
|
||||
if let url = channel?.thumbnailURLOrCached {
|
||||
if let url {
|
||||
ThumbnailView(url: url)
|
||||
} else {
|
||||
ZStack {
|
||||
@@ -31,6 +33,7 @@ struct ChannelAvatarView: View {
|
||||
.font(.system(size: 20))
|
||||
.contentShape(Rectangle())
|
||||
}
|
||||
.onAppear(perform: updateURL)
|
||||
}
|
||||
}
|
||||
.clipShape(Circle())
|
||||
@@ -54,6 +57,16 @@ struct ChannelAvatarView: View {
|
||||
}
|
||||
.imageScale(.small)
|
||||
}
|
||||
|
||||
func updateURL() {
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
if let url = channel?.thumbnailURLOrCached {
|
||||
DispatchQueue.main.async {
|
||||
self.url = url
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct ChannelAvatarView_Previews: PreviewProvider {
|
||||
|
Reference in New Issue
Block a user