From b42649b24932c81ab4685e93edbab5adb9b0357e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Fri, 26 Jan 2024 18:48:59 +0300 Subject: [PATCH] d --- Modules/MicX/Mic/src/Mic.Shoulds.swift | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Modules/MicX/Mic/src/Mic.Shoulds.swift b/Modules/MicX/Mic/src/Mic.Shoulds.swift index 423d533..15e48ee 100644 --- a/Modules/MicX/Mic/src/Mic.Shoulds.swift +++ b/Modules/MicX/Mic/src/Mic.Shoulds.swift @@ -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 }