Files
discord-decomp/actions/ReadStateActionCreators.tsx
T
2026-11-01 12:12:55 +02:00

132 lines
3.5 KiB
TypeScript

// Metro module 5126 (f5127).
import ActiveJoinedThreadsStore from "../modules/threads/ActiveJoinedThreadsStore";
import { isReadableType } from "../records/ChannelRecord";
import ChannelStore from "../stores/ChannelStore";
import GuildCategoryStore from "../stores/GuildCategoryStore";
import UserStore from "../stores/UserStore";
import { CURRENT_APP_CONTEXT } from "../Constants";
import Dispatcher from "../Dispatcher";
import SnowflakeUtils from "../utils/SnowflakeUtils";
let ackCategory;
const ack = function ack(a0, a1, immediate = false, force = false) {
Dispatcher.dispatch({
type: "CHANNEL_ACK",
channelId: a0,
messageId: arguments[4],
immediate,
force,
context: CURRENT_APP_CONTEXT,
location: a1
});
};
ackCategory = function ackCategory(id, a1, r5 = false, r4 = false) {
let c14674_1;
c14674_1 = void 0;
const channel = ChannelStore.getChannel(id);
if (channel != null && channel.guild_id != null) {
const categories = GuildCategoryStore.getCategories(channel.guild_id);
if (categories[id] != null) {
const r34 = categories[id].filter((item) => isReadableType(item.channel.type));
const r37 = r34.map((item) => item.channel.id);
c14674_1 = r37;
r34.forEach(({ channel: channel2 }) => {
let guild_id = channel2.guild_id;
if (guild_id == null) {
guild_id = channel.guild_id;
}
const activeJoinedThreadsForParent = ActiveJoinedThreadsStore.getActiveJoinedThreadsForParent(guild_id, channel2.id);
for (const key in activeJoinedThreadsForParent) {
c14674_1.push(key);
}
});
for (const item of r37) {
ack(item, a1, r5, r4);
}
}
}
};
export { ack };
export { ackCategory };
export function ackChannel(a0, a1) {
if (a0.isCategory()) {
ackCategory(a0.id, a1, true, true);
} else {
const isForumLikeChannel = a0.isForumLikeChannel();
const id = a0.id;
if (isForumLikeChannel) {
Dispatcher.dispatch({
type: "CHANNEL_ACK",
channelId: id,
messageId: SnowflakeUtils.fromTimestamp(Date.now()),
immediate: true,
force: true,
context: CURRENT_APP_CONTEXT,
location: a1
});
} else {
Dispatcher.dispatch({
type: "CHANNEL_ACK",
channelId: id,
messageId: void 0,
immediate: true,
force: true,
context: CURRENT_APP_CONTEXT,
location: a1
});
}
}
}
export function bulkAck(a0, a1) {
Dispatcher.dispatch({
type: "BULK_ACK",
channels: a0,
context: CURRENT_APP_CONTEXT,
onFinished: a1
});
}
export function localAck(a0) {
Dispatcher.dispatch({
type: "CHANNEL_LOCAL_ACK",
channelId: a0
});
}
export function enableAutomaticAck(a0, a1) {
Dispatcher.dispatch({
type: "ENABLE_AUTOMATIC_ACK",
channelId: a0,
windowId: a1
});
}
export function disableAutomaticAck(a0, a1) {
Dispatcher.dispatch({
type: "DISABLE_AUTOMATIC_ACK",
channelId: a0,
windowId: a1
});
}
export function ackGuildFeature(a0, a1, a2) {
Dispatcher.dispatch({
type: "GUILD_FEATURE_ACK",
id: a0,
ackType: a1,
ackedId: a2,
local: false
});
}
export function ackUserFeature(a0, a1) {
if (UserStore.getCurrentUser()?.id != null) {
Dispatcher.dispatch({
type: "USER_NON_CHANNEL_ACK",
ackType: a0,
ackedId: a1,
local: false
});
}
}
export function clearOldestUnreadMessageId(a0) {
Dispatcher.dispatch({
type: "CLEAR_OLDEST_UNREAD_MESSAGE",
channelId: a0
});
}