decord/source/modules/auth_sessions/AuthSessionsUtils.tsx

52 lines
2 KiB
TypeScript
Raw Normal View History

// Module ID: 14784
// Function ID: 14785
// Name: AuthSessionsUtils
// Dependencies: [19, 502, 14785, 504, 1115, 4229, 2]
2026-07-20 16:05:17 +00:00
// Exports: formatDate, useAuthSessions
// Module 14784 (AuthSessionsUtils)
import util from "util" /* 1115 */;
import _modDef4229 from "module_4229" /* 4229 */;
import noop from "module_19" /* 19 */;
import AuthenticationStore from "AuthenticationStore" /* 502 */;
import AuthSessionsStore from "AuthSessionsStore" /* 14785 */;
2026-07-23 10:11:24 +00:00
require = fn;
const size = fn(2);
const result = size.fileFinishedImporting("modules/auth_sessions/AuthSessionsUtils.tsx");
2026-07-20 16:05:17 +00:00
export const useAuthSessions = function useAuthSessions() {
const items = [AuthSessionsStore];
stateFromStoresObject = stateFromStoresObject(504).useStateFromStoresObject(items, () => sessions.getSessions());
2026-07-20 16:05:17 +00:00
const items1 = [stateFromStoresObject];
return noop.useMemo(() => {
const otherSessions = [...stateFromStoresObject];
const authSessionIdHash = AuthenticationStore.getAuthSessionIdHash();
2026-07-29 08:29:29 +00:00
let currentSession = null;
2026-07-20 16:05:17 +00:00
if (null != authSessionIdHash) {
2026-07-29 08:29:29 +00:00
const findIndexResult = otherSessions.findIndex((id_hash) => id_hash.id_hash === authSessionIdHash);
currentSession = null;
2026-07-20 16:05:17 +00:00
if (findIndexResult >= 0) {
2026-07-29 08:29:29 +00:00
currentSession = otherSessions.splice(findIndexResult, 1)[0];
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
const sorted = otherSessions.sort((approx_last_used_time, approx_last_used_time2) => {
2026-07-20 16:05:17 +00:00
approx_last_used_time = approx_last_used_time2.approx_last_used_time;
approx_last_used_time2 = approx_last_used_time.approx_last_used_time;
return approx_last_used_time.valueOf() - approx_last_used_time2.valueOf();
});
2026-07-29 08:29:29 +00:00
return { currentSession, otherSessions };
2026-07-20 16:05:17 +00:00
}, items1);
};
export const formatDate = function formatDate(arg0) {
const timestamp = Date.now();
if ((timestamp - arg0.valueOf()) / 1000 / 60 / 60 < 1) {
const intl = util.intl;
let stringResult = intl.string(util.t.TXCmfL);
2026-07-20 16:05:17 +00:00
} else {
stringResult = _modDef4229(arg0).fromNow();
const obj = _modDef4229(arg0);
2026-07-20 16:05:17 +00:00
}
return stringResult;
};