mirror of
https://github.com/Dimillian/IceCubesApp.git
synced 2024-11-26 18:21:00 +00:00
Composer: Trim attachement characters
This commit is contained in:
parent
47004d00c1
commit
09c09d5ea9
1 changed files with 7 additions and 7 deletions
|
@ -245,18 +245,18 @@ public class StatusEditorViewModel: ObservableObject {
|
||||||
range: NSRange(location: range.location, length: range.length))
|
range: NSRange(location: range.location, length: range.length))
|
||||||
}
|
}
|
||||||
|
|
||||||
var attachmentsToRemove: [NSRange] = []
|
var mediaAdded: Bool = false
|
||||||
statusText.enumerateAttribute(.attachment, in: range) { attachment, _, _ in
|
statusText.enumerateAttribute(.attachment, in: range) { attachment, range, _ in
|
||||||
if let attachment = attachment as? NSTextAttachment, let image = attachment.image {
|
if let attachment = attachment as? NSTextAttachment, let image = attachment.image {
|
||||||
attachmentsToRemove.append(range)
|
|
||||||
mediasImages.append(.init(image: image, mediaAttachment: nil, error: nil))
|
mediasImages.append(.init(image: image, mediaAttachment: nil, error: nil))
|
||||||
|
statusText.removeAttribute(.attachment, range: range)
|
||||||
|
statusText.mutableString.deleteCharacters(in: range)
|
||||||
|
mediaAdded = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !attachmentsToRemove.isEmpty {
|
|
||||||
|
if mediaAdded {
|
||||||
processMediasToUpload()
|
processMediasToUpload()
|
||||||
for range in attachmentsToRemove {
|
|
||||||
statusText.removeAttribute(.attachment, range: range)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue