Respond to CR.

This commit is contained in:
Matthew Chen 2018-11-15 14:05:08 -05:00
parent 8b24fba095
commit 8eb2550e0c
3 changed files with 7 additions and 8 deletions

View File

@ -241,12 +241,12 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
isInBatchSelectMode = true
for attachment in attachments {
guard let assetId = attachment.sourceId else {
guard let assetId = attachment.assetId else {
owsFailDebug("Attachment is missing asset id.")
continue
}
// Link the attachment with its asset to ensure caption continuity.
attachment.sourceId = assetId
attachment.assetId = assetId
// Restore any existing caption for this attachment.
attachment.captionText = assetIdToCommentMap[assetId]
}
@ -349,7 +349,6 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
if isInBatchSelectMode {
updateDoneButton()
} else {
let asset = photoCollectionContents.asset(at: indexPath.row)
complete(withAssets: [asset])
}
}
@ -404,7 +403,7 @@ class ImagePickerGridController: UICollectionViewController, PhotoLibraryDelegat
func attachmentApproval(_ attachmentApproval: AttachmentApprovalViewController, changedCaptionOfAttachment attachment: SignalAttachment) {
AssertIsOnMainThread()
guard let assetId = attachment.sourceId else {
guard let assetId = attachment.assetId else {
owsFailDebug("Attachment missing source id.")
return
}

View File

@ -151,13 +151,13 @@ class PhotoCollectionContents {
case .image:
return requestImageDataSource(for: asset).map { (dataSource: DataSource, dataUTI: String) in
let attachment = SignalAttachment.attachment(dataSource: dataSource, dataUTI: dataUTI, imageQuality: .medium)
attachment.sourceId = asset.localIdentifier
attachment.assetId = asset.localIdentifier
return attachment
}
case .video:
return requestVideoDataSource(for: asset).map { (dataSource: DataSource, dataUTI: String) in
let attachment = SignalAttachment.attachment(dataSource: dataSource, dataUTI: dataUTI)
attachment.sourceId = asset.localIdentifier
attachment.assetId = asset.localIdentifier
return attachment
}
default:

View File

@ -160,9 +160,9 @@ public class SignalAttachment: NSObject {
@objc
public let dataUTI: String
// Can be used by views to link this SignalAttachment with an arbitrary source.
// Can be used by views to link this SignalAttachment with an Photos framework asset.
@objc
public var sourceId: String?
public var assetId: String?
var error: SignalAttachmentError? {
didSet {