Files
discord-decomp/modules/media_channel/MediaPostSharePromptStore.tsx
T
2026-11-01 12:12:55 +02:00

42 lines
1.6 KiB
TypeScript

// Metro module 7722 (f7723).
import GatedChannelStore from "../channel/GatedChannelStore";
import AuthenticationStore from "../../stores/AuthenticationStore";
import ChannelStore from "../../stores/ChannelStore";
import { isFirstMessageIdInMediaPost } from "./useIsFirstMessageInMediaPost";
import SnowflakeUtils from "../../utils/SnowflakeUtils";
import Module589 from "../../_bundle/Module589";
import Dispatcher from "../../Dispatcher";
let c4855_6 = new Set();
class MediaPostSharePromptStore extends Module589.Store {
static displayName = "MediaPostSharePromptStore";
initialize() {
this.waitFor(AuthenticationStore, ChannelStore, GatedChannelStore);
}
shouldDisplayPrompt(a0) {
return c4855_6.has(a0);
}
}
const mediaPostSharePromptStore = new MediaPostSharePromptStore(Dispatcher, {
CONNECTION_OPEN: function handleConnectionOpen() {
c4855_6 = new Set();
},
MESSAGE_CREATE: function handleMessageCreate(a0) {
if (!a0.isPushNotification) {
const message = a0.message;
if (AuthenticationStore.getId() === message.author?.id && isFirstMessageIdInMediaPost(message.id, message.channel_id)) {
const channel = ChannelStore.getChannel(message.channel_id);
if (channel != null && channel.parent_id != null && GatedChannelStore.isChannelGated(channel.guild_id, channel.parent_id)) {
c4855_6.add(SnowflakeUtils.castMessageIdAsChannelId(a0.message.id));
}
}
}
},
DISMISS_MEDIA_POST_SHARE_PROMPT: function handleDismissMediaPostSharePrompt(a0) {
c4855_6.delete(a0.threadId);
},
LOGOUT: function handleLogout() {
c4855_6.clear();
}
});
export default mediaPostSharePromptStore;