Channels performance improvements

Add settings:
Show channel avatars in channels lists
Show channel avatars in videos lists

Fix #508
This commit is contained in:
Arkadiusz Fal
2023-07-22 19:02:59 +02:00
parent 37a96a01db
commit 3c9e04d243
14 changed files with 81 additions and 71 deletions

View File

@@ -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 {