parent
6fafdf270c
commit
451e629605
|
@ -382,8 +382,15 @@ public final class OpenGroupAPI : DotNetAPI {
|
|||
var sanitizedProfilePictureURL = profilePictureURL
|
||||
while sanitizedProfilePictureURL.hasPrefix("/") { sanitizedProfilePictureURL.removeFirst() }
|
||||
let url = "\(sanitizedServerURL)/\(sanitizedProfilePictureURL)"
|
||||
FileServerAPI.downloadAttachment(from: url).map2 { data in
|
||||
let attachmentStream = TSAttachmentStream(contentType: OWSMimeTypeImageJpeg, byteCount: UInt32(data.count), sourceFilename: nil, caption: nil, albumMessageId: nil)
|
||||
FileServerAPI.downloadAttachment(from: url).map2 { rawData in
|
||||
let attachmentStream: TSAttachmentStream
|
||||
let data: Data
|
||||
if let rawImage = UIImage(data: rawData), let jpegData = rawImage.jpegData(compressionQuality: 0.8) {
|
||||
data = jpegData
|
||||
} else {
|
||||
data = rawData
|
||||
}
|
||||
attachmentStream = TSAttachmentStream(contentType: OWSMimeTypeImageJpeg, byteCount: UInt32(data.count), sourceFilename: nil, caption: nil, albumMessageId: nil)
|
||||
try attachmentStream.write(data)
|
||||
thread.updateAvatar(with: attachmentStream)
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ private struct OWSThumbnailRequest {
|
|||
throw OWSThumbnailError.failure(description: "Could not convert thumbnail to JPEG.")
|
||||
}
|
||||
do {
|
||||
try thumbnailData.write(to: URL(fileURLWithPath: thumbnailPath), options: .atomicWrite)
|
||||
try thumbnailData.write(to: URL(fileURLWithPath: thumbnailPath, isDirectory: false), options: .atomic)
|
||||
} catch let error as NSError {
|
||||
throw OWSThumbnailError.externalError(description: "File write failed: \(thumbnailPath), \(error)", underlyingError: error)
|
||||
}
|
||||
|
|
|
@ -60,11 +60,7 @@ public final class ProfilePictureView : UIView {
|
|||
public func update(for thread: TSThread) {
|
||||
openGroupProfilePicture = nil
|
||||
if let thread = thread as? TSGroupThread {
|
||||
if thread.name() == "Loki Public Chat"
|
||||
|| thread.name() == "Session Public Chat" { // Override the profile picture for the Loki Public Chat and the Session Public Chat
|
||||
hexEncodedPublicKey = ""
|
||||
isRSSFeed = true
|
||||
} else if let openGroupProfilePicture = thread.groupModel.groupImage { // An open group with a profile picture
|
||||
if let openGroupProfilePicture = thread.groupModel.groupImage { // An open group with a profile picture
|
||||
self.openGroupProfilePicture = openGroupProfilePicture
|
||||
isRSSFeed = false
|
||||
hasTappableProfilePicture = true
|
||||
|
|
Loading…
Reference in New Issue