decord/beta/source/modules/notification_center/useRelativeTimestamp.tsx

52 lines
1.6 KiB
TypeScript
Raw Normal View History

// Module ID: 15669
// Function ID: 15670
// Name: useRelativeTimestamp
// Dependencies: [32, 19, 7055, 1091, 2]
// Exports: useRelativeTimestamp
// Module 15669 (useRelativeTimestamp)
import NotificationCenterUtils from "NotificationCenterUtils" /* 7055 */;
2026-10-01 14:13:23 +00:00
import _slicedToArray from "_slicedToArray" /* 32 */;
import react from "react" /* 19 */;
import size from "module_2" /* 2 */;
const result = size.fileFinishedImporting("modules/notification_center/useRelativeTimestamp.tsx");
export const useRelativeTimestamp = function useRelativeTimestamp(timestamp) {
2026-10-01 14:13:23 +00:00
let closure_2;
let first;
timestamp = timestamp.timestamp;
let flag = timestamp.abbreviated;
if (flag === undefined) {
flag = true;
}
2026-10-01 14:13:23 +00:00
closure_2 = undefined;
[first, closure_2] = react.useState(() => {
const obj = NotificationCenterUtils;
return obj.getRelativeTimestamp(timestamp, flag);
});
const items = [timestamp, flag];
2026-10-01 14:13:23 +00:00
const effect = react.useEffect(() => {
let closure_0;
let interval;
let obj = timestamp(closure_2[2]);
closure_2(obj.getRelativeTimestamp(interval, flag));
const diff = Date.now() - interval;
2026-10-01 14:13:23 +00:00
if (diff <= flag(closure_2[3]).Millis.DAY) {
let MINUTE;
if (diff >= flag(closure_2[3]).Millis.HOUR) {
MINUTE = tmp4(tmp[3]).Millis.HOUR;
} else {
2026-10-01 14:13:23 +00:00
MINUTE = tmp4(tmp[3]).Millis.MINUTE;
}
const _setInterval = setInterval;
interval = setInterval(() => {
2026-10-01 14:13:23 +00:00
const obj = timestamp(closure_2[2]);
closure_1_2(obj.getRelativeTimestamp(closure_0, flag));
}, MINUTE, MINUTE - diff % MINUTE);
return () => clearInterval(closure_0);
}
}, items);
2026-10-01 14:13:23 +00:00
return first;
};