Добавлено gasText в ChatMessage #13
This commit is contained in:
1 parent
fe2b14ecee
commit
4c16644b69
1 file changed
+13
-1
@@ -167,7 +167,8 @@ final class ChatMessage {
|
|||||||
var quotePreview: String {
|
var quotePreview: String {
|
||||||
if isRetracted { return "Сообщение удалено" }
|
if isRetracted { return "Сообщение удалено" }
|
||||||
let value = kind == .text ? body : previewText
|
let value = kind == .text ? body : previewText
|
||||||
let normalized = value
|
let normalized =
|
||||||
|
value
|
||||||
.replacingOccurrences(of: "\n", with: " ")
|
.replacingOccurrences(of: "\n", with: " ")
|
||||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||||
guard normalized.count > 140 else { return normalized }
|
guard normalized.count > 140 else { return normalized }
|
||||||
@@ -264,4 +265,15 @@ final class ChatMessage {
|
|||||||
let bare = value[..<slash].lowercased()
|
let bare = value[..<slash].lowercased()
|
||||||
return bare + String(value[slash...])
|
return bare + String(value[slash...])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hasText: Bool {
|
||||||
|
// 1. Удалённые сообщения не копируем
|
||||||
|
guard !isRetracted else { return false }
|
||||||
|
|
||||||
|
// 2. Исключаем системные уведомления
|
||||||
|
guard kind != .system else { return false }
|
||||||
|
|
||||||
|
// 3. Текст считается существующим, если body не пустая строка (с обрезкой пробелов)
|
||||||
|
return !body.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user