mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Various fixes
This commit is contained in:
@@ -24,6 +24,7 @@ public enum MessageContentKindKey {
|
||||
case expiredVoiceMessage
|
||||
case expiredVideoMessage
|
||||
case poll
|
||||
case todo
|
||||
case restricted
|
||||
case dice
|
||||
case invoice
|
||||
@@ -50,6 +51,7 @@ public enum MessageContentKind: Equatable {
|
||||
case expiredVoiceMessage
|
||||
case expiredVideoMessage
|
||||
case poll(String)
|
||||
case todo(String)
|
||||
case restricted(String)
|
||||
case dice(String)
|
||||
case invoice(String)
|
||||
@@ -160,6 +162,12 @@ public enum MessageContentKind: Equatable {
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .todo:
|
||||
if case .todo = other {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .restricted:
|
||||
if case .restricted = other {
|
||||
return true
|
||||
@@ -229,6 +237,8 @@ public enum MessageContentKind: Equatable {
|
||||
return .expiredVideoMessage
|
||||
case .poll:
|
||||
return .poll
|
||||
case .todo:
|
||||
return .todo
|
||||
case .restricted:
|
||||
return .restricted
|
||||
case .dice:
|
||||
@@ -369,6 +379,8 @@ public func mediaContentKind(_ media: EngineMedia, message: EngineMessage? = nil
|
||||
}
|
||||
case let .poll(poll):
|
||||
return .poll(poll.text)
|
||||
case let .todo(todo):
|
||||
return .todo(todo.text)
|
||||
case let .dice(dice):
|
||||
return .dice(dice.emoji)
|
||||
case let .invoice(invoice):
|
||||
@@ -455,6 +467,8 @@ public func stringForMediaKind(_ kind: MessageContentKind, strings: Presentation
|
||||
return (NSAttributedString(string: strings.Message_VideoMessageExpired), true)
|
||||
case let .poll(text):
|
||||
return (NSAttributedString(string: "📊 \(text)"), false)
|
||||
case let .todo(text):
|
||||
return (NSAttributedString(string: "☑️ \(text)"), false)
|
||||
case let .restricted(text):
|
||||
return (NSAttributedString(string: text), false)
|
||||
case let .dice(emoji):
|
||||
|
||||
@@ -1297,38 +1297,47 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var taskTitle = "DELETED"
|
||||
if let todo {
|
||||
if message.author?.id == accountPeerId {
|
||||
let resultString: PresentationStrings.FormattedString
|
||||
if let completedTaskId = completed.first, let completedTask = todo.items.first(where: { $0.id == completedTaskId }) {
|
||||
resultString = strings.Notification_TodoCompletedYou(completedTask.text)
|
||||
} else if let incompletedTaskId = incompleted.first, let incompletedTask = todo.items.first(where: { $0.id == incompletedTaskId }) {
|
||||
resultString = strings.Notification_TodoIncompletedYou(incompletedTask.text)
|
||||
} else {
|
||||
fatalError()
|
||||
}
|
||||
attributedString = addAttributesToStringWithRanges(resultString._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
|
||||
} else {
|
||||
let peerName = message.author?.compactDisplayTitle ?? ""
|
||||
|
||||
var attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id)])
|
||||
attributes[1] = boldAttributes
|
||||
|
||||
let resultString: PresentationStrings.FormattedString
|
||||
if let completedTaskId = completed.first, let completedTask = todo.items.first(where: { $0.id == completedTaskId }) {
|
||||
resultString = strings.Notification_TodoCompleted(peerName, completedTask.text)
|
||||
} else if let incompletedTaskId = incompleted.first, let incompletedTask = todo.items.first(where: { $0.id == incompletedTaskId }) {
|
||||
resultString = strings.Notification_TodoIncompleted(peerName, incompletedTask.text)
|
||||
} else {
|
||||
fatalError()
|
||||
}
|
||||
attributedString = addAttributesToStringWithRanges(resultString._tuple, body: bodyAttributes, argumentAttributes: attributes)
|
||||
if let completedTaskId = completed.first, let completedTask = todo.items.first(where: { $0.id == completedTaskId }) {
|
||||
taskTitle = completedTask.text
|
||||
} else if let incompletedTaskId = incompleted.first, let incompletedTask = todo.items.first(where: { $0.id == incompletedTaskId }) {
|
||||
taskTitle = incompletedTask.text
|
||||
}
|
||||
}
|
||||
if taskTitle.count > 20 {
|
||||
taskTitle = taskTitle.prefix(20) + "…"
|
||||
}
|
||||
|
||||
if message.author?.id == accountPeerId {
|
||||
let resultString: PresentationStrings.FormattedString
|
||||
if let _ = completed.first {
|
||||
resultString = strings.Notification_TodoCompletedYou(taskTitle)
|
||||
} else if let _ = incompleted.first {
|
||||
resultString = strings.Notification_TodoIncompletedYou(taskTitle)
|
||||
} else {
|
||||
resultString = strings.Notification_TodoCompletedYou("")
|
||||
}
|
||||
attributedString = addAttributesToStringWithRanges(resultString._tuple, body: bodyAttributes, argumentAttributes: [0: boldAttributes])
|
||||
} else {
|
||||
attributedString = NSAttributedString(string: ".")
|
||||
let peerName = message.author?.compactDisplayTitle ?? ""
|
||||
|
||||
var attributes = peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: [(0, message.author?.id)])
|
||||
attributes[1] = boldAttributes
|
||||
|
||||
let resultString: PresentationStrings.FormattedString
|
||||
if let _ = completed.first {
|
||||
resultString = strings.Notification_TodoCompleted(peerName, taskTitle)
|
||||
} else if let _ = incompleted.first {
|
||||
resultString = strings.Notification_TodoIncompleted(peerName, taskTitle)
|
||||
} else {
|
||||
resultString = strings.Notification_TodoCompleted(peerName, "")
|
||||
}
|
||||
attributedString = addAttributesToStringWithRanges(resultString._tuple, body: bodyAttributes, argumentAttributes: attributes)
|
||||
}
|
||||
case let .todoAppendTasks(tasks):
|
||||
var todoTitle = ""
|
||||
var todoTitle = "DELETED"
|
||||
for attribute in message.attributes {
|
||||
if let attribute = attribute as? ReplyMessageAttribute, let message = message.associatedMessages[attribute.messageId] {
|
||||
for media in message.media {
|
||||
@@ -1338,10 +1347,17 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
||||
}
|
||||
}
|
||||
}
|
||||
if todoTitle.count > 20 {
|
||||
todoTitle = todoTitle.prefix(20) + "…"
|
||||
}
|
||||
if message.author?.id == accountPeerId {
|
||||
let resultString: PresentationStrings.FormattedString
|
||||
if tasks.count == 1, let task = tasks.first {
|
||||
resultString = strings.Notification_TodoAddedTaskYou(task.text, todoTitle)
|
||||
var taskTitle = task.text
|
||||
if taskTitle.count > 20 {
|
||||
taskTitle = taskTitle.prefix(20) + "…"
|
||||
}
|
||||
resultString = strings.Notification_TodoAddedTaskYou(taskTitle, todoTitle)
|
||||
} else {
|
||||
resultString = strings.Notification_TodoAddedMultipleTasksYou(strings.Notification_TodoTasks(Int32(tasks.count)), todoTitle)
|
||||
}
|
||||
@@ -1354,7 +1370,11 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
||||
|
||||
let resultString: PresentationStrings.FormattedString
|
||||
if tasks.count == 1, let task = tasks.first {
|
||||
resultString = strings.Notification_TodoAddedTask(peerName, task.text, todoTitle)
|
||||
var taskTitle = task.text
|
||||
if taskTitle.count > 20 {
|
||||
taskTitle = taskTitle.prefix(20) + "…"
|
||||
}
|
||||
resultString = strings.Notification_TodoAddedTask(peerName, taskTitle, todoTitle)
|
||||
} else {
|
||||
resultString = strings.Notification_TodoAddedMultipleTasks(peerName, strings.Notification_TodoTasks(Int32(tasks.count)), todoTitle)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user