decord/source/modules/conversations/components/native/useConversationsHeaderButton.tsx

203 lines
7 KiB
TypeScript
Raw Normal View History

// Module ID: 8011
// Function ID: 8012
2026-07-20 16:05:17 +00:00
// Name: useConversationsHeaderButton
// Dependencies: [5, 19, 7701, 7703, 8012, 1095, 8013, 8014, 504, 8017, 8016, 8019, 1115, 2]
2026-07-20 16:05:17 +00:00
// Exports: useConversationsHeaderButton
// Module 8011 (useConversationsHeaderButton)
import util from "util" /* 1115 */;
import ConversationsActionCreators from "ConversationsActionCreators" /* 8014 */;
import PaperIcon from "PaperIcon" /* 8017 */;
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */;
import noop from "module_19" /* 19 */;
import ConversationsStore from "ConversationsStore" /* 7701 */;
2026-07-23 10:11:24 +00:00
const require = globalThis.__r;
require = fn;
const ConversationConstants = fn(7703);
({ CONVERSATION_HAS_MORE_EXPIRATION_MS: hasOwnProperty, MOBILE_FETCH_LIMIT: metroRequire, MOBILE_PREVIEW_MESSAGE_COUNT: closure_7 } = ConversationConstants);
const size = fn(2);
let result = size.fileFinishedImporting("modules/conversations/components/native/useConversationsHeaderButton.tsx");
2026-07-20 16:05:17 +00:00
export const useConversationsHeaderButton = function useConversationsHeaderButton(channel) {
_require = channel;
let isTopicalNavEnabled = require("ConversationExperiments").useIsTopicalNavEnabled(channel.guild_id, "channel_header");
2026-07-20 16:05:17 +00:00
if (isTopicalNavEnabled) {
2026-07-29 08:29:29 +00:00
isTopicalNavEnabled = channel.type === tmp(tmp2[5]).ChannelTypes.GUILD_TEXT;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
fetchPage = isTopicalNavEnabled;
let obj = require("ConversationExperiments");
2026-07-20 16:05:17 +00:00
const items = [channel.id];
const conversationBackoffRef = require("useConversationBackoffRef").useConversationBackoffRef(items);
2026-07-29 08:29:29 +00:00
fetchPage = function fetchPage() {
const self = this;
const apply = closure_0.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
};
_require = conversationBackoffRef(function*(arg0, value) {
2026-07-29 08:29:29 +00:00
if (c3 === 2) {
c3 = 3;
throw new TypeError("Generator functions may not be called on executing generators");
2026-07-29 08:29:29 +00:00
} else if (tmp6 === 3) {
if (arg0 === 1) {
throw value;
2026-07-29 08:29:29 +00:00
} else if (arg0 === 2) {
const obj4 = { value, done: true };
return obj4;
2026-07-29 08:29:29 +00:00
} else {
2026-09-01 10:26:29 +00:00
return { value: "HermesInternal", done: null };
2026-07-29 08:29:29 +00:00
}
} else {
try {
c3 = 2;
if (0 === c1) {
if (arg0 === 1) {
c3 = 3;
throw value;
2026-07-29 08:29:29 +00:00
} else if (arg0 === 2) {
c3 = 3;
const obj5 = { value, done: true };
return obj5;
} else if (c1) {
ref = 1;
const obj6 = { channelId: null, guildId: null, direction: "before", anchor: null, limit: null, isJump: true, throwOnError: true, hydrateMessages: null };
({ id: obj3.channelId, guild_id: obj3.guildId } = tmp3);
obj6.limit = isTopicalNavEnabled;
const obj7 = { limit };
obj6.hydrateMessages = obj7;
c1 = 2;
c3 = 1;
const obj12 = { value: tmp3(fetchPage[7]).fetchChannelConversations(obj6), done: false };
return obj12;
2026-07-29 08:29:29 +00:00
}
} else {
if (1 === tmp7) {
ref = 0;
const current2 = ref.current;
current2.fail(closure_128_1);
2026-07-29 08:29:29 +00:00
} else if (arg0 === 1) {
c3 = 3;
throw value;
2026-07-29 08:29:29 +00:00
} else if (arg0 !== 2) {
const current = ref.current;
current.succeed();
ref = 0;
}
ref = 0;
c3 = 3;
const obj = { value, done: true };
2026-07-29 08:29:29 +00:00
return obj;
}
c3 = 3;
} catch (tmp20) {
if (tmp4 === ref) {
c3 = tmp2;
throw tmp20;
} else {
c1 = tmp;
}
}
}
});
2026-07-20 16:05:17 +00:00
const items1 = [, , , ];
({ id: arr2[0], guild_id: arr2[1] } = channel);
items1[2] = isTopicalNavEnabled;
items1[3] = conversationBackoffRef;
2026-07-29 08:29:29 +00:00
callback = callback.useCallback(fetchPage, items1);
2026-07-20 16:05:17 +00:00
const items2 = [, , , ];
({ id: arr3[0], guild_id: arr3[1] } = channel);
items2[2] = isTopicalNavEnabled;
items2[3] = callback;
2026-07-23 10:11:24 +00:00
const effect = callback.useEffect(() => {
2026-07-29 08:29:29 +00:00
let hasChannelDataResult = !fetchPage;
if (fetchPage) {
hasChannelDataResult = ConversationsStore.hasChannelData(user.id);
2026-07-20 16:05:17 +00:00
}
if (!hasChannelDataResult) {
hasChannelDataResult = ConversationsStore.isPendingFetch(user.id);
2026-07-20 16:05:17 +00:00
}
if (!hasChannelDataResult) {
callback();
}
}, items2);
const tmpResult = require("useConversationBackoffRef");
2026-07-23 10:11:24 +00:00
const items3 = [stateFromStores];
2026-07-20 16:05:17 +00:00
const items4 = [channel.id];
stateFromStores = require("initialize").useStateFromStores(items3, () => ConversationsStore.getEdgeMarker(user.id, "after"), items4);
2026-07-20 16:05:17 +00:00
const items5 = [stateFromStores, isTopicalNavEnabled, callback];
2026-07-23 10:11:24 +00:00
const effect1 = callback.useEffect(() => {
2026-07-29 08:29:29 +00:00
if (fetchPage) {
2026-07-20 16:05:17 +00:00
if (null != stateFromStores) {
const _Date = Date;
const sum = tmp + hasOwnProperty;
2026-07-20 16:05:17 +00:00
const diff = sum - Date.now();
if (diff > 0) {
const _setTimeout = setTimeout;
const timeout = setTimeout(callback, diff);
return () => clearTimeout(closure_0);
} else {
callback();
}
}
}
}, items5);
const tmpResult3 = require("initialize");
2026-07-23 10:11:24 +00:00
const items6 = [stateFromStores];
2026-07-20 16:05:17 +00:00
const items7 = [channel.id];
const stateFromStores1 = require("initialize").useStateFromStores(items6, () => {
const channelConversations = ConversationsStore.getChannelConversations(user.id);
2026-07-29 08:29:29 +00:00
let num;
if (channelConversations != null) {
num = channelConversations.length;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
return num;
}, items7);
if (isTopicalNavEnabled) {
isTopicalNavEnabled = stateFromStores1 > 0;
}
callback.useRef(null);
2026-07-20 16:05:17 +00:00
const items8 = [isTopicalNavEnabled, stateFromStores1, channel.id];
2026-07-29 08:29:29 +00:00
const effect2 = obj3.useEffect(() => {
2026-07-20 16:05:17 +00:00
let tmp = isTopicalNavEnabled;
if (isTopicalNavEnabled) {
tmp = ref.current !== user.id;
2026-07-20 16:05:17 +00:00
}
if (tmp) {
ref.current = user.id;
const result = ConversationsActionCreators.trackTopicalNavigationEntrypointImpression(user.id, stateFromStores1);
2026-07-20 16:05:17 +00:00
}
}, items8);
const items9 = [isTopicalNavEnabled, conversationBackoffRef, , ];
({ id: arr10[2], guild_id: arr10[3] } = channel);
2026-07-23 10:11:24 +00:00
return callback.useMemo(() => {
2026-07-20 16:05:17 +00:00
let tmp = null;
if (isTopicalNavEnabled) {
const obj = {
source: null,
IconComponent: PaperIcon.PaperIcon,
onPress() {
const current = ref.current;
current.cancel();
const ConversationsAnalytics = closure_0(fetchPage[10]).ConversationsAnalytics;
const result = ConversationsAnalytics.trackTopicsUnitImpression({ channelId: user.id, conversationIds: [], isFocusMode: false });
const result1 = closure_0(fetchPage[11]).openConversationNavigator({ channelId: user.id, guildId: user.guild_id });
},
accessibilityLabel: null
2026-07-20 16:05:17 +00:00
};
const intl = util.intl;
obj.accessibilityLabel = intl.string(util.t.u54FxB);
2026-07-20 16:05:17 +00:00
tmp = obj;
}
return tmp;
}, items9);
};