162 lines
5.1 KiB
TypeScript
162 lines
5.1 KiB
TypeScript
// Metro module 11689 (f11690).
|
|
import UserStore from "../../stores/UserStore";
|
|
import MessageRequestStore from "./MessageRequestStore";
|
|
import SpamMessageRequestStore from "./SpamMessageRequestStore";
|
|
import { createMessageRecord, updateMessageRecord } from "../messages/MessageRecordUtils";
|
|
import Module589 from "../../_bundle/Module589";
|
|
import Dispatcher from "../../Dispatcher";
|
|
let c7998_5, c7998_6, storeMessagePreview;
|
|
const isMessagePreviewEnabledForChannel = function isMessagePreviewEnabledForChannel(id) {
|
|
return MessageRequestStore.isMessageRequest(id) || SpamMessageRequestStore.isSpam(id);
|
|
};
|
|
storeMessagePreview = function storeMessagePreview(item, a1) {
|
|
const error = void 0 === void 0 ? false : void 0;
|
|
const r9 = MessageRequestStore.isMessageRequest(item) || SpamMessageRequestStore.isSpam(item);
|
|
L12: {
|
|
if (r9) {
|
|
const r3 = null === null;
|
|
if (!r3 && item !== (null !== null ? null.channel_id : void 0)) {
|
|
break L12;
|
|
}
|
|
c7998_5[item] = {
|
|
loaded: true,
|
|
error,
|
|
message: r3 ? null : createMessageRecord(null)
|
|
};
|
|
}
|
|
}
|
|
};
|
|
c7998_5 = {};
|
|
c7998_6 = new Set();
|
|
class MessageRequestPreviewStore extends Module589.Store {
|
|
static displayName = "MessageRequestPreviewStore";
|
|
initialize() {
|
|
this.waitFor(MessageRequestStore, SpamMessageRequestStore, UserStore);
|
|
}
|
|
shouldLoadMessageRequestPreview(a0) {
|
|
return !c7998_6.has(a0);
|
|
}
|
|
getMessageRequestPreview(a0) {
|
|
if (!(a0 in c7998_5)) {
|
|
c7998_5[a0] = {
|
|
loaded: false,
|
|
error: false,
|
|
message: null
|
|
};
|
|
}
|
|
return c7998_5[a0];
|
|
}
|
|
}
|
|
const messageRequestPreviewStore = new MessageRequestPreviewStore(Dispatcher, {
|
|
CONNECTION_OPEN: function handleConnectionOpen() {
|
|
c7998_5 = {};
|
|
c7998_6.clear();
|
|
},
|
|
CHANNEL_CREATE: function handleChannelCreate({ channel }) {
|
|
const id = channel.id;
|
|
if (MessageRequestStore.isMessageRequest(id) || SpamMessageRequestStore.isSpam(id)) {
|
|
c7998_6.add(channel.id);
|
|
}
|
|
},
|
|
CHANNEL_UPDATES: function handleChannelUpdates(a0) {
|
|
for (const channel of a0.channels) {
|
|
if (!isMessagePreviewEnabledForChannel(channel.id)) {
|
|
c7998_6.delete(channel.id);
|
|
delete c7998_5[channel.id];
|
|
}
|
|
}
|
|
},
|
|
CHANNEL_DELETE: function handleChannelDelete({ channel }) {
|
|
c7998_6.delete(channel.id);
|
|
delete c7998_5[channel.id];
|
|
},
|
|
MESSAGE_CREATE: function handleMessageCreate(a0) {
|
|
if (a0.isPushNotification) {
|
|
return false;
|
|
}
|
|
const channel_id = a0.message.channel_id;
|
|
const message = a0.message;
|
|
const r10 = MessageRequestStore.isMessageRequest(channel_id) || SpamMessageRequestStore.isSpam(channel_id);
|
|
L11: {
|
|
if (r10) {
|
|
if (message != null && channel_id !== message?.channel_id) {
|
|
break L11;
|
|
}
|
|
c7998_5[channel_id] = {
|
|
loaded: true,
|
|
error: false,
|
|
message: message == null ? null : createMessageRecord(message)
|
|
};
|
|
}
|
|
}
|
|
},
|
|
MESSAGE_UPDATE: function handleMessageUpdate(a0) {
|
|
const channel_id = a0.message.channel_id;
|
|
if (channel_id == null) {
|
|
return false;
|
|
}
|
|
const r7 = c7998_5[channel_id];
|
|
let r1 = r7 != null;
|
|
if (r1) {
|
|
let r14 = r7.message != null;
|
|
if (r14) {
|
|
c7998_5[channel_id] = {
|
|
...r7,
|
|
message: updateMessageRecord(r7.message, a0.message)
|
|
};
|
|
r14 = void 0;
|
|
}
|
|
r1 = r14;
|
|
}
|
|
return r1;
|
|
},
|
|
MESSAGE_DELETE: function handleMessageDelete(a0) {
|
|
const channelId = a0.channelId;
|
|
if (MessageRequestStore.isMessageRequest(channelId) || SpamMessageRequestStore.isSpam(channelId)) {
|
|
c7998_5[a0.channelId] = {
|
|
loaded: true,
|
|
error: false,
|
|
message: null
|
|
};
|
|
return void 0;
|
|
}
|
|
return false;
|
|
},
|
|
LOAD_MESSAGE_REQUESTS_SUPPLEMENTAL_DATA_SUCCESS: function handleLoadMessageRequestsSupplementalDataSuccess({ requestedChannelIds, supplementalData }) {
|
|
const set = new Set([...requestedChannelIds]);
|
|
let c19077_0 = set;
|
|
supplementalData.forEach((item) => {
|
|
const { channel_id, message_preview } = item;
|
|
const r8 = MessageRequestStore.isMessageRequest(channel_id) || SpamMessageRequestStore.isSpam(channel_id);
|
|
L10: {
|
|
if (r8) {
|
|
if (message_preview != null && channel_id !== message_preview?.channel_id) {
|
|
break L10;
|
|
}
|
|
c7998_5[channel_id] = {
|
|
loaded: true,
|
|
error: false,
|
|
message: message_preview == null ? null : createMessageRecord(message_preview)
|
|
};
|
|
}
|
|
}
|
|
c19077_0.delete(item.channel_id);
|
|
});
|
|
for (const item of Array.from(set)) {
|
|
storeMessagePreview(item, null);
|
|
}
|
|
},
|
|
LOAD_MESSAGE_REQUESTS_SUPPLEMENTAL_DATA_ERROR: function handleLoadMessageRequestsSupplementalDataError(a0) {
|
|
a0.requestedChannelIds.forEach((requestedChannelId) => {
|
|
if (MessageRequestStore.isMessageRequest(requestedChannelId) || SpamMessageRequestStore.isSpam(requestedChannelId)) {
|
|
c7998_5[requestedChannelId] = {
|
|
loaded: true,
|
|
error: true,
|
|
message: null
|
|
};
|
|
}
|
|
});
|
|
}
|
|
});
|
|
export default messageRequestPreviewStore;
|