d
This commit is contained in:
@@ -6,6 +6,29 @@ public extension Mic {
|
||||
///
|
||||
/// - Returns: Словарь активных состояний
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user