287 lines
14 KiB
TypeScript
287 lines
14 KiB
TypeScript
/* Metro module 14848; source: modules/icymi/useSharedICYMILogic.tsx; dependencies: [57, 31, 9569, 14814, 14849, 566, 9589, 9586, 8819, 9580, 9579, 7230, 14850, 2] */
|
|
function _fun112192(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#112192, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:6, offset: 0x023bebb6, size: 175 bytes, params: 8, frame: 19
|
|
const env0_0 = require;
|
|
const Object = global.Object;
|
|
Object.defineProperty(exports, '__esModule', {value: true});
|
|
const env0_3 = importDefault(57) /* metro dependency 57 */;
|
|
const env0_4 = importAll(31) /* metro dependency 31 */;
|
|
const icymiStore = importDefault(9569) /* metro dependency 9569: ICYMIStore */;
|
|
const env0_6 = (require(14814) /* metro dependency 14814: ICYMIConstants */).SCROLL_EVENT_THROTTLE_MS;
|
|
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/icymi/useSharedICYMILogic.tsx');
|
|
exports.useSharedICYMILogic = useSharedICYMILogic;
|
|
}
|
|
|
|
function useSharedICYMILogic({showDot, notificationItem}) { // fn#112193, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:258, offset: 0x023bec65, size: 807 bytes, params: 2, frame: 37
|
|
const binding = env0_4;
|
|
let useState = binding.useState;
|
|
const value2 = Reflect.apply(useState, binding, [false]);
|
|
const binding2 = env0_3;
|
|
const value3 = binding2(value2, 2);
|
|
const property = value3[0];
|
|
const property2 = value3[1];
|
|
const {unreadItems, readItems,
|
|
allUnreadItemsHydrated} = (importDefault(14849) /* metro dependency 14849: useICYMIItems */)();
|
|
const value = (require(566) /* metro dependency 566: flux */).useStateFromStores([ICYMIStore], function() {
|
|
return ICYMIStore.getVersion();
|
|
}, []);
|
|
const value5 = (require(566) /* metro dependency 566: flux */).useStateFromStores([ICYMIStore], _fun112195);
|
|
binding.useEffect(function() {
|
|
if (ICYMIStore.getLoadId() != null) {
|
|
require(dependencyMap[6]).ICYMIAnalytics.trackFeedShown({homeSessionId: 'gravity'});
|
|
}
|
|
}, [value]);
|
|
const value6 = (require(566) /* metro dependency 566: flux */).useStateFromStores([ICYMIStore], function() {
|
|
return ICYMIStore.isRefreshing();
|
|
}, []);
|
|
const value7 = (require(566) /* metro dependency 566: flux */).useStateFromStores([ICYMIStore], function() {
|
|
return ICYMIStore.isHydrating();
|
|
}, []);
|
|
useState = binding.useState;
|
|
const value8 = binding2(Reflect.apply(useState, binding, [[]]), 2);
|
|
const property3 = value8[0];
|
|
const env0_9 = value8[1];
|
|
const {loadId,
|
|
lastScrollEventTimestamp} = (require(566) /* metro dependency 566: flux */).useStateFromStoresObject([ICYMIStore],
|
|
function() {
|
|
var object = {};
|
|
object.loadId = ICYMIStore.getLoadId();
|
|
object.lastScrollEventTimestamp = ICYMIStore.lastScrollEvent();
|
|
return object;
|
|
});
|
|
const value12 = property3.filter(function({item}) {
|
|
var NON_ELIGIBLE_SCROLL_ITEMS = require(dependencyMap[7]).NON_ELIGIBLE_SCROLL_ITEMS;
|
|
return !NON_ELIGIBLE_SCROLL_ITEMS.has(item.data.kind);
|
|
}).map(function(a0) {
|
|
return a0.item.id;
|
|
}).pop();
|
|
binding.useEffect(_fun112202, [value6, lastScrollEventTimestamp,
|
|
(importDefault(8819) /* metro dependency 8819: usePrevValue */)(value12), value12, loadId, value5]);
|
|
const value17 = binding.useMemo(_fun112213, [binding.useCallback(_fun112203, [value, property2]),
|
|
binding.useCallback(_fun112206, [value]), binding.useCallback(_fun112210, [])]);
|
|
binding.useEffect(_fun112214, []);
|
|
const value18 = (require(14850) /* metro dependency 14850: useICYMIReloadHandler */).useICYMIReloadHandler(showDot);
|
|
const value19 = binding.useMemo(_fun112215, [value5, notificationItem, unreadItems, allUnreadItemsHydrated,
|
|
readItems, value7]);
|
|
return {data: value19.data, loading: value5, version: value, visibleItemIds: property3, endVisible: property,
|
|
isRefreshing: value6, handleOnRefresh: value18, stickyHeaderIndices: value19.stickyHeaderIndices,
|
|
viewabilityConfigCallbackPairs: value17};
|
|
}
|
|
|
|
function _fun112195() { // fn#112195, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:525, offset: 0x023bef9f, size: 40 bytes, params: 1, frame: 10
|
|
const value = environment.__proto__;
|
|
return !(ICYMIStore.isFirstPageHydrated() && env0_5 > 0);
|
|
}
|
|
|
|
function _fun112202() { // fn#112202, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:1128, offset: 0x023bf0a9, size: 161 bytes, params: 1, frame: 14
|
|
var value2;
|
|
var value3;
|
|
var value;
|
|
if (!env0_7) {
|
|
if (!env0_6) {
|
|
if (env0_12 != null) {
|
|
if (env0_11 != null) {
|
|
if (env0_11 !== env0_12) {
|
|
value2 = global.Date.now();
|
|
value = value2 - lastScrollEventTimestamp;
|
|
value3 = environment.__proto__;
|
|
if (value > SCROLL_EVENT_THROTTLE_MS) {
|
|
(importDefault(9580) /* metro dependency 9580: ICYMIActionCreators */).gravityScrollEvent(value2);
|
|
(require(9589) /* metro dependency 9589: ICYMIAnalytics */).ICYMIAnalytics.trackFeedFirstScrollStarted();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function _fun112203({viewableItems}) { // fn#112203, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:1318, offset: 0x023bf14a, size: 344 bytes, params: 2, frame: 28
|
|
var environment;
|
|
var r3;
|
|
var r11;
|
|
var r12;
|
|
var items2;
|
|
var value2;
|
|
var viewableFeedItemsArray;
|
|
var value4;
|
|
var value5;
|
|
var property;
|
|
var push;
|
|
var object2;
|
|
var id;
|
|
var moduleValue2;
|
|
var value6;
|
|
var value7;
|
|
var value8;
|
|
var ICYMIAnalytics;
|
|
if (viewableItems.some(function(a0) {
|
|
return a0.item.data.kind === 'end';
|
|
})) {
|
|
env0_1(true);
|
|
}
|
|
let length = viewableItems.length;
|
|
if (length !== 0) {
|
|
env0_9(viewableItems);
|
|
items2 = [];
|
|
value2 = environment.__proto__;
|
|
viewableFeedItemsArray = (require(9579) /* metro dependency 9579: ICYMIUtils */).getViewableFeedItemsArray(viewableItems);
|
|
value4 = global.Date.now();
|
|
length = viewableFeedItemsArray.length;
|
|
value5 = length - 1;
|
|
if (value5 >= 0) {
|
|
r3 = value4;
|
|
r11 = value5;
|
|
while (true) {
|
|
property = viewableFeedItemsArray[r11];
|
|
if (property == null) {
|
|
r12 = r3;
|
|
} else {
|
|
push = items2.push;
|
|
object2 = {};
|
|
id = property.id;
|
|
object2.id = id;
|
|
moduleValue2 = require(7230) /* metro dependency 7230: ICYMITypes */;
|
|
object2.type = moduleValue2.typeToString(property);
|
|
value6 = typeof r3 === 'bigint' ? r3 : +r3;
|
|
value7 = typeof value6 === 'bigint' ? value6 + 1n : +value6 + 1;
|
|
object2.timestamp = value6;
|
|
Reflect.apply(push, items2, [object2]);
|
|
r12 = value7;
|
|
}
|
|
value8 = typeof r11 === 'bigint' ? r11 - 1n : +r11 - 1;
|
|
if (value8 >= 0) {
|
|
r3 = r12;
|
|
r11 = value8;
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
length = items2.length;
|
|
if (length > 0) {
|
|
(importDefault(9580) /* metro dependency 9580: ICYMIActionCreators */).ackGravityItems(items2, true);
|
|
}
|
|
ICYMIAnalytics = (require(9589) /* metro dependency 9589: ICYMIAnalytics */).ICYMIAnalytics;
|
|
ICYMIAnalytics.trackItemShortImpression(viewableItems, viewableFeedItemsArray.map(_fun112205), env0_5);
|
|
}
|
|
}
|
|
|
|
function _fun112206({viewableItems}) { // fn#112206, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:1755, offset: 0x023bf2f6, size: 181 bytes, params: 2, frame: 20
|
|
var environment;
|
|
var value;
|
|
var viewableFeedItemsArray;
|
|
var ICYMIAnalytics;
|
|
var triggerItemsLongImpression;
|
|
var value5;
|
|
if (viewableItems.length !== 0) {
|
|
value = environment.__proto__;
|
|
viewableFeedItemsArray = (require(9579) /* metro dependency 9579: ICYMIUtils */).getViewableFeedItemsArray(viewableItems);
|
|
ICYMIAnalytics = (require(9589) /* metro dependency 9589: ICYMIAnalytics */).ICYMIAnalytics;
|
|
ICYMIAnalytics.trackItemLongImpression(viewableItems, viewableFeedItemsArray.map(_fun112207), env0_5);
|
|
value = importDefault(9580) /* metro dependency 9580: ICYMIActionCreators */;
|
|
triggerItemsLongImpression = value.triggerItemsLongImpression;
|
|
value5 = viewableItems.filter(function({item}) {
|
|
var NON_ELIGIBLE_SCROLL_ITEMS = require(dependencyMap[7]).NON_ELIGIBLE_SCROLL_ITEMS;
|
|
return !NON_ELIGIBLE_SCROLL_ITEMS.has(item.data.kind);
|
|
});
|
|
Reflect.apply(triggerItemsLongImpression, value, [value5.map(_fun112209)]);
|
|
}
|
|
}
|
|
|
|
function _fun112210({viewableItems}) { // fn#112210, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:2310, offset: 0x023bf474, size: 83 bytes, params: 2, frame: 15
|
|
var environment;
|
|
let value = environment.__proto__;
|
|
value = importDefault(9580) /* metro dependency 9580: ICYMIActionCreators */;
|
|
const startItemsDwell = value.startItemsDwell;
|
|
const value2 = viewableItems.filter(function({item}) {
|
|
var NON_ELIGIBLE_SCROLL_ITEMS = require(dependencyMap[7]).NON_ELIGIBLE_SCROLL_ITEMS;
|
|
return !NON_ELIGIBLE_SCROLL_ITEMS.has(item.data.kind);
|
|
});
|
|
Reflect.apply(startItemsDwell, value, [value2.map(_fun112212)]);
|
|
}
|
|
|
|
function _fun112213() { // fn#112213, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:2681, offset: 0x023bf4c7, size: 111 bytes, params: 1, frame: 4
|
|
return [{viewabilityConfig: {'waitForInteraction': false, 'viewAreaCoveragePercentThreshold': 100,
|
|
'minimumViewTime': 50}, onViewableItemsChanged: env0_13}, {viewabilityConfig: {'waitForInteraction': false,
|
|
'viewAreaCoveragePercentThreshold': 50, 'minimumViewTime': 1000}, onViewableItemsChanged: env0_14},
|
|
{viewabilityConfig: {'waitForInteraction': false, 'viewAreaCoveragePercentThreshold': 50,
|
|
'minimumViewTime': 50}, onViewableItemsChanged: env0_15}];
|
|
}
|
|
|
|
function _fun112214() { // fn#112214, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:3084, offset: 0x023bf536, size: 37 bytes, params: 1, frame: 11
|
|
const value = environment.__proto__;
|
|
(importDefault(9580) /* metro dependency 9580: ICYMIActionCreators */).openICYMITab();
|
|
}
|
|
|
|
function _fun112215() { // fn#112215, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:3172, offset: 0x023bf55b, size: 432 bytes, params: 1, frame: 18
|
|
var environment;
|
|
var notificationItemBinding;
|
|
var push;
|
|
var object2;
|
|
var value5;
|
|
var moduleValue;
|
|
const items2 = [];
|
|
if (env0_6 && notificationItem != null && notificationItem.type === (require(7230) /* metro dependency 7230: ICYMITypes */).ICYMIItemTypes.CUSTOM_STATUS) {
|
|
push = items2.push;
|
|
object2 = {};
|
|
notificationItemBinding = notificationItem;
|
|
object2.id = notificationItemBinding.id;
|
|
object2.timestamp = global.Date.now();
|
|
value5 = environment.__proto__;
|
|
moduleValue = require(9579) /* metro dependency 9579: ICYMIUtils */;
|
|
object2.data = {kind: 'contentInventory',
|
|
content: moduleValue.customStatusToContentInventoryEntry(notificationItemBinding).activity};
|
|
object2.score = notificationItemBinding.score;
|
|
object2.unread = true;
|
|
Reflect.apply(push, items2, [object2]);
|
|
}
|
|
if (env0_6) {
|
|
items2.push({'id': 'loading', 'timestamp': 0, 'unread': false, data: {kind: 'loading'}});
|
|
} else {
|
|
unreadItems.forEach(_fun112216);
|
|
if (allUnreadItemsHydrated) {
|
|
items2.push({'id': 'end', 'timestamp': 0, 'unread': false, data: {kind: 'end'}});
|
|
}
|
|
if (readItems.length > 0) {
|
|
readItems.forEach(_fun112217);
|
|
}
|
|
if (env0_8) {
|
|
items2.push({'id': 'bottomLoading', 'timestamp': 0, 'unread': false, data: {kind: 'bottomLoading'}});
|
|
}
|
|
}
|
|
return {data: items2, stickyHeaderIndices: []};
|
|
}
|
|
|
|
function _fun112205(a0) { // fn#112205, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:1678, offset: 0x023bf2be, size: 56 bytes, params: 2, frame: 13
|
|
const object2 = {};
|
|
object2.id = a0.id;
|
|
const value = environment.__proto__.__proto__;
|
|
object2.type = (require(7230) /* metro dependency 7230: ICYMITypes */).typeToString(a0);
|
|
return object2;
|
|
}
|
|
|
|
function _fun112209({item, index}) { // fn#112209, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:2061, offset: 0x023bf3eb, size: 137 bytes, params: 2, frame: 14
|
|
const object2 = {};
|
|
object2.itemId = item.id;
|
|
let value = environment.__proto__.__proto__;
|
|
object2.itemType = (require(9579) /* metro dependency 9579: ICYMIUtils */).itemToType(item);
|
|
object2.triggerType = 'list';
|
|
object2.itemFeedIndex = index;
|
|
const score = item.score;
|
|
value = null;
|
|
object2.itemScore = value != score ? score : value;
|
|
const channelType = item.channelType;
|
|
object2.itemChannelType = value != channelType ? channelType : value;
|
|
object2.isInitiallyVisible = false;
|
|
return object2;
|
|
}
|
|
|
|
function _fun112216(a0) { // fn#112216, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:3493, offset: 0x023bf70b, size: 61 bytes, params: 2, frame: 12
|
|
let value = environment.__proto__.__proto__;
|
|
value = require(9579) /* metro dependency 9579: ICYMIUtils */;
|
|
if (!value.isItemNSFW(a0)) {
|
|
env0_0.push(a0);
|
|
}
|
|
}
|
|
|