From d102e090ead366e836759eef6b5d4eabcc2d7321 Mon Sep 17 00:00:00 2001 From: Nathan Mattes Date: Thu, 15 Dec 2022 21:11:14 +0100 Subject: [PATCH] Download thumbnails (#690) --- .../Scene/Onboarding/PickServer/PickServerSection.swift | 8 +++++++- .../PickServer/TableViewCell/PickServerCell.swift | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Mastodon/Scene/Onboarding/PickServer/PickServerSection.swift b/Mastodon/Scene/Onboarding/PickServer/PickServerSection.swift index d32b5beb6..4cce243f0 100644 --- a/Mastodon/Scene/Onboarding/PickServer/PickServerSection.swift +++ b/Mastodon/Scene/Onboarding/PickServer/PickServerSection.swift @@ -63,7 +63,13 @@ extension PickServerSection { ] ) }() - + if let proxiedThumbnail = server.proxiedThumbnail, let thumbnailUrl = URL(string: proxiedThumbnail) { + cell.thumbnailImageView.af.setImage(withURL: thumbnailUrl) { _ in + OperationQueue.main.addOperation { + cell.thumbnailImageView.isHidden = false + } + } + } attribute.isLast .receive(on: DispatchQueue.main) .sink { [weak cell] isLast in diff --git a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift index 554fc6070..882f8c44f 100644 --- a/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift +++ b/Mastodon/Scene/Onboarding/PickServer/TableViewCell/PickServerCell.swift @@ -31,6 +31,8 @@ class PickServerCell: UITableViewCell { thumbnail.translatesAutoresizingMaskIntoConstraints = false thumbnail.backgroundColor = Asset.Colors.brand.color thumbnail.layer.cornerRadius = 8 + thumbnail.contentMode = .scaleAspectFill + thumbnail.layer.masksToBounds = true return thumbnail }() @@ -66,7 +68,8 @@ class PickServerCell: UITableViewCell { override func prepareForReuse() { super.prepareForReuse() - + thumbnailImageView.isHidden = true + thumbnailImageView.image = nil disposeBag.removeAll() }