decord/source/modules/guild_home/ActiveChannelsStore.tsx

250 lines
7.8 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 13310
// Function ID: 13311
2026-07-29 08:29:29 +00:00
// Name: truncateOldMessageData
2026-08-24 06:08:38 +00:00
// Dependencies: [1391, 4201, 1398, 11, 12, 589, 709, 2]
2026-07-23 10:11:24 +00:00
2026-08-24 06:08:38 +00:00
// Module 13310 (truncateOldMessageData)
import DISCORD_EPOCHDefault from "DISCORD_EPOCH" /* 11 */;
import applyDefault from "apply" /* 12 */;
import initializeDefault from "initialize" /* 589 */;
import dispatcherDefault from "dispatcher" /* 709 */;
import closure_2 from "ensureGuildLoaded" /* 1391 */;
import closure_3 from "handleConnectionOpen" /* 4201 */;
import { isGuildHomeChannel } from "set" /* 1398 */;
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
function truncateOldMessageData(channelId) {
if (null != dependencyMap2[channelId]) {
2026-07-20 16:05:17 +00:00
let nowResult = globalThis;
const _Date2 = Date;
2026-08-24 06:08:38 +00:00
importDefault = DISCORD_EPOCHDefault.fromTimestamp(Date.now() - c5);
const obj = DISCORD_EPOCHDefault;
2026-07-29 08:29:29 +00:00
const tmp6 = importDefault;
2026-08-24 06:08:38 +00:00
const findIndexResult = applyDefault.findIndex(arr, (id) => callback(closure_1_1[3]).compare(id.id, callback) > 0);
2026-07-20 16:05:17 +00:00
if (-1 === findIndexResult) {
2026-07-29 08:29:29 +00:00
dependencyMap2[channelId] = [];
2026-07-20 16:05:17 +00:00
} else {
const _Math = Math;
const bound = Math.max(findIndexResult, arr.length - 26);
2026-07-29 08:29:29 +00:00
dependencyMap2[channelId] = tmp6(12).slice(arr, bound);
const tmp6Result = tmp6(12);
2026-07-20 16:05:17 +00:00
}
const _Date = nowResult.Date;
nowResult = _Date.now();
2026-07-29 08:29:29 +00:00
closure_8[channelId] = nowResult;
2026-08-24 06:08:38 +00:00
const obj2 = applyDefault;
2026-07-20 16:05:17 +00:00
}
}
function handleChannelDelete(channel) {
channel = channel.channel;
2026-07-23 10:11:24 +00:00
delete tmp4[tmp3];
delete tmp2[tmp];
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let c5 = 900000;
let closure_6 = {};
let closure_7 = {};
let closure_8 = {};
let closure_9 = {};
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class ActiveChannelsStore extends Store {
}
const prototype = ActiveChannelsStore.prototype;
prototype["initialize"] = function initialize() {
2026-08-24 06:08:38 +00:00
this.waitFor(closure_2, closure_3);
2026-07-29 08:29:29 +00:00
};
prototype["getActiveChannelsFetchStatus"] = function getActiveChannelsFetchStatus(arg0) {
return dependencyMap3[arg0];
};
prototype["getActiveChannelIds"] = function getActiveChannelIds(guildId) {
return dependencyMap[guildId];
};
prototype["getChannelMessageData"] = function getChannelMessageData(channelId) {
return dependencyMap2[channelId];
};
prototype["shouldFetch"] = function shouldFetch(arg0) {
let tmp = null == dependencyMap[arg0];
if (tmp) {
let loading;
if (dependencyMap3[arg0] != null) {
loading = tmp3.loading;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp = !loading;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp;
};
ActiveChannelsStore.displayName = "ActiveChannelsStore";
2026-08-24 06:08:38 +00:00
const activeChannelsStore = new ActiveChannelsStore(dispatcherDefault, {
2026-07-20 16:05:17 +00:00
CHANNEL_SELECT: function handleRefreshChannels(guildId) {
guildId = guildId.guildId;
if (isGuildHomeChannel(guildId.channelId)) {
if (null != guildId) {
2026-07-23 10:11:24 +00:00
if (null == dependencyMap[guildId]) {
2026-07-20 16:05:17 +00:00
return false;
} else {
const item = arr.forEach((arg0) => {
2026-07-29 08:29:29 +00:00
callback(arg0);
2026-07-20 16:05:17 +00:00
let length;
2026-07-29 08:29:29 +00:00
if (dependencyMap[arg0] != null) {
2026-07-20 16:05:17 +00:00
length = arr.length;
}
if (0 === length) {
2026-07-23 10:11:24 +00:00
delete tmp[tmp2];
2026-07-20 16:05:17 +00:00
}
});
const _Array = Array;
2026-08-24 06:08:38 +00:00
const obj = applyDefault;
const found = applyDefault.chain(Array.from(arr)).filter((arg0) => arg0 in closure_7);
const chainResult = applyDefault.chain(Array.from(arr));
2026-07-20 16:05:17 +00:00
const _Set = Set;
const set = new Set(found.sortBy((arg0) => {
2026-07-29 08:29:29 +00:00
let num;
if (dependencyMap[arg0] != null) {
num = arr.length;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
return -num;
}).value());
2026-07-23 10:11:24 +00:00
dependencyMap[guildId] = set;
2026-07-20 16:05:17 +00:00
}
}
}
return false;
},
MESSAGE_CREATE: function handleMessageCreate(optimistic) {
({ channelId, message } = optimistic);
if (!optimistic.optimistic) {
if (!optimistic.isPushNotification) {
2026-07-23 10:11:24 +00:00
channel = channel.getChannel(channelId);
2026-07-20 16:05:17 +00:00
if (null == channel) {
return false;
} else {
const guild_id = channel.guild_id;
2026-07-29 08:29:29 +00:00
let tmp20 = null != guild_id;
if (tmp20) {
2026-07-23 10:11:24 +00:00
if (null != dependencyMap[guild_id]) {
2026-07-29 08:29:29 +00:00
const author = message.author;
let id;
if (author != null) {
2026-07-20 16:05:17 +00:00
id = author.id;
}
2026-07-29 08:29:29 +00:00
let obj = dependencyMap[guild_id];
obj.add(channelId);
let tmp11 = null == tmp10;
if (!tmp11) {
const _Date = Date;
const sum = tmp10 + 300000;
tmp11 = sum > Date.now();
}
if (tmp11) {
truncateOldMessageData(channelId);
}
if (null == dependencyMap2[channelId]) {
dependencyMap2[channelId] = [];
}
let arr = dependencyMap2[channelId];
obj = { id: null, userId: null };
obj[0] = message.id;
obj[1] = id;
arr = arr.push(obj);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
tmp20 = tmp5;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return tmp20;
2026-07-20 16:05:17 +00:00
}
}
}
return false;
},
GUILD_DELETE: function handleGuildDelete(arg0) {
2026-07-23 10:11:24 +00:00
delete tmp2[tmp];
2026-07-20 16:05:17 +00:00
},
CHANNEL_DELETE: handleChannelDelete,
THREAD_DELETE: handleChannelDelete,
ACTIVE_CHANNELS_FETCH_START: function handleActiveChannelsFetchStart(guildId) {
2026-07-29 08:29:29 +00:00
closure_9[guildId.guildId] = { loading: true, error: null, fetchedAt: Date.now() };
2026-07-20 16:05:17 +00:00
},
ACTIVE_CHANNELS_FETCH_SUCCESS: function handleActiveChannelsFetchSuccess(guildId) {
guildId = guildId.guildId;
const channels = guildId.channels;
2026-07-29 08:29:29 +00:00
closure_9[guildId] = { loading: false, error: null, fetchedAt: Date.now() };
2026-07-23 10:11:24 +00:00
const obj = { loading: false, error: null, fetchedAt: Date.now() };
2026-07-29 08:29:29 +00:00
closure_6[guildId] = new Set();
2026-07-23 10:11:24 +00:00
let item = channels.forEach((arg0) => {
({ channel_id: guildId, messages } = arg0);
2026-07-29 08:29:29 +00:00
const item = messages.forEach((arg0) => {
({ message_id, user_id } = arg0);
2026-08-24 06:08:38 +00:00
closure_2_6[closure_1_0].add(closure_0);
2026-07-29 08:29:29 +00:00
let tmp4 = null == tmp3;
if (!tmp4) {
const _Date = Date;
const sum = tmp3 + 300000;
tmp4 = sum > Date.now();
}
if (tmp4) {
2026-08-24 06:08:38 +00:00
closure_2_10(tmp);
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
if (null == closure_2_7[closure_0]) {
closure_2_7[tmp] = [];
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
let arr = closure_2_7[tmp];
2026-07-29 08:29:29 +00:00
arr = arr.push({ id: message_id, userId: user_id });
2026-07-20 16:05:17 +00:00
});
});
},
ACTIVE_CHANNELS_FETCH_FAILURE: function handleActiveChannelsFetchFailure(error) {
2026-07-29 08:29:29 +00:00
closure_9[error.guildId] = { loading: false, error: error.error, fetchedAt: null };
2026-07-20 16:05:17 +00:00
},
CONNECTION_OPEN: function handleConnectionOpen() {
2026-07-23 10:11:24 +00:00
guildId = guildId.getGuildId();
2026-07-20 16:05:17 +00:00
if (null != guildId) {
2026-07-29 08:29:29 +00:00
let items = tmp5;
if (dependencyMap[guildId] == null) {
2026-07-20 16:05:17 +00:00
items = [];
}
const reduced = Array.from(items).reduce((arg0, arg1) => {
2026-07-29 08:29:29 +00:00
let items = table[arg1];
if (items == null) {
2026-07-20 16:05:17 +00:00
items = [];
}
arg0[arg1] = items;
return arg0;
}, {});
2026-07-29 08:29:29 +00:00
dependencyMap = {};
2026-08-24 06:08:38 +00:00
closure_7 = {};
closure_8 = {};
2026-07-29 08:29:29 +00:00
let dependencyMap3 = {};
2026-07-20 16:05:17 +00:00
const _Date = Date;
2026-07-29 08:29:29 +00:00
let num;
2026-07-20 16:05:17 +00:00
const timestamp = Date.now();
2026-07-29 08:29:29 +00:00
if (dependencyMap3[guildId] != null) {
num = tmp3.fetchedAt;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (num == null) {
num = 0;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (timestamp - num < c5) {
let obj = {};
obj[guildId] = tmp3;
dependencyMap3 = obj;
2026-07-23 10:11:24 +00:00
obj = {};
2026-07-20 16:05:17 +00:00
obj[guildId] = tmp5;
2026-07-29 08:29:29 +00:00
dependencyMap = obj;
2026-07-20 16:05:17 +00:00
obj = {};
const merged = Object.assign(reduced);
2026-07-29 08:29:29 +00:00
closure_7 = obj;
2026-07-20 16:05:17 +00:00
}
const arr = Array.from(items);
} else {
2026-07-29 08:29:29 +00:00
dependencyMap = {};
closure_7 = {};
closure_8 = {};
dependencyMap3 = {};
2026-07-20 16:05:17 +00:00
}
}
});
2026-07-29 08:29:29 +00:00
const result = require("set").fileFinishedImporting("modules/guild_home/ActiveChannelsStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default activeChannelsStore;
2026-07-20 16:05:17 +00:00
export const MAX_STORED_MESSAGES = 26;