Fix crash tapping attachments on instance public timelines
This commit is contained in:
parent
7999ecafd0
commit
b94bfca406
|
@ -12,7 +12,7 @@ import Gifu
|
||||||
import AVFoundation
|
import AVFoundation
|
||||||
|
|
||||||
protocol AttachmentViewDelegate: class {
|
protocol AttachmentViewDelegate: class {
|
||||||
func attachmentViewGallery(startingAt index: Int) -> UIViewController
|
func attachmentViewGallery(startingAt index: Int) -> UIViewController?
|
||||||
func attachmentViewPresent(_ vc: UIViewController, animated: Bool)
|
func attachmentViewPresent(_ vc: UIViewController, animated: Bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,8 +230,8 @@ class AttachmentView: UIImageView, GIFAnimatable {
|
||||||
}
|
}
|
||||||
|
|
||||||
func showGallery() {
|
func showGallery() {
|
||||||
if let delegate = delegate {
|
if let delegate = delegate,
|
||||||
let gallery = delegate.attachmentViewGallery(startingAt: index)
|
let gallery = delegate.attachmentViewGallery(startingAt: index) {
|
||||||
delegate.attachmentViewPresent(gallery, animated: true)
|
delegate.attachmentViewPresent(gallery, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -384,8 +384,8 @@ class AttachmentsContainerView: UIView {
|
||||||
@objc func moreViewTapped() {
|
@objc func moreViewTapped() {
|
||||||
guard attachments.count > 4 else { return }
|
guard attachments.count > 4 else { return }
|
||||||
// the more view shows up in place of the fourth attachemtn view, show tapping it should start at the fourth attachment
|
// the more view shows up in place of the fourth attachemtn view, show tapping it should start at the fourth attachment
|
||||||
if let delegate = delegate {
|
if let delegate = delegate,
|
||||||
let gallery = delegate.attachmentViewGallery(startingAt: 3)
|
let gallery = delegate.attachmentViewGallery(startingAt: 3) {
|
||||||
delegate.attachmentViewPresent(gallery, animated: true)
|
delegate.attachmentViewPresent(gallery, animated: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -366,10 +366,11 @@ class BaseStatusTableViewCell: UITableViewCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
extension BaseStatusTableViewCell: AttachmentViewDelegate {
|
extension BaseStatusTableViewCell: AttachmentViewDelegate {
|
||||||
func attachmentViewGallery(startingAt index: Int) -> UIViewController {
|
func attachmentViewGallery(startingAt index: Int) -> UIViewController? {
|
||||||
guard let status = mastodonController.persistentContainer.status(for: statusID) else { fatalError("Missing cached status \(statusID!)") }
|
guard let delegate = delegate,
|
||||||
|
let status = mastodonController.persistentContainer.status(for: statusID) else { return nil }
|
||||||
let sourceViews = status.attachments.map(attachmentsView.getAttachmentView(for:))
|
let sourceViews = status.attachments.map(attachmentsView.getAttachmentView(for:))
|
||||||
return delegate!.gallery(attachments: status.attachments, sourceViews: sourceViews, startIndex: index)
|
return delegate.gallery(attachments: status.attachments, sourceViews: sourceViews, startIndex: index)
|
||||||
}
|
}
|
||||||
|
|
||||||
func attachmentViewPresent(_ vc: UIViewController, animated: Bool) {
|
func attachmentViewPresent(_ vc: UIViewController, animated: Bool) {
|
||||||
|
|
Loading…
Reference in New Issue