589 lines
21 KiB
TypeScript
589 lines
21 KiB
TypeScript
// Metro module 9133 (f9134).
|
|
import { useEffect, useMemo, useRef } from "react";
|
|
import EmojiStore from "../emojis/EmojiStore";
|
|
import ActiveJoinedThreadsStore from "../threads/ActiveJoinedThreadsStore";
|
|
import ActiveThreadsStore from "../threads/ActiveThreadsStore";
|
|
import ThreadMessageStore from "../threads/ThreadMessageStore";
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import GuildMemberRequesterStore from "../../stores/GuildMemberRequesterStore";
|
|
import GuildStore from "../../stores/GuildStore";
|
|
import PermissionStore from "../../stores/PermissionStore";
|
|
import ReadStateStore from "../../stores/ReadStateStore";
|
|
import UserStore from "../../stores/UserStore";
|
|
import ForumActivePostStore from "./ForumActivePostStore";
|
|
import ForumPostMessagesStore from "./ForumPostMessagesStore";
|
|
import ForumPostUnreadCountStore from "./ForumPostUnreadCountStore";
|
|
import ForumSearchStore from "./ForumSearchStore";
|
|
import { ForumTimestampFormats } from "./ForumConstants";
|
|
import { Permissions, EMPTY_STRING_SNOWFLAKE_ID, AnalyticsObjects, AnalyticsObjectTypes } from "../../Constants";
|
|
import { ChannelFlags } from "../channel/ChannelConstants";
|
|
import { MAX_THREAD_UNREAD_MESSAGE_COUNT } from "../threads/ThreadConstants";
|
|
import { useStateFromStores, useStateFromStoresArray, useStateFromStoresObject } from "../../_bundle/Module589";
|
|
import { canDisplayPostUnreadMessageCount, getForumTimestampFormatter, getForumPostReadStates } from "./ForumUtils";
|
|
import Dispatcher from "../../Dispatcher";
|
|
import Module12 from "../../_bundle/Module12";
|
|
import { isNotNullish } from "../../utils/GlobalUtils";
|
|
import useMountEffect from "../../hooks/useMountEffect";
|
|
import SnowflakeUtils from "../../utils/SnowflakeUtils";
|
|
import { useLastMessageTimestamp, getTimestampString } from "../threads/ThreadUtils";
|
|
import { ThreadSortOrder } from "../../_bundle/Module1381";
|
|
import { getMessageCountText } from "../threads/MessageCountUtils";
|
|
import { useNullableMessageAuthor, useNullableUserAuthor, getUserAuthor } from "../messages/useMessageAuthor";
|
|
import renderMessageMarkup from "../messages/renderMessageMarkup";
|
|
import { useFindFirstMediaProperties, useFirstMediaIsEmbed } from "./ForumPostMediaUtils";
|
|
import ForumActionCreators from "./ForumActionCreators";
|
|
import { ackChannel } from "../../actions/ReadStateActionCreators";
|
|
function $mk81928() {
|
|
return (a0) => a0.count + a0.burst_count;
|
|
}
|
|
function $mk81929() {
|
|
return (a0) => a0.burst_count;
|
|
}
|
|
function $mk81930($env) {
|
|
return () => {
|
|
const r2 = $env[0];
|
|
return r2?.emojiId != null ? $env.$parent[5].getUsableCustomEmojiById(r2.emojiId) : null;
|
|
};
|
|
}
|
|
function $mk81931($env) {
|
|
return () => {
|
|
const r0 = $env.$parent;
|
|
return r0[12].can(r0[23].READ_MESSAGE_HISTORY, $env[0]);
|
|
};
|
|
}
|
|
function $mk81932($env) {
|
|
return () => {
|
|
const r3 = $env.$parent[18];
|
|
const r5 = $env[0];
|
|
return {
|
|
isSearchLoading: r3.getSearchLoading(r5),
|
|
searchQuery: r3.getSearchQuery(r5),
|
|
searchResults: r3.getSearchResults(r5)
|
|
};
|
|
};
|
|
}
|
|
function $mk81933($env) {
|
|
return () => {
|
|
let r1, r44;
|
|
const r10 = $env;
|
|
const r14 = $env.$parent;
|
|
const r12 = r14[9];
|
|
const r11 = r10[1];
|
|
const channel2 = r12.getChannel(r11);
|
|
if (channel2 == null ? void 0 : channel2.isForumLikeChannel()) {
|
|
const r21 = r14[6];
|
|
const r23 = r10[0];
|
|
const activeJoinedUnreadThreadsForParent = r21.getActiveJoinedUnreadThreadsForParent(r23, r11);
|
|
const activeUnjoinedUnreadThreadsForParent = r21.getActiveUnjoinedUnreadThreadsForParent(r23, r11);
|
|
const r28 = r14[13].ackMessageId(r11);
|
|
if (r28 == null) {
|
|
return 0;
|
|
}
|
|
let r0 = 0;
|
|
let r30 = 0;
|
|
for (const key in activeJoinedUnreadThreadsForParent) {
|
|
r1 = r0;
|
|
r30 = r1;
|
|
const r36 = r14[13].lastMessageId(activeJoinedUnreadThreadsForParent[key].channel.id);
|
|
r0 = r36 != null && r36 > r28 ? r1 + 1 : r1;
|
|
}
|
|
r1 = r0;
|
|
r30 = r1;
|
|
let r39 = r30;
|
|
let r40 = r39;
|
|
for (const key2 in activeUnjoinedUnreadThreadsForParent) {
|
|
r44 = r39;
|
|
r40 = r44;
|
|
const r51 = r14[13].lastMessageId(activeUnjoinedUnreadThreadsForParent[key2].id);
|
|
r39 = r51 != null && r51 > r28 ? r44 + 1 : r44;
|
|
}
|
|
r44 = r39;
|
|
r40 = r44;
|
|
return r40;
|
|
}
|
|
return 0;
|
|
};
|
|
}
|
|
let env5988 = {};
|
|
const c5988_26 = {
|
|
isNew: false,
|
|
hasUnreads: false
|
|
};
|
|
export function useLoadForumUnreadCounts(a0, a1, a2, a3) {
|
|
const stateFromStores = useStateFromStores([ActiveThreadsStore], () => ActiveThreadsStore.hasLoaded(a0.guild_id));
|
|
useEffect(() => {
|
|
if (stateFromStores) {
|
|
const threads = ForumPostUnreadCountStore.getThreadIdsMissingCounts(a0.guild_id, ForumActivePostStore.getThreadIds(a0.id, a1, a2, a3)).filter((item) => canDisplayPostUnreadMessageCount(item, [ReadStateStore])).slice(0, 180).map((item) => ({
|
|
threadId: item,
|
|
ackMessageId: ReadStateStore.getTrackedAckMessageId(item)
|
|
}));
|
|
if (threads.length > 0) {
|
|
Dispatcher.dispatch({
|
|
type: "REQUEST_FORUM_UNREADS",
|
|
guildId: a0.guild_id,
|
|
channelId: a0.id,
|
|
threads
|
|
});
|
|
}
|
|
}
|
|
}, [a0.id, a0.guild_id, stateFromStores, a2, a1, a3]);
|
|
}
|
|
export function useExistingPin(c16992_0) {
|
|
return useStateFromStores([ActiveThreadsStore, ChannelStore], () => ChannelStore.getChannel(Module12(ActiveThreadsStore.getThreadsForParent(c16992_0.guild_id, c16992_0.parent_id)).keys().filter((item) => {
|
|
const channel2 = ChannelStore.getChannel(item);
|
|
return (channel2 == null ? void 0 : channel2.hasFlag(ChannelFlags.PINNED)) === true;
|
|
}).head()));
|
|
}
|
|
export function useFacepileUsers(c16993_0, c16993_1) {
|
|
const stateFromStoresArray = useStateFromStoresArray([UserStore], () => c16993_1.map((item) => UserStore.getUser(item)).filter(isNotNullish));
|
|
useMountEffect(() => {
|
|
stateFromStoresArray.forEach((item) => {
|
|
GuildMemberRequesterStore.requestMember(c16993_0.guild_id, item.id);
|
|
});
|
|
});
|
|
return stateFromStoresArray;
|
|
}
|
|
export function useLastActiveTimestamp(a0, a1) {
|
|
let lastMessageTimestamp, memo2;
|
|
let r2 = arguments[2];
|
|
if (r2 === void 0) {
|
|
r2 = ForumTimestampFormats.DURATION_AGO;
|
|
}
|
|
const DURATION_AGO = r2;
|
|
lastMessageTimestamp = void 0;
|
|
memo2 = void 0;
|
|
const memo = useMemo(() => SnowflakeUtils.extractTimestamp(a0.id), [a0.id]);
|
|
lastMessageTimestamp = useLastMessageTimestamp(a0);
|
|
memo2 = useMemo(() => getForumTimestampFormatter(a1, DURATION_AGO), [a1, DURATION_AGO]);
|
|
return useMemo(() => a1 === ThreadSortOrder.CREATION_DATE ? getTimestampString(memo, memo2) : getTimestampString(lastMessageTimestamp, memo2), [lastMessageTimestamp, a1, memo, memo2]);
|
|
}
|
|
export function useMostUsedReaction(a0) {
|
|
return useMemo(() => {
|
|
let r8 = a0?.reactions;
|
|
if (r8 == null) {
|
|
r8 = [];
|
|
}
|
|
if (r8.length !== 0) {
|
|
return Module12.orderBy(r8, [$mk81928(), $mk81929()], ["desc", "desc"])[0];
|
|
}
|
|
}, [a0?.reactions]);
|
|
}
|
|
export function useDefaultReactionEmoji(a0) {
|
|
const defaultReactionEmoji = a0?.defaultReactionEmoji;
|
|
let env16987;
|
|
const r9 = env16987 = {
|
|
$parent: env5988
|
|
};
|
|
env16987[0] = defaultReactionEmoji;
|
|
const stateFromStores7 = useStateFromStores([EmojiStore], $mk81930(r9));
|
|
return defaultReactionEmoji == null ? null : defaultReactionEmoji.emojiId != null && stateFromStores7 != null ? {
|
|
id: defaultReactionEmoji.emojiId,
|
|
name: stateFromStores7.name,
|
|
animated: stateFromStores7.animated
|
|
} : defaultReactionEmoji.emojiName != null ? {
|
|
id: defaultReactionEmoji.emojiId,
|
|
name: defaultReactionEmoji.emojiName,
|
|
animated: false
|
|
} : null;
|
|
}
|
|
export function useSomeForumPostReactions({ message, parentChannel, count = 1, sorted = true }) {
|
|
let env16997;
|
|
let c16996_1 = sorted;
|
|
const r7 = env16997 = {
|
|
$parent: env5988
|
|
};
|
|
env16997[0] = void 0;
|
|
const defaultReactionEmoji = parentChannel?.defaultReactionEmoji;
|
|
env16997[0] = defaultReactionEmoji;
|
|
const stateFromStores7 = useStateFromStores([EmojiStore], $mk81930(r7));
|
|
const emoji = defaultReactionEmoji == null ? null : defaultReactionEmoji.emojiId != null && stateFromStores7 != null ? {
|
|
id: defaultReactionEmoji.emojiId,
|
|
name: stateFromStores7.name,
|
|
animated: stateFromStores7.animated
|
|
} : defaultReactionEmoji.emojiName != null ? {
|
|
id: defaultReactionEmoji.emojiId,
|
|
name: defaultReactionEmoji.emojiName,
|
|
animated: false
|
|
} : null;
|
|
const memo3 = useMemo(() => {
|
|
let r8 = message?.reactions;
|
|
if (r8 == null) {
|
|
r8 = [];
|
|
}
|
|
return c16996_1 ? Module12.orderBy(r8, [$mk81928(), $mk81929()], ["desc", "desc"]) : r8;
|
|
}, [message?.reactions, sorted]);
|
|
let r42 = emoji != null ? [{
|
|
emoji,
|
|
me: false,
|
|
count: 0,
|
|
burst_count: 0,
|
|
me_burst: false
|
|
}] : [];
|
|
if (memo3.length > 0) {
|
|
r42 = memo3;
|
|
}
|
|
return {
|
|
reactions: r42.slice(0, count),
|
|
additionalNonUniqueReactionCount: Module12.sum(r42.slice(count, r42.length).map((item) => item.count + item.burst_count))
|
|
};
|
|
}
|
|
export function useMaxPossibleForumPostReactions({ containerWidth, reactionEmojiWidth, digitWidth, message: message2, parentChannel }) {
|
|
let length;
|
|
let env16999;
|
|
const r22 = env16999 = {
|
|
$parent: env5988
|
|
};
|
|
env16999[0] = void 0;
|
|
const defaultReactionEmoji = parentChannel?.defaultReactionEmoji;
|
|
env16999[0] = defaultReactionEmoji;
|
|
const stateFromStores7 = useStateFromStores([EmojiStore], $mk81930(r22));
|
|
const emoji = defaultReactionEmoji == null ? null : defaultReactionEmoji.emojiId != null && stateFromStores7 != null ? {
|
|
id: defaultReactionEmoji.emojiId,
|
|
name: stateFromStores7.name,
|
|
animated: stateFromStores7.animated
|
|
} : defaultReactionEmoji.emojiName != null ? {
|
|
id: defaultReactionEmoji.emojiId,
|
|
name: defaultReactionEmoji.emojiName,
|
|
animated: false
|
|
} : null;
|
|
const memo3 = useMemo(() => {
|
|
let r7 = message2?.reactions;
|
|
if (r7 == null) {
|
|
r7 = [];
|
|
}
|
|
return Module12.orderBy(r7, [$mk81928(), $mk81929()], ["desc", "desc"]);
|
|
}, [message2?.reactions]);
|
|
let r49 = emoji != null ? [{
|
|
emoji,
|
|
me: false,
|
|
count: 0,
|
|
burst_count: 0,
|
|
me_burst: false
|
|
}] : [];
|
|
if (memo3.length > 0) {
|
|
r49 = memo3;
|
|
}
|
|
const r54 = 0 < r49.length;
|
|
let r0 = 0;
|
|
let r56 = 0;
|
|
let r1 = 0;
|
|
let r4 = 0;
|
|
if (r54) {
|
|
do {
|
|
const r57 = r49[r0];
|
|
const burst_count = r57.burst_count;
|
|
const r5 = r0;
|
|
const r59 = r56;
|
|
const r3 = r1;
|
|
const r69 = reactionEmojiWidth + digitWidth * Math.ceil(Math.log10((burst_count > 0 ? r57.burst_count : r57.count) + 1));
|
|
const r70 = r59 + r69;
|
|
r4 = r3;
|
|
if (!(r70 < containerWidth)) {
|
|
break;
|
|
}
|
|
r56 = r59 + r69;
|
|
r1 = r3 + 1;
|
|
r0 = r5 + 1;
|
|
length = r49.length;
|
|
r4 = r1;
|
|
} while (r0 < length);
|
|
}
|
|
const r73 = r49.length - r4;
|
|
let r74 = r4;
|
|
let additionalReactionCount = r73;
|
|
if (0 < additionalReactionCount) {
|
|
r74 = r4 - 1;
|
|
additionalReactionCount = r73 + 1;
|
|
}
|
|
return {
|
|
reactions: r49.slice(0, r74),
|
|
additionalReactionCount
|
|
};
|
|
}
|
|
export function useMessageCount(a0) {
|
|
let stateFromStores3;
|
|
const stateFromStores2 = useStateFromStores([ThreadMessageStore], () => {
|
|
let r8 = ThreadMessageStore.getCount(a0.id);
|
|
if (r8 == null) {
|
|
r8 = 0;
|
|
}
|
|
return r8;
|
|
});
|
|
const messageCountText = getMessageCountText(stateFromStores2, a0.id);
|
|
stateFromStores3 = useStateFromStores([ReadStateStore], () => canDisplayPostUnreadMessageCount(a0.id, [ReadStateStore]));
|
|
return {
|
|
messageCount: stateFromStores2,
|
|
isMaxMessageCount: stateFromStores2 != null && `${stateFromStores2}` !== messageCountText,
|
|
messageCountText,
|
|
unreadCount: useStateFromStores([ForumPostUnreadCountStore], () => {
|
|
if (stateFromStores3) {
|
|
const count = ForumPostUnreadCountStore.getCount(a0.id);
|
|
if (count != null && count > 0) {
|
|
let r16 = Math.min(count, stateFromStores2);
|
|
if (r16 >= MAX_THREAD_UNREAD_MESSAGE_COUNT) {
|
|
r16 = `${MAX_THREAD_UNREAD_MESSAGE_COUNT}+`;
|
|
}
|
|
return r16;
|
|
}
|
|
return "1+";
|
|
}
|
|
return null;
|
|
})
|
|
};
|
|
}
|
|
export function useForumPostMessageAuthor(a0, a1) {
|
|
const id = a0 == null ? void 0 : a0.author?.id;
|
|
const guildId = a1.getGuildId();
|
|
const stateFromStores7 = useStateFromStores([UserStore], () => UserStore.getUser(id));
|
|
const nullableMessageAuthor = useNullableMessageAuthor(a0);
|
|
useEffect(() => {
|
|
if (id != null && guildId != null) {
|
|
GuildMemberRequesterStore.requestMember(guildId, id);
|
|
}
|
|
}, [guildId, id]);
|
|
let authorName = nullableMessageAuthor?.nick;
|
|
if (authorName == null) {
|
|
authorName = stateFromStores7?.username;
|
|
}
|
|
let authorColor = nullableMessageAuthor?.colorString;
|
|
if (authorColor == null) {
|
|
authorColor = null;
|
|
}
|
|
let authorColors = nullableMessageAuthor?.colorStrings;
|
|
if (authorColors == null) {
|
|
authorColors = null;
|
|
}
|
|
return {
|
|
authorName,
|
|
authorColor,
|
|
authorColors,
|
|
user: stateFromStores7
|
|
};
|
|
}
|
|
export function useForumPostAuthor(a0) {
|
|
const stateFromStores7 = useStateFromStores([UserStore], () => UserStore.getUser(a0.ownerId));
|
|
let r25 = useStateFromStores([ForumPostMessagesStore], () => ForumPostMessagesStore.getMessage(a0.id)?.firstMessage)?.author;
|
|
if (r25 == null) {
|
|
r25 = stateFromStores7;
|
|
}
|
|
const nullableUserAuthor = useNullableUserAuthor(r25, a0);
|
|
useEffect(() => {
|
|
if (a0.ownerId != null) {
|
|
GuildMemberRequesterStore.requestMember(a0.guild_id, a0.ownerId);
|
|
}
|
|
}, [a0.guild_id, a0.ownerId]);
|
|
return {
|
|
user: stateFromStores7,
|
|
author: nullableUserAuthor
|
|
};
|
|
}
|
|
export function getForumPostAuthor(a0) {
|
|
const user = UserStore.getUser(a0.ownerId);
|
|
let r21 = ForumPostMessagesStore.getMessage(a0.id)?.firstMessage?.author;
|
|
if (r21 == null) {
|
|
r21 = user;
|
|
}
|
|
return {
|
|
user,
|
|
author: getUserAuthor(r21, a0)
|
|
};
|
|
}
|
|
export function useForumPostFirstMessageMarkup(a0) {
|
|
const { firstMessage, formatInline: formatInline2 = true } = a0;
|
|
const formatInline = formatInline2;
|
|
let noStyleAndInteraction2 = a0.noStyleAndInteraction;
|
|
if (noStyleAndInteraction2 === void 0) {
|
|
noStyleAndInteraction2 = true;
|
|
}
|
|
const noStyleAndInteraction = noStyleAndInteraction2;
|
|
let hasUnreads = a0.hasUnreads;
|
|
if (hasUnreads === void 0) {
|
|
hasUnreads = true;
|
|
}
|
|
const textColor = hasUnreads ? "text-default" : "text-muted";
|
|
const memo3 = useMemo(() => firstMessage?.content != null && firstMessage.content !== "" ? renderMessageMarkup(firstMessage, {
|
|
formatInline,
|
|
noStyleAndInteraction,
|
|
allowHeading: true,
|
|
allowList: true,
|
|
allowGameMentions: true,
|
|
textColor,
|
|
disablePressableChannelMention: true
|
|
}) : {
|
|
hasSpoilerEmbeds: false,
|
|
content: null
|
|
}, [firstMessage, formatInline, noStyleAndInteraction, textColor]);
|
|
const hasSpoilerEmbeds = memo3.hasSpoilerEmbeds;
|
|
return {
|
|
hasSpoilerEmbeds,
|
|
content: memo3.content,
|
|
firstMedia: useFindFirstMediaProperties(firstMessage, hasSpoilerEmbeds),
|
|
firstMediaIsEmbed: useFirstMediaIsEmbed(firstMessage, hasSpoilerEmbeds)
|
|
};
|
|
}
|
|
export function useCanManageChannel(c17004_0) {
|
|
return useStateFromStores([PermissionStore], () => PermissionStore.can(Permissions.MANAGE_CHANNELS, c17004_0));
|
|
}
|
|
export function useForumPostReadStates(c17005_0) {
|
|
return useStateFromStoresObject([GuildStore, ReadStateStore], () => {
|
|
let r9 = c17005_0.getGuildId();
|
|
if (r9 == null) {
|
|
r9 = EMPTY_STRING_SNOWFLAKE_ID;
|
|
}
|
|
const guild = GuildStore.getGuild(r9);
|
|
return guild == null ? c5988_26 : getForumPostReadStates(c17005_0, guild, [ReadStateStore]);
|
|
});
|
|
}
|
|
export function useChannelTemplate(a0) {
|
|
return useMemo(() => a0 == null ? "" : a0.template == null ? "" : a0.template.trim(), [a0]);
|
|
}
|
|
export function useForumThreadsForChannelList(c17007_0) {
|
|
const stateFromStoresObject = useStateFromStoresObject([ActiveJoinedThreadsStore], () => ({
|
|
activeJoinedThreads: ActiveJoinedThreadsStore.getActiveJoinedThreadsForGuild(c17007_0),
|
|
activeUnjoinedThreads: ActiveJoinedThreadsStore.getActiveUnjoinedThreadsForGuild(c17007_0),
|
|
newThreadCounts: ActiveJoinedThreadsStore.getNewThreadCountsForGuild(c17007_0)
|
|
}));
|
|
return {
|
|
activeJoinedThreads: stateFromStoresObject.activeJoinedThreads,
|
|
activeUnjoinedThreads: stateFromStoresObject.activeUnjoinedThreads,
|
|
newThreadCounts: stateFromStoresObject.newThreadCounts
|
|
};
|
|
}
|
|
export function useCanSearchForumPosts(a0) {
|
|
let env16988;
|
|
const r1 = env16988 = {
|
|
$parent: env5988
|
|
};
|
|
env16988[0] = a0;
|
|
return useStateFromStores([PermissionStore], $mk81931(r1));
|
|
}
|
|
export function useCanViewArchivedPosts(c17008_0) {
|
|
return useStateFromStores([PermissionStore], () => PermissionStore.can(Permissions.READ_MESSAGE_HISTORY, c17008_0));
|
|
}
|
|
export function useForumSearchQuery({ channelId }) {
|
|
return useStateFromStores([ForumSearchStore], () => channelId != null ? ForumSearchStore.getSearchQuery(channelId) : null);
|
|
}
|
|
export function useForumSearchState(a0) {
|
|
let env16989;
|
|
const r1 = env16989 = {
|
|
$parent: env5988
|
|
};
|
|
env16989[0] = a0.channelId;
|
|
return useStateFromStoresObject([ForumSearchStore], $mk81932(r1));
|
|
}
|
|
export function useHasForumSearchQuery(c17010_0) {
|
|
return useStateFromStores([ForumSearchStore], () => ForumSearchStore.getSearchQuery(c17010_0) != null);
|
|
}
|
|
export function useAutomaticForumSearch(a0, a1, a2) {
|
|
const current = a1;
|
|
let r10 = arguments[3];
|
|
if (r10 === void 0) {
|
|
r10 = false;
|
|
}
|
|
let env17012;
|
|
let env17013;
|
|
let c17011_3 = r10;
|
|
const id2 = a0.id;
|
|
const r4 = env17012 = {
|
|
$parent: env5988
|
|
};
|
|
env17012[0] = id2;
|
|
const stateFromStoresObject = useStateFromStoresObject([ForumSearchStore], $mk81932(r4));
|
|
const { isSearchLoading, searchQuery } = stateFromStoresObject;
|
|
const r24 = env17013 = {
|
|
$parent: env5988
|
|
};
|
|
env17013[0] = a0;
|
|
const stateFromStores4 = useStateFromStores([PermissionStore], $mk81931(r24));
|
|
const ref = useRef(null);
|
|
const ref2 = useRef(new Set());
|
|
useEffect(() => {
|
|
if (searchQuery == null && ref.current != null) {
|
|
ForumActionCreators.clearForumSearch(a0.id);
|
|
ref.current = null;
|
|
return void 0;
|
|
}
|
|
L11: {
|
|
if (searchQuery != null && searchQuery.length !== 0 && !c17011_3) {
|
|
if (stateFromStores4) {
|
|
if (ref.current === searchQuery && ref2.current === current) {
|
|
break L11;
|
|
}
|
|
if (!isSearchLoading) {
|
|
let c26362_0 = setTimeout(async () => {
|
|
let c30030_2 = 0;
|
|
L10: {
|
|
try {
|
|
ref.current = searchQuery;
|
|
ref2.current = current;
|
|
c30030_2 = 1;
|
|
await ForumActionCreators.searchForumPosts(a0.guild_id, a0.id, searchQuery, current, a2);
|
|
c30030_2 = 0;
|
|
} catch ($e) {
|
|
let r31 = $e;
|
|
if (c30030_2 !== 0) {
|
|
while (true) {
|
|
try {
|
|
c30030_2 = 0;
|
|
break L10;
|
|
} catch ($e) {
|
|
r31 = $e;
|
|
if (c30030_2 === 0) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
throw r31;
|
|
}
|
|
}
|
|
}, 350);
|
|
return () => clearTimeout(c26362_0);
|
|
}
|
|
} else {
|
|
ForumActionCreators.clearForumSearch(a0.id);
|
|
}
|
|
}
|
|
}
|
|
}, [stateFromStores4, a0.guild_id, a0.id, r10, isSearchLoading, searchQuery, a1, a2]);
|
|
}
|
|
export function useUnreadThreadsCountForParent(a0, a1) {
|
|
let env16990;
|
|
const r1 = env16990 = {
|
|
$parent: env5988
|
|
};
|
|
env16990[0] = a0;
|
|
env16990[1] = a1;
|
|
return useStateFromStores([ActiveJoinedThreadsStore, ReadStateStore, ChannelStore], $mk81933(r1));
|
|
}
|
|
export function useForumActiveThreadIds({ channel, sortOrder, tagFilter, tagSetting, shouldAutomaticallyAck }) {
|
|
let stateFromStores5, stateFromStores6;
|
|
let env17015;
|
|
stateFromStores5 = void 0;
|
|
stateFromStores6 = void 0;
|
|
const stateFromStoresArray2 = useStateFromStoresArray([ForumActivePostStore], () => ForumActivePostStore.getThreadIds(channel.id, sortOrder, tagFilter, tagSetting));
|
|
const { guild_id, id: id2 } = channel;
|
|
const r22 = env17015 = {
|
|
$parent: env5988
|
|
};
|
|
env17015[0] = guild_id;
|
|
env17015[1] = id2;
|
|
stateFromStores5 = useStateFromStores([ActiveJoinedThreadsStore, ReadStateStore, ChannelStore], $mk81933(r22));
|
|
stateFromStores6 = useStateFromStores([ForumActivePostStore], () => {
|
|
let r1 = shouldAutomaticallyAck;
|
|
if (shouldAutomaticallyAck) {
|
|
r1 = stateFromStores5 > 0 || ForumActivePostStore.getCanAckThreads();
|
|
}
|
|
return r1;
|
|
}, [shouldAutomaticallyAck, stateFromStores5]);
|
|
useEffect(() => {
|
|
if (stateFromStores6) {
|
|
ackChannel(channel, {
|
|
object: AnalyticsObjects.ACK_FORUM_ACTIVE_THREADS,
|
|
objectType: AnalyticsObjectTypes.ACK_AUTOMATIC
|
|
});
|
|
}
|
|
}, [channel, stateFromStores6]);
|
|
return stateFromStoresArray2;
|
|
}
|