This commit is contained in:
Михаил Капелько
2024-01-26 18:48:59 +03:00
parent e844e8100e
commit b42649b249

View File

@@ -6,6 +6,29 @@ public extension Mic {
/// ///
/// - Returns: Словарь активных состояний /// - Returns: Словарь активных состояний
static func shouldResetActivityDates(_ c: MicContext) -> [String: Date]? { static func shouldResetActivityDates(_ c: MicContext) -> [String: Date]? {
if c.activeIds.isRecent {
var ad = c.activityDates
let ids = c.activeIds.value
let now = Date()
// Задаём абсолютную дату истечения для активных id.
for id in ids {
ad[id] = now + C.activityTimeout
}
// Собираем истёкшие id.
var expiredIds = [String]()
for (id, timeout) in ad {
if timeout < now {
expiredIds.append(id)
}
}
// Удаляем истёкшие id.
for id in expiredIds {
ad[id] = nil
}
return ad
}
return nil return nil
} }