mirror of
https://github.com/yattee/yattee.git
synced 2025-08-05 02:04:07 +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 {
|
||||
|
@@ -61,7 +61,8 @@ struct ChannelListItem: View {
|
||||
private var label: some View {
|
||||
HStack(alignment: .top, spacing: 12) {
|
||||
VStack {
|
||||
ChannelAvatarView(channel: channel)
|
||||
ChannelAvatarView(channel: channel, subscribedBadge: false)
|
||||
.id("channel-avatar-\(channel.id)")
|
||||
#if os(tvOS)
|
||||
.frame(width: 90, height: 90)
|
||||
#else
|
||||
|
@@ -205,6 +205,7 @@ struct ChannelVideosView: View {
|
||||
|
||||
var thumbnail: some View {
|
||||
ChannelAvatarView(channel: store.item?.channel)
|
||||
.id("channel-avatar-\(store.item?.channel?.id ?? "")")
|
||||
#if os(tvOS)
|
||||
.frame(width: 80, height: 80, alignment: .trailing)
|
||||
#else
|
||||
|
Reference in New Issue
Block a user