notifications

This commit is contained in:
overtake
2018-11-21 16:14:48 +04:00
parent 05b8bf6a1b
commit 0161c7793a
9 changed files with 85 additions and 44 deletions

View File

@@ -337,3 +337,16 @@ func userPresenceStringRefreshTimeout(_ presence: TelegramUserPresence, relative
return Double.infinity
}
}
func stringForRemainingMuteInterval(strings: PresentationStrings, muteInterval value: Int32) -> String {
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970)
let value = max(1 * 60, value - timestamp)
if value <= 1 * 60 * 60 {
return strings.MuteExpires_Minutes(Int32(round(Float(value) / 60)))
} else if value <= 24 * 60 * 60 {
return strings.MuteExpires_Hours(Int32(round(Float(value) / (60 * 60))))
} else {
return strings.MuteExpires_Days(Int32(round(Float(value) / (24 * 60 * 60))))
}
}