decord/source/stores/InviteSuggestionsStore.tsx

140 lines
5.2 KiB
TypeScript
Raw Normal View History

// Module ID: 9865
// Function ID: 9866
// Name: InviteSuggestionsStore
// Dependencies: [9866, 7673, 1957, 4212, 4222, 1074, 7750, 9854, 5532, 1369, 504, 573, 2]
2026-07-20 16:05:17 +00:00
// Module 9865 (InviteSuggestionsStore)
import initializeDefault from "initialize" /* 504 */;
import DispatcherDefault from "Dispatcher" /* 573 */;
import autocompleter_sortByMatchScoreDefault from "autocompleter/sortByMatchScore" /* 5532 */;
import InstantInviteUtils from "InstantInviteUtils" /* 9854 */;
import QuickSwitcherStore from "QuickSwitcherStore" /* 9866 */;
import UserAffinitiesV2Store from "UserAffinitiesV2Store" /* 7673 */;
import ChannelStore from "ChannelStore" /* 1957 */;
import PermissionStore from "PermissionStore" /* 4212 */;
import RelationshipStore from "RelationshipStore" /* 4222 */;
2026-07-23 10:11:24 +00:00
require = fn;
2026-09-03 10:05:34 +00:00
function compareRowsByMatchScore(score, score2) {
let num = 0;
if (null != score.score) {
num = 0;
if (null != score2.score) {
const obj = { score: score.score };
const obj2 = { score: score2.score };
num = autocompleter_sortByMatchScoreDefault(obj, obj2);
2026-09-03 10:05:34 +00:00
}
}
return num;
}
2026-07-20 16:05:17 +00:00
function _computeRows(query) {
2026-08-24 06:08:38 +00:00
set = new Set();
if (channel != null) {
const type = channel.type;
2026-07-20 16:05:17 +00:00
}
let tmp = null == guild;
2026-07-29 08:29:29 +00:00
if (!tmp) {
tmp = inviteTargetType === InviteTargetTypes.EMBEDDED_APPLICATION;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (!tmp) {
tmp = type === constants.GUILD_VOICE;
2026-07-20 16:05:17 +00:00
}
let id = null;
2026-07-29 08:29:29 +00:00
if (!tmp) {
id = guild.id;
2026-07-20 16:05:17 +00:00
}
const mostRecentDMedUser = set1(9854).getMostRecentDMedUser(set, id);
2026-07-20 16:05:17 +00:00
let isBlockedOrIgnoredResult = null == mostRecentDMedUser;
if (!isBlockedOrIgnoredResult) {
isBlockedOrIgnoredResult = RelationshipStore.isBlockedOrIgnored(mostRecentDMedUser.id);
2026-07-20 16:05:17 +00:00
}
if (!isBlockedOrIgnoredResult) {
set.add(mostRecentDMedUser.id);
}
const userAffinities = UserAffinitiesV2Store.getUserAffinities();
2026-07-29 08:29:29 +00:00
for (const item10040 of userAffinities) {
let addResult1 = set.add(item10040.otherUserId);
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-23 10:11:24 +00:00
set1 = new Set();
if (inviteTargetType === InviteTargetTypes.EMBEDDED_APPLICATION) {
const channelHistory = QuickSwitcherStore.getChannelHistory();
const mapped = channelHistory.map((item) => channel.getChannel(item));
const found = mapped.filter(set1(1369).isNotNullish);
2026-07-29 08:29:29 +00:00
const found1 = found.filter((type) => type.type === constants.GUILD_TEXT);
const found2 = found1.filter((item) => PermissionStore.can(constants2.SEND_MESSAGES, item));
2026-07-20 16:05:17 +00:00
const substr = found2.slice(0, 3);
const item = substr.forEach((id) => set1.add(id.id));
}
const obj2 = set1(9854);
return set1(9854).generateRowsForQuery({ query, omitUserIds: set, suggestedUserIds: set, maxRowsWithoutQuery: 100, omitGuildId: id, suggestedChannelIds: set1, inviteTargetType });
2026-07-20 16:05:17 +00:00
}
const Constants = fn(1074);
({ ChannelTypes: closure_14, Permissions: closure_15 } = Constants);
const InviteTargetTypes = fn(7750).InviteTargetTypes;
2026-07-23 10:11:24 +00:00
let set = new Set();
let rows = [];
2026-07-23 10:11:24 +00:00
let map = new Map();
let counts = { numFriends: 0, numDms: 0, numGroupDms: 0, numChannels: 0 };
2026-08-24 06:08:38 +00:00
const Store = initializeDefault.Store;
2026-07-29 08:29:29 +00:00
class InviteSuggestionsStore extends Store {
}
const prototype = InviteSuggestionsStore.prototype;
prototype["initialize"] = function initialize() {
this.waitFor(ChannelStore, PermissionStore, QuickSwitcherStore, RelationshipStore, UserAffinitiesV2Store);
2026-07-29 08:29:29 +00:00
};
prototype["getInviteSuggestionRows"] = function getInviteSuggestionRows() {
return rows;
2026-07-29 08:29:29 +00:00
};
prototype["getTotalSuggestionsCount"] = function getTotalSuggestionsCount() {
return length;
2026-07-29 08:29:29 +00:00
};
prototype["getInitialCounts"] = function getInitialCounts() {
return counts;
2026-07-29 08:29:29 +00:00
};
prototype["getSelectedInviteMetadata"] = function getSelectedInviteMetadata(row) {
value = map.get(row);
const userAffinities = UserAffinitiesV2Store.getUserAffinities();
2026-07-29 08:29:29 +00:00
if (null != value) {
const obj = { rowNum: value.index, isAffinitySuggestion: row.isSuggested, numTotal: rows.length, numAffinityConnections: arr.length, isFiltered };
2026-07-29 08:29:29 +00:00
return obj;
}
};
InviteSuggestionsStore.displayName = "InviteSuggestionsStore";
const inviteSuggestionsStore = new InviteSuggestionsStore(DispatcherDefault, {
2026-07-20 16:05:17 +00:00
LOAD_INVITE_SUGGESTIONS: function refreshInviteSuggestions(guild) {
({ omitUserIds, channel, inviteTargetType } = guild);
guild = null;
if (null != channel) {
guild = guild.guild;
}
applicationId = guild.applicationId;
const blockedOrIgnoredIDs = RelationshipStore.getBlockedOrIgnoredIDs();
const usersAlreadyJoined = InstantInviteUtils.getUsersAlreadyJoined({ channel, applicationId, inviteTargetType });
2026-07-20 16:05:17 +00:00
const items = [...usersAlreadyJoined];
2026-08-24 06:08:38 +00:00
set = new Set(items);
closure_4 = false;
2026-07-20 16:05:17 +00:00
const tmp5 = _computeRows("");
rows = tmp5.rows;
2026-08-24 06:08:38 +00:00
map = new Map();
const item = rows.forEach((item, index) => {
const result = map.set(item, { index });
2026-07-29 08:29:29 +00:00
});
counts = tmp5.counts;
2026-07-20 16:05:17 +00:00
},
INVITE_SUGGESTIONS_SEARCH: function handleSearch(query) {
query = query.query;
2026-09-03 10:05:34 +00:00
closure_4 = "" !== query;
rows = _computeRows(query).rows;
2026-09-03 10:05:34 +00:00
const sorted = rows.sort(compareRowsByMatchScore);
2026-08-24 06:08:38 +00:00
map = new Map();
const item = rows.forEach((item, index) => {
const result = map.set(item, { index });
2026-07-29 08:29:29 +00:00
});
2026-07-20 16:05:17 +00:00
}
});
const size = fn(2);
let result = size.fileFinishedImporting("stores/InviteSuggestionsStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default inviteSuggestionsStore;