decord/beta/source/modules/notification_center/useNotificationCenterItemsLoader.tsx

226 lines
7.8 KiB
TypeScript
Raw Normal View History

// Module ID: 16050
// Function ID: 16051
// Name: useNotificationCenterItemsLoader
// Dependencies: [5, 32, 19, 7051, 7053, 16049, 5018, 504, 16051, 6531, 7695, 2]
// Exports: useNotificationCenterItemsLoader
// Module 16050 (useNotificationCenterItemsLoader)
2026-10-01 14:13:23 +00:00
import ReadStateConstants from "ReadStateConstants" /* 5018 */;
import ReadStateActionCreators from "ReadStateActionCreators" /* 6531 */;
import NotificationCenterItemsActions from "NotificationCenterItemsActions" /* 16051 */;
2026-10-01 14:13:23 +00:00
import _asyncToGenerator from "_asyncToGenerator" /* 5 */;
import _slicedToArray from "_slicedToArray" /* 32 */;
import react from "react" /* 19 */;
import RecentMentionsStore from "RecentMentionsStore" /* 7051 */;
import NotificationCenterItemsStore from "NotificationCenterItemsStore" /* 7053 */;
import NotificationCenterStore from "NotificationCenterStore" /* 16049 */;
2026-10-01 14:13:23 +00:00
import size from "module_2" /* 2 */;
2026-10-01 14:13:23 +00:00
let c2, with_mentions;
2026-10-01 14:13:23 +00:00
const ReadStateTypes = ReadStateConstants.ReadStateTypes;
let result = size.fileFinishedImporting("modules/notification_center/useNotificationCenterItemsLoader.tsx");
export const PAGE_SIZE_WITH_MENTIONS = 8;
export const PAGE_SIZE = 20;
export const useNotificationCenterItemsLoader = function useNotificationCenterItemsLoader(isFocused) {
2026-10-01 14:13:23 +00:00
let _undefined;
let c7;
let tmp3;
isFocused = isFocused.isFocused;
const navigatedAway = isFocused.navigatedAway;
const isDesktop = isFocused.isDesktop;
let flag = isFocused.withMentions;
if (flag === undefined) {
flag = false;
}
const initialPageSize = isFocused.initialPageSize;
c7 = undefined;
let initialized;
2026-10-01 14:13:23 +00:00
let obj = isFocused(isDesktop[7]);
const items1 = [initialized];
2026-10-01 14:13:23 +00:00
const stateFromStores = obj.useStateFromStores(items1, () => initialized.shouldReload());
let closure_6 = stateFromStores.useRef(false);
let tmp2 = initialPageSize(stateFromStores.useState(false), 2);
2026-10-01 14:13:23 +00:00
[tmp3, c7] = tmp2;
let obj2 = isFocused(isDesktop[7]);
const items2 = [c7];
2026-10-01 14:13:23 +00:00
const stateFromStoresObject = obj2.useStateFromStoresObject(items2, () => ({ initialized: _undefined.initialized, loading: _undefined.loading, items: _undefined.items, hasMore: _undefined.hasMore, cursor: _undefined.cursor, errored: _undefined.errored }));
initialized = stateFromStoresObject.initialized;
const items = stateFromStoresObject.items;
const hasMore = stateFromStoresObject.hasMore;
const cursor = stateFromStoresObject.cursor;
const errored = stateFromStoresObject.errored;
2026-10-01 14:13:23 +00:00
const loading = stateFromStoresObject.loading;
let obj3 = isFocused(isDesktop[7]);
const items3 = [closure_6];
2026-10-01 14:13:23 +00:00
const stateFromStoresObject1 = obj3.useStateFromStoresObject(items3, () => ({ everyoneFilter: closure_6.everyoneFilter, roleFilter: closure_6.roleFilter }));
const roleFilter = stateFromStoresObject1.roleFilter;
const everyoneFilter = stateFromStoresObject1.everyoneFilter;
const effect = stateFromStores.useEffect(() => {
2026-10-01 14:13:23 +00:00
let obj = isFocused(isDesktop[8]);
const result = obj.setNotificationCenterActive(true);
return () => {
const obj = isFocused(isDesktop[8]);
return obj.setNotificationCenterActive(false);
};
}, []);
const items4 = [isFocused, initialized];
const effect1 = stateFromStores.useEffect(() => {
2026-10-01 14:13:23 +00:00
const tmp = initialized && isFocused;
if (tmp) {
2026-10-01 14:13:23 +00:00
const obj = ReadStateActionCreators;
obj.ackUserFeature(ReadStateTypes.NOTIFICATION_CENTER);
}
}, items4);
2026-10-01 14:13:23 +00:00
const tmp8 = navigatedAway(isDesktop[10])();
let closure_15 = tmp8;
const items5 = [navigatedAway, items, isDesktop, tmp8, errored];
const effect2 = stateFromStores.useEffect(() => () => {
2026-10-01 14:13:23 +00:00
const tmp = closure_1_2;
if (tmp) {
let tmp9 = !closure_1_15();
closure_1_15();
if (tmp9) {
tmp9 = errored || items.length > 100;
const tmp10 = errored || items.length > 100;
}
2026-10-01 14:13:23 +00:00
if (tmp9) {
const obj2 = isFocused(isDesktop[8]);
const result = obj2.resetNotificationCenter();
}
} else {
2026-10-01 14:13:23 +00:00
const tmp2 = navigatedAway && items.length > 100;
if (tmp2) {
const obj = isFocused(isDesktop[8]);
const result1 = obj.resetNotificationCenter();
}
}
}, items5);
const items6 = [initialized, stateFromStores, isFocused, flag, roleFilter, everyoneFilter, initialPageSize];
const effect3 = stateFromStores.useEffect(() => {
let tmp = !initialized;
if (initialized) {
2026-10-01 14:13:23 +00:00
tmp = stateFromStores && isFocused;
}
if (tmp) {
2026-10-01 14:13:23 +00:00
let tmp6 = initialPageSize;
const fetchNotificationCenterItems = NotificationCenterItemsActions.fetchNotificationCenterItems;
NotificationCenterItemsActions;
if (initialPageSize == null) {
let num = 20;
if (flag) {
num = 8;
}
2026-10-01 14:13:23 +00:00
tmp6 = num;
}
2026-10-01 14:13:23 +00:00
const obj = { limit: tmp6, with_mentions: flag, roles_filter: roleFilter, everyone_filter: everyoneFilter };
const notificationCenterItems = fetchNotificationCenterItems(obj);
}
}, items6);
2026-10-01 14:13:23 +00:00
const useCallback = stateFromStores.useCallback;
let closure_0 = flag(function*(arg0, value) {
let num7;
closure_0 = arg0;
if (with_mentions === 2) {
with_mentions = 3;
throw new TypeError("Generator functions may not be called on executing generators");
2026-10-01 14:13:23 +00:00
} else if (tmp3 === 3) {
if (arg0 === 1) {
throw value;
} else if (arg0 === 2) {
2026-10-01 14:13:23 +00:00
const obj2 = { value, done: true };
return obj2;
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
with_mentions = 2;
if (0 === c2) {
if (arg0 === 1) {
with_mentions = 3;
throw value;
} else if (arg0 === 2) {
with_mentions = 3;
2026-10-01 14:13:23 +00:00
const obj3 = { value, done: true };
return obj3;
} else {
2026-10-01 14:13:23 +00:00
let closure_1 = tmp;
let current = ref.current;
2026-10-01 14:13:23 +00:00
const tmp27 = ref;
if (!current) {
current = !initialized;
}
if (!current) {
current = !hasMore;
}
if (!current) {
current = null == after;
}
if (!current) {
2026-10-01 14:13:23 +00:00
let tmp12 = !tmp26;
if (!closure_0) {
tmp12 = errored;
}
2026-10-01 14:13:23 +00:00
current = tmp12;
}
2026-10-01 14:13:23 +00:00
if (!current) {
tmp27.current = true;
_undefined(true);
2026-10-01 14:13:23 +00:00
const obj4 = { after, with_mentions, roles_filter, everyone_filter, limit: num7 };
num7 = 20;
const fetchNotificationCenterItems = closure_0(isDesktop[8]).fetchNotificationCenterItems;
const tmp17 = closure_0(isDesktop[8]);
if (with_mentions) {
num7 = 8;
}
c2 = 1;
with_mentions = 1;
2026-10-01 14:13:23 +00:00
const obj5 = {
value: fetchNotificationCenterItems(obj4, () => {
ref.current = false;
}),
done: false
};
2026-10-01 14:13:23 +00:00
return obj5;
}
}
} else if (arg0 === 1) {
with_mentions = 3;
throw value;
2026-10-01 14:13:23 +00:00
} else if (arg0 === 2) {
with_mentions = 3;
const obj = { value, done: true };
return obj;
} else {
_undefined(false);
}
with_mentions = 3;
2026-10-01 14:13:23 +00:00
return { value: "HermesInternal", done: null };
} catch (tmp22) {
2026-10-01 14:13:23 +00:00
with_mentions = 3;
throw tmp22;
}
}
});
const items7 = [initialized, hasMore, cursor, errored, flag, roleFilter, everyoneFilter];
2026-10-01 14:13:23 +00:00
let obj4 = {
initialized,
2026-10-01 14:13:23 +00:00
loading,
items,
hasMore,
2026-10-01 14:13:23 +00:00
loadMore: useCallback(function() {
return closure_0(...arguments);
}, items7),
loadingMore: tmp3,
2026-10-01 14:13:23 +00:00
setReadNotifItemToAcked(acked) {
if (!acked.acked) {
acked.acked = true;
}
},
errored
};
2026-10-01 14:13:23 +00:00
return obj4;
};