mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Voice Chat Fixes
This commit is contained in:
@@ -157,7 +157,7 @@ public struct HumanReadableStringFormat {
|
||||
}
|
||||
}
|
||||
|
||||
public func humanReadableStringForTimestamp(strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, timestamp: Int32, alwaysShowTime: Bool = false, format: HumanReadableStringFormat? = nil) -> String {
|
||||
public func humanReadableStringForTimestamp(strings: PresentationStrings, dateTimeFormat: PresentationDateTimeFormat, timestamp: Int32, alwaysShowTime: Bool = false, allowYesterday: Bool = true, format: HumanReadableStringFormat? = nil) -> String {
|
||||
var t: time_t = time_t(timestamp)
|
||||
var timeinfo: tm = tm()
|
||||
localtime_r(&t, &timeinfo)
|
||||
@@ -178,7 +178,7 @@ public func humanReadableStringForTimestamp(strings: PresentationStrings, dateTi
|
||||
}
|
||||
|
||||
let dayDifference = timeinfo.tm_yday - timeinfoNow.tm_yday
|
||||
if dayDifference == 0 || dayDifference == -1 || dayDifference == 1 {
|
||||
if dayDifference == 0 || (dayDifference == -1 && allowYesterday) || dayDifference == 1 {
|
||||
let day: RelativeTimestampFormatDay
|
||||
if dayDifference == 0 {
|
||||
day = .today
|
||||
|
||||
@@ -448,11 +448,11 @@ public func universalServiceMessageString(presentationData: (PresentationTheme,
|
||||
attributedString = NSAttributedString(string: titleString, font: titleFont, textColor: primaryTextColor)
|
||||
case let .groupPhoneCall(_, _, scheduleDate, duration):
|
||||
if let scheduleDate = scheduleDate {
|
||||
let timeString = humanReadableStringForTimestamp(strings: strings, dateTimeFormat: dateTimeFormat, timestamp: scheduleDate)
|
||||
if message.author?.id.namespace == Namespaces.Peer.CloudChannel {
|
||||
let titleString = humanReadableStringForTimestamp(strings: strings, dateTimeFormat: dateTimeFormat, timestamp: scheduleDate, format: HumanReadableStringFormat(dateFormatString: { strings.Notification_VoiceChatScheduledChannel($0).0 }, tomorrowFormatString: { strings.Notification_VoiceChatScheduledTomorrowChannel($0).0 }, todayFormatString: { strings.Notification_VoiceChatScheduledTodayChannel($0).0 }, yesterdayFormatString: { $0 }))
|
||||
let titleString = humanReadableStringForTimestamp(strings: strings, dateTimeFormat: dateTimeFormat, timestamp: scheduleDate, alwaysShowTime: true, allowYesterday: false, format: HumanReadableStringFormat(dateFormatString: { strings.Notification_VoiceChatScheduledChannel($0).0 }, tomorrowFormatString: { strings.Notification_VoiceChatScheduledTomorrowChannel($0).0 }, todayFormatString: { strings.Notification_VoiceChatScheduledTodayChannel($0).0 }, yesterdayFormatString: { $0 }))
|
||||
attributedString = NSAttributedString(string: titleString, font: titleFont, textColor: primaryTextColor)
|
||||
} else {
|
||||
let timeString = humanReadableStringForTimestamp(strings: strings, dateTimeFormat: dateTimeFormat, timestamp: scheduleDate)
|
||||
let attributePeerIds: [(Int, PeerId?)] = [(0, message.author?.id)]
|
||||
let titleString = strings.Notification_VoiceChatScheduled(authorName, timeString)
|
||||
attributedString = addAttributesToStringWithRanges(titleString, body: bodyAttributes, argumentAttributes: peerMentionsAttributes(primaryTextColor: primaryTextColor, peerIds: attributePeerIds))
|
||||
|
||||
Reference in New Issue
Block a user