146 lines
4.2 KiB
TypeScript
146 lines
4.2 KiB
TypeScript
// 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;
|