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