decord/source/modules/messages/native/MessagesHooks.tsx
github-actions ecf26fc058 chore: update source for alpha 347.2
Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4823.js (118.4 MB)
2026-09-16 07:03:15 +00:00

177 lines
6.8 KiB
TypeScript

// Module ID: 11622
// Function ID: 11623
// Name: MessagesHooks
// Dependencies: [32, 19, 17, 11454, 9628, 4980, 1980, 4678, 504, 12, 558, 7273, 1370, 7849, 11623, 11398, 11624, 2]
// Exports: useChatUpdatesQueue, useFetchMessageApplications, useFetchVoiceChannelInviteStartTimes, useMessageAuthorActivities, useMessagesLifecycle, useMessagesState, useScrollState
// Module 11622 (MessagesHooks)
import _modDef12 from "module_12" /* 12 */;
import GlobalUtils from "GlobalUtils" /* 1370 */;
import ApplicationActionCreatorsDefault from "ApplicationActionCreators" /* 7273 */;
import InviteTypeUtils from "InviteTypeUtils" /* 7849 */;
import messages_MessagesUtils from "messages/MessagesUtils" /* 11398 */;
import ChatUpdatesQueueDefault from "ChatUpdatesQueue" /* 11624 */;
import _slicedToArray from "module_32" /* 32 */;
import noop from "module_19" /* 19 */;
import VoiceChannelStartTimeStore from "VoiceChannelStartTimeStore" /* 11454 */;
import GuildAvailabilityStore from "GuildAvailabilityStore" /* 4980 */;
import GuildStore from "GuildStore" /* 1980 */;
import PresenceStore from "PresenceStore" /* 4678 */;
const require = globalThis.__r;
require = fn;
const findNodeHandle = fn(17).findNodeHandle;
let closure_7 = fn(9628).updateShouldShowJumpToPresentButton;
const size = fn(2);
let result = size.fileFinishedImporting("modules/messages/native/MessagesHooks.tsx");
export const useMessageAuthorActivities = function useMessageAuthorActivities(arg0) {
_require = arg0;
const items = [arg0];
const memo = noop.useMemo(() => {
const obj = {};
const item = closure_0.forEach((author) => {
if (tmp) {
obj[author.author.id] = null;
}
});
return obj;
}, items);
const items1 = [PresenceStore];
const items2 = [memo];
return require("initialize").useStateFromStoresObject(items1, () => _modDef12.mapValues(memo, (arg0, arg1) => primaryActivity.getPrimaryActivity(arg1)), items2);
};
export const useFetchMessageApplications = function useFetchMessageApplications(arg0) {
closure_0 = arg0;
const items = [arg0];
const memo = noop.useMemo(() => {
const set = new Set();
const item = closure_0.forEach((applicationId) => {
if (tmp) {
set.add(applicationId.applicationId);
}
});
return Array.from(set);
}, items);
noop.useRef([]);
const items1 = [memo];
const effect = noop.useEffect(() => {
if (!obj.areArraysShallowEqual(memo, ref.current)) {
const obj2 = ApplicationActionCreatorsDefault;
const found = _modDef12(tmp3).filter(GlobalUtils.isNotNullish);
const arr = _modDef12(tmp3);
const applications = obj2.fetchApplications(found.uniq().value(), false);
ref.current = tmp3;
const iter = found.uniq();
}
}, items1);
};
export const useFetchVoiceChannelInviteStartTimes = function useFetchVoiceChannelInviteStartTimes(stateFromStores4) {
_require = stateFromStores4;
const items = [GuildStore, GuildAvailabilityStore];
const items1 = [stateFromStores4];
const stateFromStoresObject = require("initialize").useStateFromStoresObject(items, () => {
const obj = {};
const values = stateFromStores4.values();
const iter = values[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp3 = nextResult;
if (null != nextResult.guild) {
let obj2 = InviteTypeUtils;
if (obj2.isVoiceChannelInvite(tmp3)) {
let id = tmp3.guild.id;
let tmp8 = id;
let tmp10 = null != GuildStore.getGuild(id);
if (tmp10) {
tmp10 = !GuildAvailabilityStore.isUnavailable(tmp8);
}
obj[id] = tmp10;
}
}
continue;
}
return obj;
}, items1);
const items2 = [stateFromStores4, stateFromStoresObject];
const effect = noop.useEffect(() => {
const values = stateFromStores4.values();
const iter = values[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp3 = nextResult;
if (null != nextResult.guild) {
let tmp4 = require;
let obj = InviteTypeUtils;
if (obj.isVoiceChannelInvite(tmp3)) {
let id = tmp3.guild.id;
let tmp8 = id;
let result = true !== stateFromStoresObject[id];
if (!result) {
result = VoiceChannelStartTimeStore.hasRequestedStartTimes(tmp8);
}
if (!result) {
let tmp4Result = tmp4(11623);
let channelInfo = tmp4Result.fetchChannelInfo(tmp8);
}
}
}
continue;
}
}, items2);
};
export const useMessagesLifecycle = function useMessagesLifecycle(screenIndex) {
({ messages: require, isMessagesReady: importDefault, oldestUnreadMessageId: dependencyMap, channelId } = screenIndex);
screenIndex = screenIndex.screenIndex;
({ updateRows: findNodeHandle, scrollToMessageId: VoiceChannelStartTimeStore } = screenIndex);
const effect = screenIndex.useEffect(() => {
messages_MessagesUtils.syncMessageDisplay({ messages, isMessagesReady, oldestUnreadMessageId, channelId, screenIndex, updateRows, scrollToMessageId });
const obj2 = { messages, isMessagesReady, oldestUnreadMessageId, channelId, screenIndex, updateRows, scrollToMessageId };
messages_MessagesUtils.recordTimings(channelId, messages);
}, []);
const items = [channelId, screenIndex];
const effect1 = screenIndex.useEffect(() => () => {
closure_2_7(channelId, screenIndex, false);
}, items);
};
export const useScrollState = function useScrollState() {
const tmp = _slicedToArray(noop.useState({ animated: false, hasHandledScroll: false, isAtBottom: false, isNearBottom: false, isNearTop: false, decelerating: false, dragging: false, hasMoreMessagesAfterForLastUpdate: false, _loaded: false }), 2);
closure_0 = tmp[1];
const items = [
tmp[0],
noop.useCallback((arg0) => {
closure_0 = arg0;
closure_0((arg0) => {
const merged = Object.assign(arg0);
const merged1 = Object.assign(closure_0);
return {};
});
}, [])
];
return items;
};
export const useChatUpdatesQueue = function useChatUpdatesQueue(ref5, callback) {
closure_0 = ref5;
closure_1 = callback;
const items = [ref5, callback];
const memo = noop.useMemo(() => new ChatUpdatesQueueDefault(() => {
let tmp2 = null;
if (null !== ref.current) {
tmp2 = findNodeHandle(tmp.current);
}
return tmp2;
}, (arg0) => {
callback(arg0);
}), items);
const items1 = [memo];
const effect = noop.useEffect(() => () => {
memo.cleanup();
}, items1);
return memo;
};
export const useMessagesState = function useMessagesState() {
[tmp2, tmp3] = noop.useState(false);
const tmp4 = _slicedToArray(noop.useState(false), 2);
return { shouldForceRender: tmp2, hasJumpedToOriginalPost: tmp4[0], setHasJumpedToOriginalPost: tmp4[1], setShouldForceRender: tmp3 };
};