327 lines
19 KiB
TypeScript
327 lines
19 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] */
|
|
import Module00057 from '../../by-id/module-00057.js'; /* Metro dependency 57 */
|
|
import UsePrevValue from '../../hooks/usePrevValue.tsx'; /* Metro dependency 8819 */
|
|
import ICYMIStore from './ICYMIStore.tsx'; /* Metro dependency 9569 */
|
|
import ICYMIActionCreators from './ICYMIActionCreators.tsx'; /* Metro dependency 9580 */
|
|
import UseICYMIItems from './useICYMIItems.tsx'; /* Metro dependency 14849 */
|
|
import * as FileImportTrackerModule from '../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
|
|
import * as ReactModule from '../../by-id/module-00031-React.js'; /* Metro dependency 31 */
|
|
import * as FluxModule from '../../external/discord_common/js/packages/flux/index.tsx'; /* Metro dependency 566 */
|
|
import * as ICYMIConstantsModule from './ICYMIConstants.tsx'; /* Metro dependency 14814 */
|
|
import * as UseICYMIReloadHandlerModule from './useICYMIReloadHandler.tsx'; /* Metro dependency 14850 */
|
|
|
|
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});
|
|
(FileImportTrackerModule).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
|
|
let useState = ReactModule.useState;
|
|
const value2 = Reflect.apply(useState, ReactModule, [false]);
|
|
const value3 = Module00057(value2, 2);
|
|
const property = value3[0];
|
|
const property2 = value3[1];
|
|
const {unreadItems, readItems,
|
|
allUnreadItemsHydrated} = (UseICYMIItems)();
|
|
const useStateFromStores = FluxModule.useStateFromStores;
|
|
let icymiStoreBinding = ICYMIStore;
|
|
const value = Reflect.apply(useStateFromStores, FluxModule, [[icymiStoreBinding], function() {
|
|
return ICYMIStore.getVersion();
|
|
}, []]);
|
|
const value5 = FluxModule.useStateFromStores([icymiStoreBinding], _fun112195);
|
|
ReactModule.useEffect(function() {
|
|
if (ICYMIStore.getLoadId() != null) {
|
|
require(dependencyMap[6]).ICYMIAnalytics.trackFeedShown({homeSessionId: 'gravity'});
|
|
}
|
|
}, [value]);
|
|
const value6 = FluxModule.useStateFromStores([icymiStoreBinding], function() {
|
|
return ICYMIStore.isRefreshing();
|
|
}, []);
|
|
const value7 = FluxModule.useStateFromStores([icymiStoreBinding], function() {
|
|
return ICYMIStore.isHydrating();
|
|
}, []);
|
|
useState = ReactModule.useState;
|
|
const value8 = Module00057(Reflect.apply(useState, ReactModule, [[]]), 2);
|
|
const property3 = value8[0];
|
|
const env0_9 = value8[1];
|
|
const {loadId, lastScrollEventTimestamp} = FluxModule.useStateFromStoresObject([icymiStoreBinding], function() {
|
|
var object = {};
|
|
var icymiStoreBinding = ICYMIStore;
|
|
object.loadId = icymiStoreBinding.getLoadId();
|
|
object.lastScrollEventTimestamp = icymiStoreBinding.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();
|
|
ReactModule.useEffect(_fun112202, [value6, lastScrollEventTimestamp,
|
|
(UsePrevValue)(value12), value12, loadId, value5]);
|
|
const value17 = ReactModule.useMemo(_fun112213, [ReactModule.useCallback(_fun112203, [value, property2]),
|
|
ReactModule.useCallback(_fun112206, [value]), ReactModule.useCallback(_fun112210, [])]);
|
|
ReactModule.useEffect(_fun112214, []);
|
|
const value18 = (UseICYMIReloadHandlerModule).useICYMIReloadHandler(showDot);
|
|
const value19 = ReactModule.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 (!ICYMIConstantsModule.SCROLL_EVENT_THROTTLE_MS) {
|
|
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 object;
|
|
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;
|
|
object = {};
|
|
id = property.id;
|
|
object.id = id;
|
|
moduleValue2 = require(7230) /* metro dependency 7230: ICYMITypes */;
|
|
object.type = moduleValue2.typeToString(property);
|
|
value6 = typeof r3 === 'bigint' ? r3 : +r3;
|
|
value7 = typeof value6 === 'bigint' ? value6 + 1n : +value6 + 1;
|
|
object.timestamp = value6;
|
|
Reflect.apply(push, items2, [object]);
|
|
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 _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 object = {};
|
|
object.id = a0.id;
|
|
const value = environment.__proto__.__proto__;
|
|
object.type = (require(7230) /* metro dependency 7230: ICYMITypes */).typeToString(a0);
|
|
return object;
|
|
}
|
|
|
|
}
|
|
|
|
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 _fun112207(a0) { // fn#112207, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:1894, offset: 0x023bf2be, size: 56 bytes, params: 2, frame: 13
|
|
const object = {};
|
|
object.id = a0.id;
|
|
const value = environment.__proto__.__proto__;
|
|
object.type = (require(7230) /* metro dependency 7230: ICYMITypes */).typeToString(a0);
|
|
return object;
|
|
}
|
|
|
|
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 object = {};
|
|
object.itemId = item.id;
|
|
let value = environment.__proto__.__proto__;
|
|
object.itemType = (require(9579) /* metro dependency 9579: ICYMIUtils */).itemToType(item);
|
|
object.triggerType = 'list';
|
|
object.itemFeedIndex = index;
|
|
const score = item.score;
|
|
value = null;
|
|
object.itemScore = value != score ? score : value;
|
|
const channelType = item.channelType;
|
|
object.itemChannelType = value != channelType ? channelType : value;
|
|
object.isInitiallyVisible = false;
|
|
return object;
|
|
}
|
|
|
|
}
|
|
|
|
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 _fun112212({item, index}) { // fn#112212, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:2438, offset: 0x023bf3eb, size: 137 bytes, params: 2, frame: 14
|
|
const object = {};
|
|
object.itemId = item.id;
|
|
let value = environment.__proto__.__proto__;
|
|
object.itemType = (require(9579) /* metro dependency 9579: ICYMIUtils */).itemToType(item);
|
|
object.triggerType = 'list';
|
|
object.itemFeedIndex = index;
|
|
const score = item.score;
|
|
value = null;
|
|
object.itemScore = value != score ? score : value;
|
|
const channelType = item.channelType;
|
|
object.itemChannelType = value != channelType ? channelType : value;
|
|
object.isInitiallyVisible = false;
|
|
return object;
|
|
}
|
|
|
|
}
|
|
|
|
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__;
|
|
(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 object;
|
|
var value5;
|
|
var moduleValue;
|
|
const items2 = [];
|
|
if (ICYMIConstantsModule.SCROLL_EVENT_THROTTLE_MS && notificationItem != null && notificationItem.type === (require(7230) /* metro dependency 7230: ICYMITypes */).ICYMIItemTypes.CUSTOM_STATUS) {
|
|
push = items2.push;
|
|
object = {};
|
|
notificationItemBinding = notificationItem;
|
|
object.id = notificationItemBinding.id;
|
|
object.timestamp = global.Date.now();
|
|
value5 = environment.__proto__;
|
|
moduleValue = require(9579) /* metro dependency 9579: ICYMIUtils */;
|
|
object.data = {kind: 'contentInventory',
|
|
content: moduleValue.customStatusToContentInventoryEntry(notificationItemBinding).activity};
|
|
object.score = notificationItemBinding.score;
|
|
object.unread = true;
|
|
Reflect.apply(push, items2, [object]);
|
|
}
|
|
if (ICYMIConstantsModule.SCROLL_EVENT_THROTTLE_MS) {
|
|
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 _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);
|
|
}
|
|
}
|
|
|
|
function _fun112217(a0) { // fn#112217, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:15045:3619, 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);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
global.__d(_fun112192, 14848, [57, 31, 9569, 14814, 14849, 566, 9589, 9586, 8819, 9580, 9579, 7230, 14850,
|
|
2]) /* metro module 14848, dependencies: [57, 31, 9569, 14814, 14849, 566, 9589, 9586, 8819, 9580, 9579, 7230, 14850, 2] */;
|