This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,36 @@
// Metro module 9565 (f9566).
import Dispatcher from "../../Dispatcher";
export function createPendingReply(a0) {
const { message, channel } = a0;
Dispatcher.dispatch({
type: "CREATE_PENDING_REPLY",
message,
channel,
shouldMention: a0.shouldMention,
showMentionToggle: a0.showMentionToggle,
source: a0.source,
mediaMention: a0.mediaMention
});
}
export function createShallowPendingReply(a0) {
return Dispatcher.dispatch({
type: "CREATE_SHALLOW_PENDING_REPLY",
messageId: a0.messageId,
channel: a0.channel,
shouldMention: a0.shouldMention,
showMentionToggle: a0.showMentionToggle
});
}
export function setPendingReplyShouldMention(a0, a1) {
Dispatcher.dispatch({
type: "SET_PENDING_REPLY_SHOULD_MENTION",
channelId: a0,
shouldMention: a1
});
}
export function deletePendingReply(a0) {
Dispatcher.dispatch({
type: "DELETE_PENDING_REPLY",
channelId: a0
});
}
+145
View File
@@ -0,0 +1,145 @@
// Metro module 5965 (f5966).
import ChannelStore from "../../stores/ChannelStore";
import MessageStore from "../../stores/MessageStore";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c3755_5 = {};
let c3755_6 = {};
let c3755_7 = {};
class PendingReplyStore extends Module589.PersistedStore {
static displayName = "PendingReplyStore";
static persistKey = "PendingReplyStore";
static migrations = [(a0) => a0 == null ? {} : a0];
getState() {
const r1 = {};
for (const item of SnowflakeUtils.entries(c3755_5)) {
const [channelId, r8] = item;
r1[channelId] = {
channelId,
messageId: r8.message.id,
shouldMention: r8.shouldMention,
showMentionToggle: r8.showMentionToggle
};
}
return {
...c3755_6,
...r1
};
}
initialize(a0) {
let r1 = a0;
this.waitFor(MessageStore, ChannelStore);
if (a0 == null) {
r1 = {};
}
c3755_6 = r1;
}
getPendingReply(a0) {
return c3755_5[a0];
}
getPendingReplyActionSource(a0) {
return c3755_7[a0];
}
}
const pendingReplyStore = new PendingReplyStore(Dispatcher, {
CREATE_PENDING_REPLY: function handleCreatePendingReply(a0) {
const { channel, message, shouldMention = true, showMentionToggle = true, source } = a0;
c3755_5[channel.id] = {
channel,
message,
shouldMention,
showMentionToggle,
mediaMention: a0.mediaMention
};
c3755_7[channel.id] = source;
},
CREATE_SHALLOW_PENDING_REPLY: function handleCreateShallowPendingReply({ channel, messageId, shouldMention = true, showMentionToggle = true }) {
c3755_6[channel.id] = {
channelId: channel.id,
messageId,
shouldMention,
showMentionToggle
};
},
SET_PENDING_REPLY_SHOULD_MENTION: function handleSetPendingReplyShouldMention({ channelId, shouldMention }) {
if (channelId in c3755_5) {
c3755_5[channelId] = {
...c3755_5[channelId],
shouldMention
};
}
if (channelId in c3755_6) {
c3755_6[channelId] = {
...c3755_6[channelId],
shouldMention
};
}
},
DELETE_PENDING_REPLY: function handleDeletePendingReply({ channelId }) {
delete c3755_5[channelId];
delete c3755_6[channelId];
},
CONNECTION_OPEN: function handleConnectionOpen() {
SnowflakeUtils.keys(c3755_6).forEach((item) => {
if (ChannelStore.getChannel(item) == null) {
delete c3755_6[item];
}
});
},
LOGOUT: function handleLogout() {
c3755_5 = {};
c3755_6 = {};
c3755_7 = {};
},
MESSAGE_DELETE: function handleMessageDelete({ id, channelId }) {
const r7 = c3755_5[channelId];
if ((r7 == null ? void 0 : r7.message?.id) === id) {
delete c3755_5[channelId];
delete c3755_7[channelId];
} else {
if (c3755_6[channelId]?.messageId !== id) {
return false;
}
delete c3755_6[channelId];
delete c3755_7[channelId];
}
},
CHANNEL_SELECT: function handleChannelSelect({ channelId }) {
if (channelId != null) {
const r5 = c3755_6[channelId];
if (r5 != null) {
const message = MessageStore.getMessage(channelId, r5.messageId);
const channel = ChannelStore.getChannel(r5.channelId);
if (message != null && channel != null) {
c3755_5[channelId] = {
channel,
message,
shouldMention: r5.shouldMention,
showMentionToggle: r5.showMentionToggle
};
delete c3755_6[channelId];
}
}
}
},
LOAD_MESSAGES_SUCCESS: function handleLoadMessagesSuccess({ channelId }) {
if (channelId != null) {
const r5 = c3755_6[channelId];
if (r5 != null) {
const message = MessageStore.getMessage(channelId, r5.messageId);
const channel = ChannelStore.getChannel(r5.channelId);
if (message != null && channel != null) {
c3755_5[channelId] = {
channel,
message,
shouldMention: r5.shouldMention,
showMentionToggle: r5.showMentionToggle
};
delete c3755_6[channelId];
}
}
}
}
});
export default pendingReplyStore;
+342
View File
@@ -0,0 +1,342 @@
// Metro module 5857 (f5858).
import ConversationsStore from "../conversations/ConversationsStore";
import ChannelStore from "../../stores/ChannelStore";
import MessageStore from "../../stores/MessageStore";
import { MessageTypes, MessageTypesWithLazyLoadedReferences } from "../../Constants";
import LRUCache from "../../_bundle/LRUCache";
import { createMessageRecord, updateMessageRecord } from "../messages/MessageRecordUtils";
import { handleExplicitMediaScanTimeoutForMessage } from "../explicit_media_redaction/ExplicitMediaRedactionUtils";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
function $mk77231($env) {
return (a0, a1) => $env[0].handleCacheDisposed(a0, a1);
}
let c3664_9, c3664_10, c3664_11, c3664_13, anyChanged;
const processMessage = function processMessage(a0) {
const r2 = c3664_13.updateExistingMessageIfCached(a0) ? true : false;
const r17 = MessageTypesWithLazyLoadedReferences.has(a0.type);
let r1 = r2;
if (r17) {
const message_reference = a0.message_reference;
if (message_reference == null) {
return r2;
}
const message_id = message_reference.message_id;
if (message_id == null) {
return r2;
}
if ("referenced_message" in a0) {
const referenced_message = a0.referenced_message;
if (referenced_message != null) {
c3664_13.set(referenced_message.channel_id, referenced_message.id, {
state: c3664_9.LOADED,
message: createMessageRecord(referenced_message)
});
const type = a0.type;
const THREAD_STARTER_MESSAGE = MessageTypes.THREAD_STARTER_MESSAGE;
r1 = true;
if (type === THREAD_STARTER_MESSAGE) {
processMessage(referenced_message);
r1 = true;
}
} else {
c3664_13.set(a0.channel_id, message_id, {
state: c3664_9.DELETED
});
r1 = true;
}
} else {
let message = MessageStore.getMessage(message_reference.channel_id, message_id);
if (message == null) {
message = ConversationsStore.getMessage(message_reference.channel_id, message_id);
}
if (message != null) {
c3664_13.set(message_reference.channel_id, message_id, {
state: c3664_9.LOADED,
message
});
r1 = true;
} else {
c3664_13.set(message_reference.channel_id, message_id, c3664_10);
r1 = true;
}
}
}
return r1;
};
anyChanged = function anyChanged(a0, a1) {
let r0 = false;
for (const item of a0) {
r0 = a1(item) !== false || r0;
}
return r0;
};
const handleLoadMessages = function handleLoadMessages(a0) {
return anyChanged(a0.messages, (a0) => processMessage(a0));
};
const handleSearchMessagesSuccess = function handleSearchMessagesSuccess(a0) {
return anyChanged(a0.data, (a0) => anyChanged(a0.messages, (a0) => anyChanged(a0, (a0) => processMessage(a0))));
};
const handleChannelDelete = function handleChannelDelete(a0) {
return c3664_13.deleteChannelCache(a0.channel.id);
};
const resetState = function resetState() {
c3664_13.clear();
};
const handleLoadThreadsSuccess = function handleLoadThreadsSuccess({ firstMessages }) {
return firstMessages != null && anyChanged(firstMessages, (a0) => processMessage(a0));
};
c3664_9 = {
LOADED: 0,
0: "LOADED",
NOT_LOADED: 1,
1: "NOT_LOADED",
DELETED: 2,
2: "DELETED"
};
c3664_10 = Object.freeze({
state: c3664_9.NOT_LOADED
});
c3664_11 = new Set();
class ChannelReferencedMessageCache {
constructor() {
let env15209;
const r3 = env15209 = {};
env15209[0] = this;
this._cachedMessages = new LRUCache({
max: 100,
dispose: $mk77231(r3)
});
this._cachedMessageIds = new Set();
}
handleCacheDisposed(a0) {
if (this._cachedMessageIds.has(a0)) {
this._cachedMessageIds = new Set(this._cachedMessageIds);
this._cachedMessageIds.delete(a0);
}
}
set(a0, a1) {
this._cachedMessages.set(a0, a1);
if (!this._cachedMessageIds.has(a0)) {
this._cachedMessageIds = new Set(this._cachedMessageIds);
this._cachedMessageIds.add(a0);
}
}
has(a0) {
return this._cachedMessageIds.has(a0);
}
get(a0) {
return this._cachedMessages.get(a0);
}
getCachedMessageIds() {
return this._cachedMessageIds;
}
}
class ReferencedMessageCache {
constructor() {
return {
__proto__: new.target.prototype,
_channelCaches: new Map()
};
}
has(a0, a1) {
const r5 = this._channelCaches.get(a0);
let r7 = r5 == null ? void 0 : r5.has(a1);
if (r7 == null) {
r7 = false;
}
return r7;
}
get(a0, a1) {
const r4 = this._channelCaches.get(a0);
return r4 == null ? void 0 : r4.get(a1);
}
set(a0, a1, a2) {
let r4 = this._channelCaches.get(a0);
if (r4 == null) {
let env15210;
const r15 = {
__proto__: ChannelReferencedMessageCache.prototype
};
const r16 = env15210 = {};
env15210[0] = r15;
r15._cachedMessages = new LRUCache({
max: 100,
dispose: $mk77231(r16)
});
r15._cachedMessageIds = new Set();
this._channelCaches.set(a0, r15);
r4 = r15;
}
r4.set(a1, a2);
}
updateExistingMessageIfCached(a0) {
const r6 = this._channelCaches.get(a0.channel_id);
let r11 = r6 != null;
if (r11) {
let r15 = !!r6.has(a0.id);
if (r15) {
r6.set(a0.id, {
state: c3664_9.LOADED,
message: createMessageRecord(a0)
});
r15 = true;
}
r11 = r15;
}
return r11;
}
deleteChannelCache(a0) {
return this._channelCaches.delete(a0);
}
retainWhere(a0) {
const r0 = [];
for (const _channelCache of this._channelCaches) {
const [r29] = _channelCache;
if (!a0(r29)) {
r0.push(r29);
}
}
for (const item of r0) {
this.deleteChannelCache(item);
}
return r0.length;
}
getCachedMessageIdsForChannel(a0) {
const r5 = this._channelCaches.get(a0);
return r5 != null ? r5.getCachedMessageIds() : null;
}
clear() {
this._channelCaches.clear();
}
}
c3664_13 = {
__proto__: ReferencedMessageCache.prototype,
_channelCaches: new Map()
};
class ReferencedMessageStore extends Module589.Store {
static displayName = "ReferencedMessageStore";
initialize() {
this.waitFor(MessageStore, ChannelStore, ConversationsStore);
}
getMessageByReference(a0) {
let r2 = a0 != null ? c3664_13.get(a0.channel_id, a0.message_id) : void 0;
if (r2 == null) {
r2 = c3664_10;
}
return r2;
}
getMessage(a0, a1) {
let r6 = c3664_13.get(a0, a1);
if (r6 == null) {
r6 = c3664_10;
}
return r6;
}
getReplyIdsForChannel(a0) {
let r2 = a0 != null ? c3664_13.getCachedMessageIdsForChannel(a0) : void 0;
if (r2 == null) {
r2 = c3664_11;
}
return r2;
}
}
const referencedMessageStore = new ReferencedMessageStore(Dispatcher, {
CACHE_LOADED: function handleCacheLoaded(a0) {
return anyChanged(Object.values(a0.messages), (a0) => anyChanged(Object.values(a0), (a0) => processMessage(a0)));
},
LOCAL_MESSAGES_LOADED: handleLoadMessages,
LOAD_MESSAGES_SUCCESS: handleLoadMessages,
LOAD_MESSAGES_AROUND_SUCCESS: handleLoadMessages,
SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess,
MOD_VIEW_SEARCH_MESSAGES_SUCCESS: handleSearchMessagesSuccess,
CONVERSATION_FETCH_SUCCESS: function handleConversationFetchSuccess(a0) {
return anyChanged(a0.messages.concat(a0.messageReferences), (a0) => processMessage(a0));
},
CONVERSATIONS_FETCH_SUCCESS: function handleConversationsFetchSuccess(a0) {
return anyChanged(a0.rawConversations, ({ messages }) => {
if (messages == null) {
messages = [];
}
return anyChanged(messages, (a0) => processMessage(a0));
});
},
LOAD_THREADS_SUCCESS: handleLoadThreadsSuccess,
LOAD_ARCHIVED_THREADS_SUCCESS: handleLoadThreadsSuccess,
MESSAGE_EXPLICIT_CONTENT_SCAN_TIMEOUT: function handleMessageExplicitContentScanTimeout({ messageId, channelId: channelId2 }) {
if (c3664_13.has(channelId2, messageId)) {
const r6 = c3664_13.get(channelId2, messageId);
if (r6 != null && r6.state === c3664_9.LOADED) {
c3664_13.set(channelId2, messageId, {
state: c3664_9.LOADED,
message: handleExplicitMediaScanTimeoutForMessage(r6.message)
});
return void 0;
}
return false;
}
return false;
},
LOAD_FORUM_POSTS: function handleLoadForumPosts(a0) {
return anyChanged(Object.values(a0.threads), ({ first_message }) => first_message != null && processMessage(first_message));
},
MESSAGE_CREATE: function handleMessageCreate({ message }) {
return !!MessageStore.getMessages(message.channel_id).ready && processMessage(message);
},
MESSAGE_UPDATE: function handleMessageUpdate({ message }) {
const { id, channel_id } = message;
if (c3664_13.has(channel_id, id)) {
const r6 = c3664_13.get(channel_id, id);
if (r6 != null && r6.state === c3664_9.LOADED) {
c3664_13.set(channel_id, id, {
state: c3664_9.LOADED,
message: updateMessageRecord(r6.message, message)
});
return void 0;
}
return false;
}
return false;
},
MESSAGE_DELETE: function handleMessageDelete({ id, channelId: channelId2 }) {
const r9 = c3664_13.has(channelId2, id);
let r0 = false;
if (r9) {
c3664_13.set(channelId2, id, {
state: c3664_9.DELETED
});
r0 = void 0;
}
return r0;
},
MESSAGE_DELETE_BULK: function handleMessageDeleteBulk({ ids, channelId }) {
return anyChanged(ids, (a0) => {
const r9 = c3664_13.has(channelId, a0);
let r0 = false;
if (r9) {
c3664_13.set(channelId, a0, {
state: c3664_9.DELETED
});
r0 = void 0;
}
return r0;
});
},
CREATE_PENDING_REPLY: function handleCreatePendingReply({ message }) {
c3664_13.set(message.channel_id, message.id, {
state: c3664_9.LOADED,
message
});
},
CHANNEL_DELETE: handleChannelDelete,
THREAD_DELETE: handleChannelDelete,
GUILD_DELETE: function handleGenericCleanup() {
if (c3664_13.retainWhere((a0) => ChannelStore.getChannel(a0) != null) === 0) {
return false;
}
},
CONNECTION_OPEN: resetState,
LOGOUT: resetState
});
export default referencedMessageStore;
export { c3664_9 as ReferencedMessageState };
+75
View File
@@ -0,0 +1,75 @@
// Metro module 7757 (f7758).
import PermissionStore from "../../stores/PermissionStore";
import UserStore from "../../stores/UserStore";
import { MessageFlags, MessageStates } from "../../Constants";
import { Permissions } from "../../_bundle/Module505";
import { MessageTypesSets } from "../../_bundle/Module686";
import * as _ThreadHooks from "../threads/ThreadHooks";
import { useCanUnarchiveThread } from "../threads/ThreadHooks";
import { useCurrentUserCommunicationDisabled, userCommunicationDisabled } from "../guild_communication_disabled/useUserCommunicationDisabled";
import { useStateFromStores } from "../../_bundle/Module589";
export function useCanReplyToMessage(a0, a1) {
const canUnarchiveThread = useCanUnarchiveThread(a0);
let r18 = a0 == null ? void 0 : a0.getGuildId();
if (r18 == null) {
r18 = void 0;
}
const [, r22] = useCurrentUserCommunicationDisabled(r18);
let r29 = useStateFromStores([PermissionStore], () => {
let r1 = a0 != null && a1 != null;
if (r1) {
r1 = (a0.isPrivate() ? !a0.isSystemDM() : PermissionStore.can(Permissions.SEND_MESSAGES, a0) && PermissionStore.can(Permissions.READ_MESSAGE_HISTORY, a0)) && MessageTypesSets.REPLYABLE.has(a1.type);
}
return r1;
});
let r30 = a0 != null && a1 != null;
if (r30) {
const hasFlag = a1.hasFlag(MessageFlags.EPHEMERAL);
const state = a1.state;
const SENT = MessageStates.SENT;
const isArchivedThread = a0.isArchivedThread();
const r40 = isArchivedThread ? canUnarchiveThread : !isArchivedThread;
if (r29) {
r29 = state === SENT;
}
if (r29) {
r29 = !hasFlag;
}
if (r29) {
r29 = !r22;
}
if (r29) {
r29 = r40;
}
r30 = r29;
}
return r30;
}
export function canReplyToMessage(a0, a1) {
const canUnarchiveThread = _ThreadHooks.canUnarchiveThread(a0);
let r19 = (a0.isPrivate() ? !a0.isSystemDM() : PermissionStore.can(Permissions.SEND_MESSAGES, a0) && PermissionStore.can(Permissions.READ_MESSAGE_HISTORY, a0)) && MessageTypesSets.REPLYABLE.has(a1.type);
const id = UserStore.getCurrentUser()?.id;
let r38 = a0.getGuildId();
if (r38 == null) {
r38 = void 0;
}
const [, r42] = userCommunicationDisabled(id, r38);
const hasFlag = a1.hasFlag(MessageFlags.EPHEMERAL);
const state = a1.state;
const SENT = MessageStates.SENT;
const isArchivedThread = a0.isArchivedThread();
const r52 = isArchivedThread ? canUnarchiveThread : !isArchivedThread;
if (r19) {
r19 = state === SENT;
}
if (r19) {
r19 = !hasFlag;
}
if (r19) {
r19 = !r42;
}
if (r19) {
r19 = r52;
}
return r19;
}
+4
View File
@@ -0,0 +1,4 @@
// Metro module 7991 (f7992).
export default function didReplyMention(a0, a1) {
return a1 != null && !!a0.mentions.includes(a1.author.id);
};
+77
View File
@@ -0,0 +1,77 @@
// Metro module 9891 (f9892).
import EditMessageStore from "../../../stores/EditMessageStore";
import UserStore from "../../../stores/UserStore";
import PendingReplyStore from "../PendingReplyStore";
import { AnalyticEvents } from "../../../Constants";
import AnalyticsUtils from "../../../utils/AnalyticsUtils";
import { getContextBarCancelReason } from "../../messages/native/long_press/LongPressMessageActionSheetUtils";
import MessageActionCreators from "../../../actions/MessageActionCreators";
import { deletePendingReply, createPendingReply } from "../PendingReplyActionCreators";
import { collectGuildAnalyticsMetadata, collectChannelAnalyticsMetadata } from "../../app_analytics/AppAnalyticsUtils";
export default function longPressMessageHandleReply({ message, channel, chatInputRef, actionSource, invertible = false }) {
const editingMessage = EditMessageStore.getEditingMessage(channel.id);
if (editingMessage != null) {
const currentUser = UserStore.getCurrentUser();
AnalyticsUtils.track(AnalyticEvents.CHAT_CONTEXT_BAR_ACTION_CANCELED, {
message_id: message.id,
channel_id: channel.id,
guild_id: channel.guild_id,
context_action: "edit",
reason: getContextBarCancelReason("edit", actionSource),
is_own_message: currentUser != null && currentUser.id === editingMessage.author.id
});
}
L26: {
MessageActionCreators.endEditMessage(channel.id);
const pendingReply = PendingReplyStore.getPendingReply(channel.id);
if (invertible && (actionSource === "message_swipe" && (pendingReply != null && pendingReply.message.id === message.id))) {
const currentUser3 = UserStore.getCurrentUser();
AnalyticsUtils.track(AnalyticEvents.CHAT_CONTEXT_BAR_ACTION_CANCELED, {
message_id: message.id,
channel_id: channel.id,
guild_id: channel.guild_id,
context_action: "reply",
reason: "swipe_reply_undo",
is_own_message: currentUser3 != null && currentUser3.id === pendingReply.message.author.id
});
deletePendingReply(channel.id);
const r116 = chatInputRef == null;
let r117 = void 0;
if (!r116) {
const current2 = chatInputRef.current;
r117 = current2 == null ? void 0 : current2.getText();
}
if (r117 !== "") {
break L26;
}
if (chatInputRef == null) {
break L26;
}
const current3 = chatInputRef.current;
if (current3 == null) {
break L26;
}
current3.dismissKeyboard();
} else {
AnalyticsUtils.track(AnalyticEvents.REPLY_MESSAGE_STARTED, {
source: actionSource,
...collectGuildAnalyticsMetadata(channel.guild_id),
...collectChannelAnalyticsMetadata(channel)
});
const currentUser2 = UserStore.getCurrentUser();
const isDM = channel.isDM();
createPendingReply({
message,
channel,
shouldMention: (isDM ? !isDM : currentUser2 != null) && message.author.id !== currentUser2.id,
source: actionSource
});
if (chatInputRef != null) {
const current = chatInputRef.current;
if (current != null) {
current.openSystemKeyboard();
}
}
}
}
};
@@ -0,0 +1,36 @@
// Metro module 10931 (f10932).
import { ReferencedMessageState } from "./ReferencedMessageStore";
import { AnalyticEvents } from "../../Constants";
import maybeCreateMessageRecordFromSnapshot from "../forwarding/maybeCreateMessageRecordFromSnapshot";
import { trackWithMetadata } from "../app_analytics/AppAnalyticsUtils";
export default function trackRepliedMessageClicked(a0, a1, a2) {
const message_id = a0.messageReference?.message_id;
const state = a1.state;
const LOADED = ReferencedMessageState.LOADED;
let replied_message_length = null;
let replied_message_has_media = null;
if (state === LOADED) {
const r24 = maybeCreateMessageRecordFromSnapshot(a1.message);
const r1 = r24.attachments.length > 0 || r24.embeds.length > 0 || r24.stickerItems.length > 0 || r24.stickers.length > 0;
let r34 = r24.content?.length;
if (r34 == null) {
r34 = 0;
}
replied_message_length = r34;
replied_message_has_media = r1;
}
const REPLIED_MESSAGE_CLICKED = AnalyticEvents.REPLIED_MESSAGE_CLICKED;
let guild_id = a2.guild_id;
if (guild_id == null) {
guild_id = void 0;
}
trackWithMetadata(REPLIED_MESSAGE_CLICKED, {
guild_id,
channel_id: a2.id,
reply_message_id: a0.id,
replied_message_id: message_id,
replied_message_is_loaded: a1.state === ReferencedMessageState.LOADED,
replied_message_has_media,
replied_message_length
});
};