decord/source/modules/chat/SlowmodeUtils.tsx

90 lines
3.8 KiB
TypeScript
Raw Normal View History

2026-08-25 06:04:03 +00:00
// Module ID: 7292
// Function ID: 7293
2026-07-20 16:05:17 +00:00
// Name: canBypassSlowmodeHelper
2026-08-25 06:04:03 +00:00
// Dependencies: [4025, 676, 589, 1236, 687, 3979, 2]
2026-07-29 08:29:29 +00:00
// Exports: canBypassSlowmode, canBypassSlowmodeHelper, getSlowmodeDescription, getSlowmodeIndicatorText, useCanBypassSlowmode
2026-07-20 16:05:17 +00:00
2026-08-25 06:04:03 +00:00
// Module 7292 (canBypassSlowmodeHelper)
2026-08-24 06:08:38 +00:00
import setDefault from "set" /* 687 */;
import getSystemLocale from "getSystemLocale" /* 1236 */;
2026-08-25 06:04:03 +00:00
import closure_3 from "getUncachedChannelPermissions" /* 4025 */;
2026-08-24 06:08:38 +00:00
import { Permissions } from "ME" /* 676 */;
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
require = arg1;
const result = require("set").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) {
2026-08-24 06:08:38 +00:00
return closure_3.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) {
2026-07-23 10:11:24 +00:00
const _require = channel;
2026-08-24 06:08:38 +00:00
const items = [closure_3];
return _require(589).useStateFromStores(items, () => closure_1_3.can(closure_1_4.BYPASS_SLOWMODE, closure_0));
2026-07-20 16:05:17 +00:00
};
export const getSlowmodeIndicatorText = function getSlowmodeIndicatorText(stateFromStores, canBypassSlowmode) {
if (canBypassSlowmode) {
2026-08-24 06:08:38 +00:00
const intl2 = getSystemLocale.intl;
return intl2.string(getSystemLocale.t["8+NidX"]);
} else if (stateFromStores >= setDefault.Millis.HOUR) {
2026-08-25 06:04:03 +00:00
let tmp2Result = tmp2(3979);
2026-07-29 08:29:29 +00:00
const durationResult = tmp2Result.duration(stateFromStores);
2026-07-20 16:05:17 +00:00
const _HermesInternal3 = HermesInternal;
const combined = "" + durationResult.minutes();
const _HermesInternal4 = HermesInternal;
const combined1 = "" + durationResult.seconds();
const padStartResult = combined.padStart(2, "0");
const _HermesInternal5 = HermesInternal;
return "" + durationResult.hours() + ":" + padStartResult + ":" + combined1.padStart(2, "0");
} else if (stateFromStores > 0) {
2026-08-25 06:04:03 +00:00
tmp2Result = tmp2(3979);
2026-07-29 08:29:29 +00:00
const durationResult1 = tmp2Result.duration(stateFromStores);
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal;
const combined2 = "" + durationResult1.seconds();
const _HermesInternal2 = HermesInternal;
return "" + durationResult1.minutes() + ":" + combined2.padStart(2, "0");
} else {
2026-08-24 06:08:38 +00:00
const intl = getSystemLocale.intl;
return intl.string(getSystemLocale.t.Icu3bf);
2026-07-20 16:05:17 +00:00
}
};
export const getSlowmodeDescription = function getSlowmodeDescription(rateLimitPerUser) {
let flag = arg1;
if (arg1 === undefined) {
flag = false;
}
2026-08-24 06:08:38 +00:00
if (rateLimitPerUser >= setDefault.Seconds.HOUR) {
2026-07-20 16:05:17 +00:00
const _Math2 = Math;
2026-07-29 08:29:29 +00:00
const rounded = Math.floor(rateLimitPerUser / tmp(687).Seconds.HOUR);
2026-07-20 16:05:17 +00:00
const _Math3 = Math;
2026-07-29 08:29:29 +00:00
const diff = rateLimitPerUser - rounded * tmp(687).Seconds.HOUR;
const rounded1 = Math.floor(diff / tmp(687).Seconds.MINUTE);
const diff1 = rateLimitPerUser - rounded * tmp(687).Seconds.HOUR;
const diff2 = diff1 - rounded1 * tmp(687).Seconds.MINUTE;
2026-08-24 06:08:38 +00:00
const intl3 = getSystemLocale.intl;
const t3 = getSystemLocale.t;
2026-07-29 08:29:29 +00:00
let obj = { hours: null, minutes: null, seconds: null };
obj[0] = rounded;
obj[1] = rounded1;
obj[2] = diff2;
2026-07-23 10:11:24 +00:00
return intl3.formatToPlainString(flag ? t3.oEwLez : t3["3hz51F"], obj);
2026-07-20 16:05:17 +00:00
} else if (rateLimitPerUser >= 60) {
const _Math = Math;
const rounded2 = Math.floor(rateLimitPerUser / 60);
2026-08-24 06:08:38 +00:00
const intl2 = getSystemLocale.intl;
const t2 = getSystemLocale.t;
2026-07-29 08:29:29 +00:00
obj = { minutes: null, seconds: null };
obj[0] = rounded2;
obj[1] = rateLimitPerUser - 60 * rounded2;
2026-07-20 16:05:17 +00:00
return intl2.formatToPlainString(flag ? t2.DARKYm : t2.sY3wlG, obj);
} else {
2026-08-24 06:08:38 +00:00
const intl = getSystemLocale.intl;
const t = getSystemLocale.t;
2026-07-29 08:29:29 +00:00
obj = { seconds: null };
obj[0] = 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
}
};