253 lines
12 KiB
TypeScript
253 lines
12 KiB
TypeScript
/* Metro module 8170; source: modules/parent_tools/hooks/useUserLinks.tsx; dependencies: [31, 1878, 5116, 5117, 632, 8171, 8172, 5187, 2] */
|
|
function _fun65555(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#65555, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:6, offset: 0x01bd37ad, size: 392 bytes, params: 8, frame: 21
|
|
const env0_0 = require;
|
|
const closure = useUserIdsForLinkStatus;
|
|
const closure2 = function() {
|
|
return useUserIdsForLinkStatus(UserLinkStatus.ACTIVE);
|
|
};
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_3 = importAll(31) /* metro dependency 31 */;
|
|
const userStore = importDefault(1878) /* metro dependency 1878: UserStore */;
|
|
const familyCenterStore = importDefault(5116) /* metro dependency 5116: FamilyCenterStore */;
|
|
const familyCenterConstantsModule = require(5117) /* metro dependency 5117: FamilyCenterConstants */;
|
|
const env0_6 = familyCenterConstantsModule.ACCEPTED_LINK_REQUEST_TIMESTAMP_FORMATTER;
|
|
const env0_7 = familyCenterConstantsModule.FAMILY_CENTER_REQUEST_QR_CODE_URL;
|
|
const env0_8 = familyCenterConstantsModule.MAX_PARENT_TO_TEEN_ACTIVE_CONNECTIONS;
|
|
const env0_9 = familyCenterConstantsModule.MAX_TEEN_TO_PARENT_ACTIVE_CONNECTIONS;
|
|
const env0_10 = familyCenterConstantsModule.PENDING_LINK_REQUEST_TIMESTAMP_FORMATTER;
|
|
const env0_11 = familyCenterConstantsModule.UserLinkStatus;
|
|
const env0_12 = familyCenterConstantsModule.UserLinkType;
|
|
const closure3 = useUsersForLinkStatus;
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/parent_tools/hooks/useUserLinks.tsx');
|
|
exports.useUserIdsForLinkStatus = closure;
|
|
exports.useUsersForLinkStatus = closure3;
|
|
exports.useActiveLinkUserIds = closure2;
|
|
exports.useActiveLinkUsers = function() {
|
|
return useUsersForLinkStatus(UserLinkStatus.ACTIVE);
|
|
};
|
|
exports.useHasActiveLinks = function() {
|
|
return useActiveLinkUserIds().length > 0;
|
|
};
|
|
exports.useHasActiveParentLinks = useHasActiveParentLinks;
|
|
exports.useUserQRLinkUrl = useUserQRLinkUrl;
|
|
exports.useHasMaxConnections = function() {
|
|
return useActiveLinkUserIds().length >= (importDefault(dependencyMap[5])() ? MAX_PARENT_TO_TEEN_ACTIVE_CONNECTIONS : MAX_TEEN_TO_PARENT_ACTIVE_CONNECTIONS);
|
|
};
|
|
exports.usePendingRequestCount = usePendingRequestCount;
|
|
exports.useAcceptedRequestsCount = function() {
|
|
return useActiveLinkUserIds().length;
|
|
};
|
|
exports.useActivityWindowTimeStamp = useActivityWindowTimeStamp;
|
|
exports.useLinkTimestampText = useLinkTimestampText;
|
|
}
|
|
|
|
function useUserIdsForLinkStatus(a0) { // fn#65556, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:387, offset: 0x01bd3935, size: 104 bytes, params: 2, frame: 16
|
|
const env0_0 = a0;
|
|
return env0_3.useMemo(_fun65558,
|
|
[(require(632) /* metro dependency 632: useStateFromStores */).useStateFromStores([FamilyCenterStore],
|
|
function() {
|
|
return FamilyCenterStore.getLinkedUsers();
|
|
}), a0]);
|
|
}
|
|
|
|
function useUsersForLinkStatus(a0) { // fn#65564, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:721, offset: 0x01bd3aad, size: 93 bytes, params: 2, frame: 15
|
|
const env0_0 = useUserIdsForLinkStatus(a0);
|
|
const useStateFromStoresModule = require(632) /* metro dependency 632: useStateFromStores */;
|
|
const useStateFromStoresArray = useStateFromStoresModule.useStateFromStoresArray;
|
|
return Reflect.apply(useStateFromStoresArray, useStateFromStoresModule, [[UserStore],
|
|
_fun65565]).filter(function(a0) {
|
|
return a0 != null;
|
|
});
|
|
}
|
|
|
|
function useHasActiveParentLinks() { // fn#65570, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:1318, offset: 0x01bd3b71, size: 93 bytes, params: 1, frame: 15
|
|
return env0_3.useMemo(_fun65572,
|
|
[(require(632) /* metro dependency 632: useStateFromStores */).useStateFromStores([FamilyCenterStore],
|
|
function() {
|
|
return FamilyCenterStore.getLinkedUsers();
|
|
})]);
|
|
}
|
|
|
|
function useUserQRLinkUrl() { // fn#65574, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:1550, offset: 0x01bd3c3c, size: 133 bytes, params: 1, frame: 19
|
|
const linkCode = (require(632) /* metro dependency 632: useStateFromStores */).useStateFromStores([FamilyCenterStore],
|
|
function() {
|
|
return FamilyCenterStore.getLinkCode();
|
|
});
|
|
const currentUser = (require(632) /* metro dependency 632: useStateFromStores */).useStateFromStores([UserStore],
|
|
function() {
|
|
return UserStore.getCurrentUser();
|
|
});
|
|
const value2 = null;
|
|
return value2 == linkCode || value2 == currentUser ? value2 : FAMILY_CENTER_REQUEST_QR_CODE_URL(currentUser.id,
|
|
linkCode);
|
|
}
|
|
|
|
function usePendingRequestCount() { // fn#65578, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:1886, offset: 0x01bd3d11, size: 153 bytes, params: 1, frame: 19
|
|
var length;
|
|
const currentUser = (require(632) /* metro dependency 632: useStateFromStores */).useStateFromStores([UserStore],
|
|
function() {
|
|
return UserStore.getCurrentUser();
|
|
});
|
|
const linkedUsers = (require(632) /* metro dependency 632: useStateFromStores */).useStateFromStores([FamilyCenterStore],
|
|
function() {
|
|
return FamilyCenterStore.getLinkedUsers();
|
|
});
|
|
let value = 0;
|
|
if (currentUser == null) {
|
|
length = value;
|
|
} else {
|
|
value = global.Object.values(linkedUsers);
|
|
length = value.filter(_fun65581).length;
|
|
}
|
|
return length;
|
|
}
|
|
|
|
function useActivityWindowTimeStamp(a0) { // fn#65583, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:2285, offset: 0x01bd3dfe, size: 182 bytes, params: 2, frame: 18
|
|
var r0;
|
|
var formatUserActivityTimestamp;
|
|
var Date;
|
|
var value4;
|
|
var date;
|
|
const env0_0 = a0;
|
|
var value;
|
|
const env0_1 = (require(8172) /* metro dependency 8172: useSelectedTeen */).useSelectedTeenId();
|
|
const value2 = (require(632) /* metro dependency 632: useStateFromStores */).useStateFromStores([FamilyCenterStore],
|
|
_fun65584);
|
|
const value3 = null;
|
|
if (value3 == value2) {
|
|
r0 = value3;
|
|
} else {
|
|
value = require(5187) /* metro dependency 5187: FamilyCenterUtils */;
|
|
formatUserActivityTimestamp = value.formatUserActivityTimestamp;
|
|
Date = global.Date;
|
|
value4 = Object.create(Date.prototype, {constructor: {value: Date}});
|
|
date = new Date(value2);
|
|
value = Reflect.apply(formatUserActivityTimestamp, value, [(date instanceof Object ? date : value4).getTime(),
|
|
_fun65585, 7]);
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function useLinkTimestampText(a0, a1) { // fn#65586, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:2551, offset: 0x01bd3ed9, size: 153 bytes, params: 3, frame: 16
|
|
var r0;
|
|
var moduleValue2;
|
|
const env0_0 = a0;
|
|
const linkTimestamp = (require(632) /* metro dependency 632: useStateFromStores */).useStateFromStores([FamilyCenterStore],
|
|
_fun65587);
|
|
const value2 = null;
|
|
if (value2 != linkTimestamp) {
|
|
moduleValue2 = require(5187) /* metro dependency 5187: FamilyCenterUtils */;
|
|
r0 = moduleValue2.formatLinkTimestamp(global.Date.parse(linkTimestamp),
|
|
a1 === UserLinkStatus.PENDING ? PENDING_LINK_REQUEST_TIMESTAMP_FORMATTER : ACCEPTED_LINK_REQUEST_TIMESTAMP_FORMATTER);
|
|
} else {
|
|
r0 = value2;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function _fun65558() { // fn#65558, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:504, offset: 0x01bd39b0, size: 98 bytes, params: 1, frame: 12
|
|
const Object = global.Object;
|
|
let value = Object.values(linkedUsers);
|
|
value = value.filter(_fun65559);
|
|
value = value.sort(function(a0, a1) {
|
|
var Date = global.Date;
|
|
var value2 = new Date(a0.updated_at);
|
|
value2 = value2.getTime();
|
|
Date = global.Date;
|
|
var updated_at2 = a1.updated_at;
|
|
var value3 = Object.create(Date.prototype, {constructor: {value: Date}});
|
|
var value4 = new Date(updated_at2);
|
|
return value2 - (value4 instanceof Object ? value4 : value3).getTime();
|
|
});
|
|
value = value.map(function(a0) {
|
|
return a0.user_id;
|
|
});
|
|
return value.filter(function(a0) {
|
|
return a0 != null;
|
|
});
|
|
}
|
|
|
|
function _fun65565() { // fn#65565, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:802, offset: 0x01bd3b0a, size: 28 bytes, params: 1, frame: 11
|
|
return env0_0.map(function(a0) {
|
|
return UserStore.getUser(a0);
|
|
});
|
|
}
|
|
|
|
function _fun65572() { // fn#65572, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:1434, offset: 0x01bd3bce, size: 47 bytes, params: 1, frame: 11
|
|
const Object = global.Object;
|
|
return Object.values(linkedUsers).some(_fun65573);
|
|
}
|
|
|
|
function _fun65581(a0) { // fn#65581, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:2084, offset: 0x01bd3daa, size: 64 bytes, params: 2, frame: 4
|
|
var r0;
|
|
var link_status;
|
|
let value = a0 != null;
|
|
if (value) {
|
|
link_status = a0.link_status;
|
|
value = environment.__proto__;
|
|
value = link_status === UserLinkStatus.PENDING;
|
|
r0 = value;
|
|
} else {
|
|
r0 = value;
|
|
}
|
|
r0 = r0 && currentUser.id !== a0.requestor_id;
|
|
return r0;
|
|
}
|
|
|
|
function _fun65584() { // fn#65584, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:2392, offset: 0x01bd3eb4, size: 37 bytes, params: 1, frame: 10
|
|
var r0;
|
|
let value = null;
|
|
if (value == env0_1) {
|
|
r0 = value;
|
|
} else {
|
|
value = environment.__proto__;
|
|
value = FamilyCenterStore.getRangeStartTimestamp();
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function _fun65587() { // fn#65587, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:2624, offset: 0x01bd3f72, size: 29 bytes, params: 1, frame: 11
|
|
return FamilyCenterStore.getLinkTimestamp(env0_0);
|
|
}
|
|
|
|
function _fun65559(a0) { // fn#65559, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:533, offset: 0x01bd3a12, size: 31 bytes, params: 2, frame: 3
|
|
var r0;
|
|
var link_status;
|
|
let value = a0 != null;
|
|
if (value) {
|
|
link_status = a0.link_status;
|
|
value = environment.__proto__;
|
|
value = link_status === env1_0;
|
|
r0 = value;
|
|
} else {
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|
|
function _fun65573(a0) { // fn#65573, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:8355:1461, offset: 0x01bd3bfd, size: 63 bytes, params: 2, frame: 4
|
|
var r0;
|
|
var link_status;
|
|
var link_type;
|
|
let value = a0 != null;
|
|
if (value) {
|
|
link_status = a0.link_status;
|
|
value = environment.__proto__.__proto__;
|
|
value = link_status === UserLinkStatus.ACTIVE;
|
|
r0 = value;
|
|
} else {
|
|
r0 = value;
|
|
}
|
|
if (r0) {
|
|
link_type = a0.link_type;
|
|
value = environment.__proto__.__proto__;
|
|
value = link_type === UserLinkType.PARENT;
|
|
r0 = value;
|
|
}
|
|
return r0;
|
|
}
|
|
|