Skipped 1 file(s) >100MB (GitHub limit): source/__polyfill/04xxx/module_4941.js (118.4 MB)
304 lines
12 KiB
TypeScript
304 lines
12 KiB
TypeScript
// Module ID: 10088
|
|
// Function ID: 10089
|
|
// Name: InviteSuggestionsStore
|
|
// Dependencies: [10089, 7893, 2041, 5638, 2105, 4395, 4405, 1074, 7976, 10077, 5730, 1370, 504, 573, 2]
|
|
|
|
// Module 10088 (InviteSuggestionsStore)
|
|
import initializeDefault from "initialize" /* 504 */;
|
|
import DispatcherDefault from "Dispatcher" /* 573 */;
|
|
import autocompleter_sortByMatchScoreDefault from "autocompleter/sortByMatchScore" /* 5730 */;
|
|
import InstantInviteUtils from "InstantInviteUtils" /* 10077 */;
|
|
import QuickSwitcherStore from "QuickSwitcherStore" /* 10089 */;
|
|
import UserAffinitiesV2Store from "UserAffinitiesV2Store" /* 7893 */;
|
|
import ChannelStore from "ChannelStore" /* 2041 */;
|
|
import GuildMemberRequesterStore from "GuildMemberRequesterStore" /* 5638 */;
|
|
import GuildMemberStore from "GuildMemberStore" /* 2105 */;
|
|
import PermissionStore from "PermissionStore" /* 4395 */;
|
|
import RelationshipStore from "RelationshipStore" /* 4405 */;
|
|
|
|
require = fn;
|
|
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);
|
|
}
|
|
}
|
|
return num;
|
|
}
|
|
function getOmitGuildId() {
|
|
let id = null;
|
|
if (null != user) {
|
|
id = null;
|
|
if (inviteTargetType !== InviteTargetTypes.EMBEDDED_APPLICATION) {
|
|
let type;
|
|
if (channel != null) {
|
|
type = channel.type;
|
|
}
|
|
id = null;
|
|
if (type !== constants.GUILD_VOICE) {
|
|
id = user.id;
|
|
}
|
|
}
|
|
}
|
|
return id;
|
|
}
|
|
const Constants = fn(1074);
|
|
({ ChannelTypes: closure_16, Permissions: closure_17 } = Constants);
|
|
const InviteTargetTypes = fn(7976).InviteTargetTypes;
|
|
let set = new Set();
|
|
let rows = [];
|
|
let map = new Map();
|
|
let counts = { numFriends: 0, numDms: 0, numGroupDms: 0, numChannels: 0 };
|
|
let query = "";
|
|
const Store = initializeDefault.Store;
|
|
class InviteSuggestionsStore extends Store {
|
|
}
|
|
const prototype = InviteSuggestionsStore.prototype;
|
|
prototype["initialize"] = function initialize() {
|
|
this.waitFor(ChannelStore, GuildMemberRequesterStore, GuildMemberStore, PermissionStore, QuickSwitcherStore, RelationshipStore, UserAffinitiesV2Store);
|
|
};
|
|
prototype["getInviteSuggestionRows"] = function getInviteSuggestionRows() {
|
|
return rows;
|
|
};
|
|
prototype["getTotalSuggestionsCount"] = function getTotalSuggestionsCount() {
|
|
return length;
|
|
};
|
|
prototype["getInitialCounts"] = function getInitialCounts() {
|
|
return counts;
|
|
};
|
|
prototype["getSelectedInviteMetadata"] = function getSelectedInviteMetadata(row) {
|
|
value = map.get(row);
|
|
const userAffinities = UserAffinitiesV2Store.getUserAffinities();
|
|
if (null != value) {
|
|
const obj = { rowNum: value.index, isAffinitySuggestion: row.isSuggested, numTotal: rows.length, numAffinityConnections: arr.length, isFiltered };
|
|
return obj;
|
|
}
|
|
};
|
|
InviteSuggestionsStore.displayName = "InviteSuggestionsStore";
|
|
const inviteSuggestionsStore = new InviteSuggestionsStore(DispatcherDefault, {
|
|
LOAD_INVITE_SUGGESTIONS: function refreshInviteSuggestions(arg0) {
|
|
({ inviteTargetType, guild: closure_1_5, channel: closure_1_6, applicationId: closure_1_7 } = arg0);
|
|
query = "";
|
|
const blockedOrIgnoredIDs = RelationshipStore.getBlockedOrIgnoredIDs();
|
|
const usersAlreadyJoined = InstantInviteUtils.getUsersAlreadyJoined({ channel, applicationId, inviteTargetType });
|
|
const items = [...usersAlreadyJoined];
|
|
set = new Set(items);
|
|
closure_4 = "" !== query;
|
|
const tmp4 = (function _computeRows(query) {
|
|
set = new Set();
|
|
const tmp = closure_25();
|
|
const mostRecentDMedUser = set1(10077).getMostRecentDMedUser(omitUserIds, tmp);
|
|
let isBlockedOrIgnoredResult = null == mostRecentDMedUser;
|
|
if (!isBlockedOrIgnoredResult) {
|
|
isBlockedOrIgnoredResult = blockedOrIgnored.isBlockedOrIgnored(mostRecentDMedUser.id);
|
|
}
|
|
if (!isBlockedOrIgnoredResult) {
|
|
set.add(mostRecentDMedUser.id);
|
|
}
|
|
userAffinities = userAffinities.getUserAffinities();
|
|
for (const item10031 of userAffinities) {
|
|
let addResult1 = set.add(item10031.otherUserId);
|
|
continue;
|
|
}
|
|
set1 = new Set();
|
|
if (inviteTargetType === constants.EMBEDDED_APPLICATION) {
|
|
channelHistory = channelHistory.getChannelHistory();
|
|
const mapped = channelHistory.map((item) => channel.getChannel(item));
|
|
const found = mapped.filter(set1(1370).isNotNullish);
|
|
const found1 = found.filter((type) => type.type === constants.GUILD_TEXT);
|
|
const found2 = found1.filter((item) => closure_1_14.can(constants2.SEND_MESSAGES, item));
|
|
const substr = found2.slice(0, 3);
|
|
const item = substr.forEach((id) => set1.add(id.id));
|
|
}
|
|
const obj2 = set1(10077);
|
|
return set1(10077).generateRowsForQuery({ query, omitUserIds, suggestedUserIds: set, maxRowsWithoutQuery: 100, omitGuildId: tmp, suggestedChannelIds: set1, inviteTargetType });
|
|
})(query);
|
|
rows = tmp4.rows;
|
|
if (closure_4) {
|
|
const sorted = rows.sort(compareRowsByMatchScore);
|
|
}
|
|
map = new Map();
|
|
const item = rows.forEach((item, index) => {
|
|
const result = map.set(item, { index });
|
|
});
|
|
(function requestMembership(rows) {
|
|
const tmp = getOmitGuildId();
|
|
if (null != tmp) {
|
|
const iter = rows[Symbol.iterator]();
|
|
const nextResult = iter.next();
|
|
while (iter !== undefined) {
|
|
let tmp5 = nextResult;
|
|
let tmp6 = id;
|
|
let tmp8 = nextResult.type !== id(10077).RowTypes.DM;
|
|
if (tmp8) {
|
|
tmp8 = tmp5.type !== tmp6(10077).RowTypes.FRIEND;
|
|
}
|
|
if (!tmp8) {
|
|
let member = GuildMemberRequesterStore.requestMember(tmp, tmp5.item.id);
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
})(rows);
|
|
counts = tmp4.counts;
|
|
},
|
|
INVITE_SUGGESTIONS_SEARCH: function handleSearch(query) {
|
|
query = query.query;
|
|
closure_4 = "" !== query;
|
|
({ rows, counts } = (function _computeRows(query) {
|
|
set = new Set();
|
|
const tmp = closure_25();
|
|
const mostRecentDMedUser = set1(10077).getMostRecentDMedUser(omitUserIds, tmp);
|
|
let isBlockedOrIgnoredResult = null == mostRecentDMedUser;
|
|
if (!isBlockedOrIgnoredResult) {
|
|
isBlockedOrIgnoredResult = blockedOrIgnored.isBlockedOrIgnored(mostRecentDMedUser.id);
|
|
}
|
|
if (!isBlockedOrIgnoredResult) {
|
|
set.add(mostRecentDMedUser.id);
|
|
}
|
|
userAffinities = userAffinities.getUserAffinities();
|
|
for (const item10031 of userAffinities) {
|
|
let addResult1 = set.add(item10031.otherUserId);
|
|
continue;
|
|
}
|
|
set1 = new Set();
|
|
if (inviteTargetType === constants.EMBEDDED_APPLICATION) {
|
|
channelHistory = channelHistory.getChannelHistory();
|
|
const mapped = channelHistory.map((item) => channel.getChannel(item));
|
|
const found = mapped.filter(set1(1370).isNotNullish);
|
|
const found1 = found.filter((type) => type.type === constants.GUILD_TEXT);
|
|
const found2 = found1.filter((item) => closure_1_14.can(constants2.SEND_MESSAGES, item));
|
|
const substr = found2.slice(0, 3);
|
|
const item = substr.forEach((id) => set1.add(id.id));
|
|
}
|
|
const obj2 = set1(10077);
|
|
return set1(10077).generateRowsForQuery({ query, omitUserIds, suggestedUserIds: set, maxRowsWithoutQuery: 100, omitGuildId: tmp, suggestedChannelIds: set1, inviteTargetType });
|
|
})(query));
|
|
if (closure_4) {
|
|
const sorted = rows.sort(compareRowsByMatchScore);
|
|
}
|
|
map = new Map();
|
|
const item = rows.forEach((item, index) => {
|
|
const result = map.set(item, { index });
|
|
});
|
|
(function requestMembership(rows) {
|
|
const tmp = getOmitGuildId();
|
|
if (null != tmp) {
|
|
const iter = rows[Symbol.iterator]();
|
|
const nextResult = iter.next();
|
|
while (iter !== undefined) {
|
|
let tmp5 = nextResult;
|
|
let tmp6 = id;
|
|
let tmp8 = nextResult.type !== id(10077).RowTypes.DM;
|
|
if (tmp8) {
|
|
tmp8 = tmp5.type !== tmp6(10077).RowTypes.FRIEND;
|
|
}
|
|
if (!tmp8) {
|
|
let member = GuildMemberRequesterStore.requestMember(tmp, tmp5.item.id);
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
})(rows);
|
|
},
|
|
GUILD_MEMBERS_CHUNK_BATCH: function handleGuildMembersChunkBatch(chunks) {
|
|
chunks = chunks.chunks;
|
|
set = undefined;
|
|
let id = null;
|
|
if (null != user) {
|
|
id = null;
|
|
if (inviteTargetType !== InviteTargetTypes.EMBEDDED_APPLICATION) {
|
|
let type;
|
|
if (channel != null) {
|
|
type = channel.type;
|
|
}
|
|
id = null;
|
|
if (type !== constants.GUILD_VOICE) {
|
|
id = user.id;
|
|
}
|
|
}
|
|
}
|
|
if (null == id) {
|
|
return false;
|
|
} else {
|
|
const _Set = Set;
|
|
set = new Set(rows.map((item) => item.item.id));
|
|
if (chunks.some((guildId) => {
|
|
let someResult = guildId.guildId === id;
|
|
if (someResult) {
|
|
const members = guildId.members;
|
|
someResult = members.some((user) => set.has(user.user.id));
|
|
}
|
|
return someResult;
|
|
})) {
|
|
closure_4 = "" !== query;
|
|
({ rows, counts } = (function _computeRows(query) {
|
|
set = new Set();
|
|
const tmp = closure_25();
|
|
const mostRecentDMedUser = set1(10077).getMostRecentDMedUser(omitUserIds, tmp);
|
|
let isBlockedOrIgnoredResult = null == mostRecentDMedUser;
|
|
if (!isBlockedOrIgnoredResult) {
|
|
isBlockedOrIgnoredResult = blockedOrIgnored.isBlockedOrIgnored(mostRecentDMedUser.id);
|
|
}
|
|
if (!isBlockedOrIgnoredResult) {
|
|
set.add(mostRecentDMedUser.id);
|
|
}
|
|
userAffinities = userAffinities.getUserAffinities();
|
|
for (const item10031 of userAffinities) {
|
|
let addResult1 = set.add(item10031.otherUserId);
|
|
continue;
|
|
}
|
|
set1 = new Set();
|
|
if (inviteTargetType === constants.EMBEDDED_APPLICATION) {
|
|
channelHistory = channelHistory.getChannelHistory();
|
|
const mapped = channelHistory.map((item) => channel.getChannel(item));
|
|
const found = mapped.filter(set1(1370).isNotNullish);
|
|
const found1 = found.filter((type) => type.type === constants.GUILD_TEXT);
|
|
const found2 = found1.filter((item) => closure_1_14.can(constants2.SEND_MESSAGES, item));
|
|
const substr = found2.slice(0, 3);
|
|
const item = substr.forEach((id) => set1.add(id.id));
|
|
}
|
|
const obj2 = set1(10077);
|
|
return set1(10077).generateRowsForQuery({ query, omitUserIds, suggestedUserIds: set, maxRowsWithoutQuery: 100, omitGuildId: tmp, suggestedChannelIds: set1, inviteTargetType });
|
|
})(query));
|
|
if (closure_4) {
|
|
const sorted = rows.sort(compareRowsByMatchScore);
|
|
}
|
|
const _Map = Map;
|
|
map = new Map();
|
|
let item = rows.forEach((item, index) => {
|
|
const result = map.set(item, { index });
|
|
});
|
|
(function requestMembership(rows) {
|
|
const tmp = getOmitGuildId();
|
|
if (null != tmp) {
|
|
const iter = rows[Symbol.iterator]();
|
|
const nextResult = iter.next();
|
|
while (iter !== undefined) {
|
|
let tmp5 = nextResult;
|
|
let tmp6 = id;
|
|
let tmp8 = nextResult.type !== id(10077).RowTypes.DM;
|
|
if (tmp8) {
|
|
tmp8 = tmp5.type !== tmp6(10077).RowTypes.FRIEND;
|
|
}
|
|
if (!tmp8) {
|
|
let member = GuildMemberRequesterStore.requestMember(tmp, tmp5.item.id);
|
|
}
|
|
continue;
|
|
}
|
|
}
|
|
})(rows);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
const size = fn(2);
|
|
let result = size.fileFinishedImporting("stores/InviteSuggestionsStore.tsx");
|
|
|
|
export default inviteSuggestionsStore;
|