decord/source/modules/chat/SlowmodeUtils.tsx

87 lines
3.6 KiB
TypeScript
Raw Normal View History

// Module ID: 7796
// Function ID: 7797
// Name: SlowmodeUtils
// Dependencies: [4276, 1074, 504, 1115, 1091, 4229, 2]
2026-07-29 08:29:29 +00:00
// Exports: canBypassSlowmode, canBypassSlowmodeHelper, getSlowmodeDescription, getSlowmodeIndicatorText, useCanBypassSlowmode
2026-07-20 16:05:17 +00:00
// Module 7796 (SlowmodeUtils)
import DurationsDefault from "Durations" /* 1091 */;
import util from "util" /* 1115 */;
import PermissionStore from "PermissionStore" /* 4276 */;
2026-07-23 10:11:24 +00:00
const require = globalThis.__r;
require = fn;
const Permissions = fn(1074).Permissions;
const size = fn(2);
const result = size.fileFinishedImporting("modules/chat/SlowmodeUtils.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export const canBypassSlowmodeHelper = function canBypassSlowmodeHelper(rateLimitPerUser, can) {
return can.can(Permissions.BYPASS_SLOWMODE, rateLimitPerUser);
};
2026-07-28 08:39:19 +00:00
export const canBypassSlowmode = function canBypassSlowmode(channel) {
return PermissionStore.can(Permissions.BYPASS_SLOWMODE, channel);
2026-07-20 16:05:17 +00:00
};
2026-07-28 08:39:19 +00:00
export const useCanBypassSlowmode = function useCanBypassSlowmode(channel) {
_require = channel;
const items = [PermissionStore];
return require("initialize").useStateFromStores(items, () => PermissionStore.can(Permissions.BYPASS_SLOWMODE, closure_0));
2026-07-20 16:05:17 +00:00
};
export const getSlowmodeIndicatorText = function getSlowmodeIndicatorText(stateFromStores, canBypassSlowmode) {
if (canBypassSlowmode) {
const intl2 = util.intl;
return intl2.string(util.t["8+NidX"]);
} else if (stateFromStores >= DurationsDefault.Millis.HOUR) {
const time2 = tmp2(4229).duration(stateFromStores);
2026-07-20 16:05:17 +00:00
const _HermesInternal3 = HermesInternal;
const combined = "" + time2.minutes();
const tmp2Result = tmp2(4229);
2026-07-20 16:05:17 +00:00
const _HermesInternal4 = HermesInternal;
const combined1 = "" + time2.seconds();
2026-07-20 16:05:17 +00:00
const padStartResult = combined.padStart(2, "0");
const _HermesInternal5 = HermesInternal;
return "" + time2.hours() + ":" + padStartResult + ":" + combined1.padStart(2, "0");
2026-07-20 16:05:17 +00:00
} else if (stateFromStores > 0) {
const time = tmp2(4229).duration(stateFromStores);
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
const combined2 = "" + time.seconds();
const tmp2Result2 = tmp2(4229);
2026-07-20 16:05:17 +00:00
const _HermesInternal2 = HermesInternal;
return "" + time.minutes() + ":" + combined2.padStart(2, "0");
2026-07-20 16:05:17 +00:00
} else {
const intl = util.intl;
return intl.string(util.t.Icu3bf);
2026-07-20 16:05:17 +00:00
}
};
export const getSlowmodeDescription = function getSlowmodeDescription(rateLimitPerUser) {
let flag = arg1;
if (arg1 === undefined) {
flag = false;
}
if (rateLimitPerUser >= DurationsDefault.Seconds.HOUR) {
2026-07-20 16:05:17 +00:00
const _Math2 = Math;
const rounded = Math.floor(rateLimitPerUser / tmp(1091).Seconds.HOUR);
2026-07-20 16:05:17 +00:00
const _Math3 = Math;
const diff = rateLimitPerUser - rounded * tmp(1091).Seconds.HOUR;
const rounded1 = Math.floor(diff / tmp(1091).Seconds.MINUTE);
const diff1 = rateLimitPerUser - rounded * tmp(1091).Seconds.HOUR;
const diff2 = diff1 - rounded1 * tmp(1091).Seconds.MINUTE;
const intl3 = util.intl;
const t3 = util.t;
const time = { hours: rounded, minutes: rounded1, seconds: diff2 };
return intl3.formatToPlainString(flag ? t3.oEwLez : t3["3hz51F"], time);
2026-07-20 16:05:17 +00:00
} else if (rateLimitPerUser >= 60) {
const _Math = Math;
const rounded2 = Math.floor(rateLimitPerUser / 60);
const intl2 = util.intl;
const t2 = util.t;
const time1 = { minutes: rounded2, seconds: rateLimitPerUser - 60 * rounded2 };
return intl2.formatToPlainString(flag ? t2.DARKYm : t2.sY3wlG, time1);
2026-07-20 16:05:17 +00:00
} else {
const intl = util.intl;
const t = util.t;
const obj = { seconds: rateLimitPerUser };
2026-07-23 10:11:24 +00:00
return intl.formatToPlainString(flag ? t["9yE8Ga"] : t.IWntYg, obj);
2026-07-20 16:05:17 +00:00
}
};