decord/source/stores/PrivateChannelRecipientsInviteStore.tsx

523 lines
17 KiB
TypeScript
Raw Normal View History

2026-08-06 08:05:19 +00:00
// Module ID: 12931
// Function ID: 12932
2026-07-29 08:29:29 +00:00
// Name: performQuery
2026-08-06 08:05:19 +00:00
// Dependencies: [4199, 7041, 1376, 1372, 5750, 5209, 1971, 1891, 3921, 1903, 676, 12932, 5214, 1884, 4123, 3957, 7233, 589, 709, 2]
2026-07-23 10:11:24 +00:00
2026-08-06 08:05:19 +00:00
// Module 12931 (performQuery)
2026-07-29 08:29:29 +00:00
import getHash from "getHash";
import recomputeAffinities from "recomputeAffinities";
import { PrivateChannelRecord } from "createChannelRecord";
import ensureGuildLoaded from "ensureGuildLoaded";
import hasConsented from "hasConsented";
import handleChannelSelect from "handleChannelSelect";
import trackCommunicationDisabled from "trackCommunicationDisabled";
import createGuildRecordFromRust from "createGuildRecordFromRust";
import upsertRelationship from "upsertRelationship";
import mergeGuildAvatar from "mergeGuildAvatar";
2026-07-23 10:11:24 +00:00
import ME from "ME";
2026-07-29 08:29:29 +00:00
import { Store } from "initialize";
import set from "createChannelRecord";
2026-07-20 16:05:17 +00:00
let Consents;
2026-07-29 08:29:29 +00:00
let closure_14;
2026-07-23 10:11:24 +00:00
const require = arg1;
2026-07-29 08:29:29 +00:00
function performQuery() {
if (c15) {
channel = channel.getChannel(c22);
if (0 === _var.trim().length) {
if (null != set1) {
set1.clearQuery();
}
let _require = channel;
const currentUser = authStore.getCurrentUser();
let obj1 = currentUser;
frictionlessGDMsEnabled = _require(frictionlessGDMsEnabled[11]).getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore");
const items = [];
HermesBuiltin.arraySpread(store2.getFriendIDs(), 0);
let isStaffResult;
if (currentUser != null) {
isStaffResult = currentUser.isStaff();
}
let arr = items;
if (isStaffResult) {
const found = authStore.filter((isStaff) => {
let isStaffResult = isStaff.isStaff();
if (isStaffResult) {
isStaffResult = isStaff.id !== obj1.id;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return isStaffResult;
}, false);
const mapped = found.map((id) => id.id);
const _Array = Array;
const _Set = Set;
const items1 = [];
HermesBuiltin.arraySpread(mapped, HermesBuiltin.arraySpread(items, 0));
const set = new Set(items1);
arr = Array.from(set);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
set1 = null;
if (frictionlessGDMsEnabled) {
const _Set2 = Set;
set1 = new Set(store.getGuildIds());
userAffinities = userAffinities.getUserAffinities();
const mapped1 = userAffinities.map((otherUserId) => otherUserId.otherUserId);
const found1 = mapped1.filter((arg0) => {
let id;
if (obj1 != null) {
id = obj1.id;
}
return arg0 !== id;
});
const found2 = found1.filter((id) => !upsertRelationship.isBlockedOrIgnored(id));
const found3 = found2.filter((id) => !upsertRelationship.isFriend(id));
const _Array2 = Array;
const _Set3 = Set;
const items2 = [];
HermesBuiltin.arraySpread(found3, HermesBuiltin.arraySpread(arr, 0));
const set2 = new Set(items2);
arr = Array.from(set2);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let isGroupDMResult;
if (channel != null) {
isGroupDMResult = channel.isGroupDM();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
let found4 = arr;
if (isGroupDMResult) {
found4 = arr.filter((arg0) => {
recipients = recipients.recipients;
return !recipients.includes(arg0);
});
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
const reduced = found4.reduce((arr) => {
const user = outer1_13.getUser(arg1);
if (null != user) {
if (!user.isProvisional) {
if (user.bot) {
if (user.isStaff()) {
let isStaffResult;
if (obj1 != null) {
isStaffResult = obj2.isStaff();
}
obj2 = obj1;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
const obj = { user: null, comparator: null };
obj[0] = user;
obj[1] = obj1(frictionlessGDMsEnabled[14]).getName(user);
if (frictionlessGDMsEnabled) {
if (null != set1) {
if (!outer1_12.isFriend(user.id)) {
arr = outer1_26(user.id, tmp5);
if (0 === arr.length) {
if (user.isStaff()) {
let isStaffResult1;
if (obj1 != null) {
isStaffResult1 = obj5.isStaff();
}
obj5 = obj1;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
return arr;
}
if (arr.length > 0) {
obj.mutualGuilds = arr;
2026-07-20 16:05:17 +00:00
}
}
}
}
2026-07-29 08:29:29 +00:00
arr = arr.push(obj);
return arr;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
return arr;
}, []);
let closure_18 = reduced.sort(sortUserList);
if (c20 !== false) {
c20 = false;
}
2026-07-20 16:05:17 +00:00
return true;
} else {
2026-07-29 08:29:29 +00:00
const currentUser1 = authStore.getCurrentUser();
let flag2;
if (currentUser1 != null) {
flag2 = currentUser1.isStaff();
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (flag2 == null) {
flag2 = false;
}
obj1 = _require(frictionlessGDMsEnabled[11]);
const frictionlessGDMsEnabled1 = obj1.getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore");
if (frictionlessGDMsEnabled1) {
const members = obj1(frictionlessGDMsEnabled[12]).requestMembers(null, _var);
const obj3 = obj1(frictionlessGDMsEnabled[12]);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (null != set1) {
let obj = { query: null, filters: null, blacklist: null, boosters: null };
obj[0] = _var;
let tmp12;
if (!frictionlessGDMsEnabled1) {
obj = { friends: true, staff: null, provisional: false };
obj[1] = flag2;
tmp12 = obj;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj[1] = tmp12;
obj[2] = tmp10;
frequentlyWithoutFetchingLatest = frequentlyWithoutFetchingLatest.getFrequentlyWithoutFetchingLatest();
const found5 = frequentlyWithoutFetchingLatest.filter((isDM) => isDM instanceof closure_6 && isDM.isDM());
const _Math = Math;
const items3 = [];
HermesBuiltin.arraySpread(found5.map((id) => scoreWithoutFetchingLatest.getScoreWithoutFetchingLatest(id.id)), 0);
const _Math2 = Math;
_require = HermesBuiltin.apply(items3, Math);
obj1 = {};
const item = found5.forEach((id) => {
const scoreWithoutFetchingLatest = outer1_9.getScoreWithoutFetchingLatest(id.id);
const recipientId = id.getRecipientId();
let num = 0;
if (outer1_12.isFriend(recipientId)) {
num = 0.2;
}
let num2 = 0;
if (null != outer1_7.getDMFromUserId(recipientId)) {
num2 = 0.1;
}
obj1[recipientId] = 1 + scoreWithoutFetchingLatest / closure_0 + num + num2;
});
obj[3] = obj1;
set1.setQuery(obj);
2026-07-20 16:05:17 +00:00
}
return false;
}
} else {
return false;
}
}
function updateHasFriends() {
2026-07-29 08:29:29 +00:00
if (c15) {
const tmp3 = store2.getFriendCount() > 0;
let c19 = tmp3;
return tmp3 !== c19;
2026-07-20 16:05:17 +00:00
} else {
return false;
}
}
function sortUserList(user, user2) {
2026-08-06 08:05:19 +00:00
const obj = require(1884) /* isNullOrEmpty */;
const name = importDefault(4123).getName(user.user);
const obj2 = importDefault(4123);
2026-07-20 16:05:17 +00:00
const stripDiacriticsResult = obj.stripDiacritics(name.toLocaleLowerCase());
2026-08-06 08:05:19 +00:00
const obj5 = require(1884) /* isNullOrEmpty */;
const name1 = importDefault(4123).getName(user2.user);
2026-07-20 16:05:17 +00:00
return stripDiacriticsResult.localeCompare(obj5.stripDiacritics(name1.toLocaleLowerCase()));
}
2026-07-23 10:11:24 +00:00
function getMutualGuildsWithCurrentUser(id, set) {
2026-08-06 08:05:19 +00:00
const RestrictedGuildIds = require(3957) /* explicitContentFromProto */.RestrictedGuildIds;
2026-07-20 16:05:17 +00:00
const setting = RestrictedGuildIds.getSetting();
const items = [];
2026-07-29 08:29:29 +00:00
const iter = set[Symbol.iterator]();
const nextResult = iter.next();
while (iter !== undefined) {
let tmp2 = nextResult;
if (!setting.includes(nextResult)) {
let tmp3 = member;
let tmp4 = nextResult;
if (member.isMember(tmp2, id)) {
let tmp5 = store;
let tmp6 = nextResult;
let guild = store.getGuild(tmp2);
if (null != guild) {
let tmp9 = guild;
let arr = items.push(tmp8);
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
}
continue;
2026-07-20 16:05:17 +00:00
}
return items;
}
2026-07-29 08:29:29 +00:00
function parseUserResults(results) {
let comparator;
let id;
results = results.results;
if (c15) {
if ("" !== c16) {
2026-07-20 16:05:17 +00:00
const currentUser = authStore.getCurrentUser();
2026-08-06 08:05:19 +00:00
const frictionlessGDMsEnabled = require(12932) /* getFrictionlessGDMsEnabled */.getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore");
2026-07-20 16:05:17 +00:00
let set = null;
if (frictionlessGDMsEnabled) {
const _Set = Set;
2026-07-23 10:11:24 +00:00
set = new Set(store.getGuildIds());
2026-07-20 16:05:17 +00:00
}
const items = [];
2026-07-29 08:29:29 +00:00
const iter = results[Symbol.iterator]();
2026-08-06 08:05:19 +00:00
const obj4 = require(12932) /* getFrictionlessGDMsEnabled */;
2026-07-29 08:29:29 +00:00
while (iter !== undefined) {
({ id, comparator } = nextResult);
if (null == currentUser) {
let tmp12 = authStore;
let tmp13 = id;
let user = authStore.getUser(id);
let obj = user;
if (null != user) {
let tmp37 = user;
if (!obj.isProvisional) {
let tmp15 = user;
if (!obj.bot) {
obj = { user: null, comparator: null };
let tmp18 = user;
obj[0] = obj;
let tmp19 = comparator;
obj[1] = comparator;
let tmp20 = obj;
if (frictionlessGDMsEnabled) {
if (null != set) {
let tmp38 = store2;
let tmp39 = user;
if (!store2.isFriend(obj.id)) {
let tmp21 = getMutualGuildsWithCurrentUser;
let tmp22 = user;
let arr2 = getMutualGuildsWithCurrentUser(obj.id, set);
let arr3 = arr2;
if (0 !== arr2.length) {
let tmp25 = arr2;
if (arr3.length > 0) {
let tmp26 = obj;
let tmp27 = arr2;
tmp20.mutualGuilds = arr3;
}
} else {
let tmp23 = user;
if (!obj.isStaff()) {
continue;
2026-07-20 16:05:17 +00:00
} else {
2026-07-29 08:29:29 +00:00
let isStaffResult;
if (currentUser != null) {
isStaffResult = currentUser.isStaff();
2026-07-20 16:05:17 +00:00
}
}
}
2026-07-29 08:29:29 +00:00
continue;
2026-07-20 16:05:17 +00:00
}
}
2026-07-29 08:29:29 +00:00
}
let tmp28 = obj;
let arr = items.push(tmp20);
} else {
let tmp16 = user;
if (obj.isStaff()) {
let isStaffResult1;
if (currentUser != null) {
isStaffResult1 = currentUser.isStaff();
2026-07-20 16:05:17 +00:00
}
}
}
}
}
2026-07-29 08:29:29 +00:00
} else {
let tmp11 = id;
}
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
privateChannelRecipientsInviteStoreClass.emitChange();
nextResult = iter.next();
2026-07-20 16:05:17 +00:00
}
}
}
function handleModalActionSheetOpen(key) {
2026-07-29 08:29:29 +00:00
if (key.key !== closure_14) {
2026-07-20 16:05:17 +00:00
return false;
} else {
2026-07-29 08:29:29 +00:00
let c15 = true;
let closure_19 = store2.getFriendCount() > 0;
if (null != userSearchContext) {
userSearchContext.destroy();
userSearchContext = null;
}
2026-08-06 08:05:19 +00:00
userSearchContext = importDefault(7233).getUserSearchContext(parseUserResults, 1000);
2026-07-29 08:29:29 +00:00
let c22 = null;
let c16 = "";
let c17 = 0;
performQuery();
2026-07-20 16:05:17 +00:00
}
}
function handleActionSheetDismiss(key) {
2026-07-29 08:29:29 +00:00
if (key.key !== closure_14) {
2026-07-20 16:05:17 +00:00
return false;
} else {
2026-07-29 08:29:29 +00:00
if (null != c3) {
c3.destroy();
c3 = null;
}
let c16 = "";
let c17 = 0;
let closure_18 = [];
const _Set = Set;
const set = new Set();
let c15 = false;
let c22 = null;
let c20 = false;
2026-07-20 16:05:17 +00:00
}
}
function performQueryOnAffinityChange() {
2026-07-29 08:29:29 +00:00
let tmp = !c15;
if (c15) {
2026-08-06 08:05:19 +00:00
tmp = !require(12932) /* getFrictionlessGDMsEnabled */.getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore");
const obj = require(12932) /* getFrictionlessGDMsEnabled */;
2026-07-20 16:05:17 +00:00
}
let tmp4 = !tmp;
if (!tmp) {
tmp4 = performQuery();
}
return tmp4;
}
2026-07-29 08:29:29 +00:00
({ NEW_GROUP_DM_POPOUT_ID: closure_14, Consents } = ME);
let c15 = false;
let c16 = "";
let c17 = 0;
let closure_18 = [];
let c19 = false;
2026-07-23 10:11:24 +00:00
let c20 = false;
let set = new Set();
2026-07-29 08:29:29 +00:00
let c22 = null;
class PrivateChannelRecipientsInviteStoreClass extends Store {
}
const prototype = PrivateChannelRecipientsInviteStoreClass.prototype;
prototype["initialize"] = function initialize() {
this.waitFor(ensureGuildLoaded, hasConsented, getHash, handleChannelSelect, trackCommunicationDisabled, createGuildRecordFromRust, upsertRelationship, recomputeAffinities, mergeGuildAvatar);
const items = [mergeGuildAvatar, ensureGuildLoaded];
this.syncWith(items, performQuery);
const items1 = [recomputeAffinities];
this.syncWith(items1, performQueryOnAffinityChange);
const items2 = [upsertRelationship];
this.syncWith(items2, updateHasFriends);
};
prototype["getResults"] = function getResults() {
return closure_18;
};
prototype["hasFriends"] = function hasFriends() {
return c19;
};
prototype["getSelectedUsers"] = function getSelectedUsers() {
return set;
};
prototype["getQuery"] = function getQuery() {
return c16;
};
prototype["getState"] = function getState() {
return { query: c16, selectedRow: c17, selectedUsers: set, results: closure_18, hasFriends: c19, isLoading: c20 };
};
PrivateChannelRecipientsInviteStoreClass.displayName = "PrivateChannelRecipientsInviteStore";
const privateChannelRecipientsInviteStoreClass = new PrivateChannelRecipientsInviteStoreClass(require("dispatcher"), {
2026-07-20 16:05:17 +00:00
CONNECTION_OPEN: function handleConnectionOpen() {
2026-07-29 08:29:29 +00:00
let c16 = "";
let c17 = 0;
let closure_18 = [];
const set = new Set();
let c15 = false;
let c22 = null;
let c20 = false;
2026-07-20 16:05:17 +00:00
},
GUILD_MEMBERS_CHUNK_BATCH: function handleGuildMembersChunkBatch() {
2026-07-29 08:29:29 +00:00
let tmp = !c15;
if (c15) {
2026-08-06 08:05:19 +00:00
tmp = !require(12932) /* getFrictionlessGDMsEnabled */.getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore");
const obj = require(12932) /* getFrictionlessGDMsEnabled */;
2026-07-20 16:05:17 +00:00
}
let tmp4 = !tmp;
if (!tmp) {
2026-07-29 08:29:29 +00:00
let flag2 = c20 !== false;
if (flag2) {
c20 = false;
flag2 = true;
}
tmp4 = flag2;
2026-07-20 16:05:17 +00:00
}
return tmp4;
},
GUILD_MEMBERS_REQUEST: function handleGuildMembersRequest(query) {
2026-07-29 08:29:29 +00:00
let tmp = !c15;
if (c15) {
2026-08-06 08:05:19 +00:00
tmp = !require(12932) /* getFrictionlessGDMsEnabled */.getFrictionlessGDMsEnabled("PrivateChannelRecipientsInviteStore");
const obj = require(12932) /* getFrictionlessGDMsEnabled */;
2026-07-20 16:05:17 +00:00
}
let tmp4 = !tmp;
if (!tmp) {
let tmp6 = query.query === _var.toLocaleLowerCase();
if (tmp6) {
2026-07-29 08:29:29 +00:00
let flag2 = c20 !== true;
if (flag2) {
c20 = true;
flag2 = true;
}
tmp6 = flag2;
2026-07-20 16:05:17 +00:00
}
tmp4 = tmp6;
}
return tmp4;
},
CHANNEL_SELECT: function handleChannelSelect(guildId) {
if (null != guildId.guildId) {
return false;
} else {
2026-07-29 08:29:29 +00:00
let c16 = "";
let c17 = 0;
let closure_18 = [];
const _Set = Set;
const set = new Set();
let c20 = false;
let c22 = tmp;
2026-07-20 16:05:17 +00:00
return performQuery();
}
},
MODAL_PUSH: handleModalActionSheetOpen,
SHOW_ACTION_SHEET: handleModalActionSheetOpen,
PRIVATE_CHANNEL_RECIPIENTS_INVITE_OPEN: function handleInviteOpen(channelId) {
2026-07-29 08:29:29 +00:00
let c15 = true;
let closure_19 = store2.getFriendCount() > 0;
if (null != userSearchContext) {
userSearchContext.destroy();
userSearchContext = null;
}
2026-08-06 08:05:19 +00:00
userSearchContext = importDefault(7233).getUserSearchContext(parseUserResults, 1000);
2026-07-20 16:05:17 +00:00
channelId = channelId.channelId;
2026-07-29 08:29:29 +00:00
let c16 = "";
let c17 = 0;
performQuery();
2026-07-20 16:05:17 +00:00
},
MODAL_POP: handleActionSheetDismiss,
HIDE_ACTION_SHEET: handleActionSheetDismiss,
2026-07-29 08:29:29 +00:00
PRIVATE_CHANNEL_RECIPIENTS_INVITE_CLOSE: function handleClose() {
if (null != c3) {
c3.destroy();
c3 = null;
}
let c16 = "";
let c17 = 0;
let closure_18 = [];
const set = new Set();
let c15 = false;
let c22 = null;
let c20 = false;
},
PRIVATE_CHANNEL_RECIPIENTS_INVITE_QUERY: function handleQuery(arg0) {
let c16;
let c22;
({ channelId: c22, query: c16 } = arg0);
let c17 = 0;
performQuery();
2026-07-20 16:05:17 +00:00
},
PRIVATE_CHANNEL_RECIPIENTS_INVITE_SELECT: function handleSelect(row) {
row = row.row;
},
PRIVATE_CHANNEL_RECIPIENTS_ADD_USER: function handleAddUser(userId) {
set.add(userId.userId);
2026-07-23 10:11:24 +00:00
set = new Set(set);
2026-07-20 16:05:17 +00:00
},
PRIVATE_CHANNEL_RECIPIENTS_REMOVE_USER: function handleRemoveUser(userId) {
set.delete(userId.userId);
2026-07-23 10:11:24 +00:00
set = new Set(set);
2026-07-20 16:05:17 +00:00
}
});
2026-07-29 08:29:29 +00:00
const result = set.fileFinishedImporting("stores/PrivateChannelRecipientsInviteStore.tsx");
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default privateChannelRecipientsInviteStoreClass;