138 lines
4.6 KiB
TypeScript
138 lines
4.6 KiB
TypeScript
// Metro module 5855 (f5856).
|
|
import FamilyCenterStore from "./FamilyCenterStore";
|
|
import { ACTION_TO_TEXT, FAMILY_CENTER_ERROR_CODE_TO_FAILURE, FamilyCenterFailureCode, TeenActionDisplayType, UserLinkStatus, UserLinkType } from "./FamilyCenterConstants";
|
|
import { intl } from "../../intl/index.native";
|
|
import FamilyCenter_messages from "./FamilyCenter.messages";
|
|
import Module3771 from "../../_bundle/Module3771";
|
|
import FamilyCenterActionCreators from "./FamilyCenterActionCreators";
|
|
let $mk77226 = function() {
|
|
return (a0) => a0.link_status === UserLinkStatus.ACTIVE && a0.link_type === UserLinkType.PARENT;
|
|
};
|
|
let c3662_10 = 86400;
|
|
let c3662_11 = 172800;
|
|
export function getEmptyActivityFormatter() {
|
|
return {
|
|
today: intl.string(FamilyCenter_messages.VjIAQQ),
|
|
yesterday: intl.string(FamilyCenter_messages["2a8xHY"]),
|
|
days: FamilyCenter_messages.Xt6oND
|
|
};
|
|
}
|
|
export function getActivityWindowTimestampFormatter(a0) {
|
|
let r26;
|
|
const r2 = {
|
|
today: null,
|
|
yesterday: null,
|
|
days: null
|
|
};
|
|
if (a0) {
|
|
r2.today = intl.string(FamilyCenter_messages["2AtcIs"]);
|
|
r2.yesterday = intl.string(FamilyCenter_messages.stOECr);
|
|
r2.days = FamilyCenter_messages.n8n5Ba;
|
|
r26 = r2;
|
|
} else {
|
|
r2.today = intl.string(FamilyCenter_messages.g1ZX6m);
|
|
r2.yesterday = intl.string(FamilyCenter_messages.s3qSVt);
|
|
r2.days = FamilyCenter_messages.f1UJiC;
|
|
r26 = r2;
|
|
}
|
|
return r26;
|
|
}
|
|
export function formatUserActivityTimestamp(a0, a1, a2) {
|
|
let today;
|
|
const r13 = Module3771().diff(Module3771(a0), "s");
|
|
const r19 = a1();
|
|
Module3771(a0).format("LL");
|
|
if (r13 < c3662_10) {
|
|
today = r19.today;
|
|
} else if (r13 < c3662_11) {
|
|
today = r19.yesterday;
|
|
} else {
|
|
let r12 = a2;
|
|
const days = r19.days;
|
|
const r33 = Math;
|
|
const r37 = Math.floor(r13 / c3662_10);
|
|
if (a2 == null) {
|
|
r12 = 999;
|
|
}
|
|
today = intl.formatToPlainString(days, {
|
|
days: r33.min(r37, r12)
|
|
});
|
|
}
|
|
return today;
|
|
}
|
|
export function formatLinkTimestamp(a0, a1) {
|
|
const r14 = Module3771().diff(Module3771(a0), "s");
|
|
const r22 = a1();
|
|
const date = Module3771(a0).format("LL");
|
|
return r14 < 60 ? r22.seconds : r14 < 3600 ? intl.formatToPlainString(r22.minutes, {
|
|
count: Math.floor(r14 / 60)
|
|
}) : r14 < c3662_10 ? intl.formatToPlainString(r22.hours, {
|
|
count: Math.floor(r14 / 3600)
|
|
}) : r14 < c3662_11 ? r22.yesterday : r14 < 604800 ? intl.formatToPlainString(r22.days, {
|
|
count: Math.floor(r14 / c3662_10)
|
|
}) : intl.formatToPlainString(r22.date, {
|
|
date
|
|
});
|
|
}
|
|
export function isUserAction(a0) {
|
|
return a0.display_type === TeenActionDisplayType.USER_ADD || a0.display_type === TeenActionDisplayType.USER_INTERACTION || a0.display_type === TeenActionDisplayType.USER_CALLED;
|
|
}
|
|
export function isGuildAction(a0) {
|
|
return a0.display_type === TeenActionDisplayType.GUILD_ADD || a0.display_type === TeenActionDisplayType.GUILD_INTERACTION;
|
|
}
|
|
export function isPurchase(a0) {
|
|
return a0.display_type === TeenActionDisplayType.PURCHASES;
|
|
}
|
|
export function isGift(a0) {
|
|
return a0.display_type === TeenActionDisplayType.GIFTS;
|
|
}
|
|
export function displayTypeFromString(a0) {
|
|
for (const item of Object.values(TeenActionDisplayType)) {
|
|
if (item.toString() !== a0) {
|
|
continue;
|
|
}
|
|
return item;
|
|
}
|
|
}
|
|
export function getFailureCodeForAPIError(a0) {
|
|
let r5 = FAMILY_CENTER_ERROR_CODE_TO_FAILURE[a0.code];
|
|
if (r5 == null) {
|
|
r5 = FamilyCenterFailureCode.GENERIC_ERROR;
|
|
}
|
|
return r5;
|
|
}
|
|
export function getSortedActivityTypeConfigs() {
|
|
const map = new Map(ACTION_TO_TEXT);
|
|
return map.size === 0 ? [] : Array.from(map.entries()).sort((a, b) => a[1].priority - b[1].priority);
|
|
}
|
|
export function getActivityTypeTextConfigs() {
|
|
return new Map(ACTION_TO_TEXT);
|
|
}
|
|
export function formatTotalTime(a0) {
|
|
const r7 = Math.floor(a0 / 60);
|
|
const r13 = a0 % 60;
|
|
return r7 > 0 ? `${r7}h ${r13}m` : `${r13}m`;
|
|
}
|
|
export function getOrFetchLinkedUsers() {
|
|
if (FamilyCenterStore.getAreLinkedUsersProcessed()) {
|
|
return FamilyCenterStore.getLinkedUsers();
|
|
}
|
|
FamilyCenterActionCreators.fetchLinkedUsers();
|
|
}
|
|
export function hasActiveParentLinks() {
|
|
return Object.values(FamilyCenterStore.getLinkedUsers()).some($mk77226());
|
|
}
|
|
export function isParentallyControlled() {
|
|
return Object.values(FamilyCenterStore.getLinkedUsers()).some($mk77226());
|
|
}
|
|
export function getTopUserOrGuildDescription(a0, a1) {
|
|
return a1 > 0 && a0 === 0 ? intl.formatToPlainString(FamilyCenter_messages["L/Cj7S"], {
|
|
callCount: a1
|
|
}) : a0 > 0 && a1 === 0 ? intl.formatToPlainString(FamilyCenter_messages["6X1F0i"], {
|
|
messageCount: a0
|
|
}) : intl.formatToPlainString(FamilyCenter_messages.IYqGMG, {
|
|
messageCount: a0,
|
|
callCount: a1
|
|
});
|
|
}
|