decord/source/stores/PrivateChannelRecipientsInviteStore.tsx

367 lines
11 KiB
TypeScript
Raw Normal View History

2026-08-15 05:55:55 +00:00
// Module ID: 13303
// Function ID: 13304
2026-07-29 08:29:29 +00:00
// Name: performQuery
2026-08-15 05:55:55 +00:00
// Dependencies: [4288, 5407, 1395, 1391, 5258, 6772, 1990, 1910, 4030, 1922, 676, 1903, 4219, 7597, 589, 709, 2]
2026-07-23 10:11:24 +00:00
2026-08-15 05:55:55 +00:00
// Module 13303 (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";
2026-08-11 06:20:06 +00:00
import markAllUserIdListsStale from "markAllUserIdListsStale";
2026-07-29 08:29:29 +00:00
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) {
2026-08-07 06:50:47 +00:00
if (null != closure_3) {
closure_3.clearQuery();
2026-07-29 08:29:29 +00:00
}
2026-08-07 06:50:47 +00:00
let closure_0 = channel;
let arr = authStore;
2026-07-29 08:29:29 +00:00
const currentUser = authStore.getCurrentUser();
let obj1 = currentUser;
const items = [];
2026-08-07 06:50:47 +00:00
HermesBuiltin.arraySpread(store.getFriendIDs(), 0);
2026-07-29 08:29:29 +00:00
let isStaffResult;
if (currentUser != null) {
isStaffResult = currentUser.isStaff();
}
2026-08-07 06:50:47 +00:00
arr = items;
2026-07-29 08:29:29 +00:00
if (isStaffResult) {
2026-08-07 06:50:47 +00:00
const found = arr.filter((isStaff) => {
2026-07-29 08:29:29 +00:00
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
let isGroupDMResult;
if (channel != null) {
isGroupDMResult = channel.isGroupDM();
2026-07-20 16:05:17 +00:00
}
2026-08-07 06:50:47 +00:00
let found1 = arr;
2026-07-29 08:29:29 +00:00
if (isGroupDMResult) {
2026-08-07 06:50:47 +00:00
found1 = arr.filter((arg0) => {
2026-07-29 08:29:29 +00:00
recipients = recipients.recipients;
return !recipients.includes(arg0);
});
2026-07-20 16:05:17 +00:00
}
2026-08-07 06:50:47 +00:00
const reduced = found1.reduce((arr) => {
2026-07-29 08:29:29 +00:00
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;
2026-08-07 06:50:47 +00:00
obj[1] = obj1(outer1_2[12]).getName(user);
arr.push(obj);
2026-07-29 08:29:29 +00:00
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;
}
2026-08-07 06:50:47 +00:00
if (null != closure_3) {
2026-07-29 08:29:29 +00:00
let obj = { query: null, filters: null, blacklist: null, boosters: null };
obj[0] = _var;
2026-08-07 06:50:47 +00:00
obj = { friends: true, staff: null, provisional: false };
obj[1] = flag2;
obj[1] = obj;
obj[2] = tmp4;
closure_0 = undefined;
obj1 = undefined;
2026-07-29 08:29:29 +00:00
frequentlyWithoutFetchingLatest = frequentlyWithoutFetchingLatest.getFrequentlyWithoutFetchingLatest();
2026-08-07 06:50:47 +00:00
const found2 = frequentlyWithoutFetchingLatest.filter((isDM) => isDM instanceof closure_6 && isDM.isDM());
2026-07-29 08:29:29 +00:00
const _Math = Math;
2026-08-07 06:50:47 +00:00
const items2 = [];
HermesBuiltin.arraySpread(found2.map((id) => scoreWithoutFetchingLatest.getScoreWithoutFetchingLatest(id.id)), 0);
2026-07-29 08:29:29 +00:00
const _Math2 = Math;
2026-08-07 06:50:47 +00:00
closure_0 = HermesBuiltin.apply(items2, Math);
2026-07-29 08:29:29 +00:00
obj1 = {};
2026-08-07 06:50:47 +00:00
const item = found2.forEach((id) => {
2026-07-29 08:29:29 +00:00
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;
2026-08-07 06:50:47 +00:00
closure_3.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) {
2026-08-07 06:50:47 +00:00
const tmp3 = store.getFriendCount() > 0;
2026-07-29 08:29:29 +00:00
let c19 = tmp3;
return tmp3 !== c19;
2026-07-20 16:05:17 +00:00
} else {
return false;
}
}
function sortUserList(user, user2) {
2026-08-11 06:20:06 +00:00
const obj = require(1903) /* isNullOrEmpty */;
2026-08-15 05:55:55 +00:00
const name = importDefault(4219).getName(user.user);
const obj2 = importDefault(4219);
2026-07-20 16:05:17 +00:00
const stripDiacriticsResult = obj.stripDiacritics(name.toLocaleLowerCase());
2026-08-11 06:20:06 +00:00
const obj5 = require(1903) /* isNullOrEmpty */;
2026-08-15 05:55:55 +00:00
const name1 = importDefault(4219).getName(user2.user);
2026-07-20 16:05:17 +00:00
return stripDiacriticsResult.localeCompare(obj5.stripDiacritics(name1.toLocaleLowerCase()));
}
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();
const items = [];
2026-07-29 08:29:29 +00:00
const iter = results[Symbol.iterator]();
while (iter !== undefined) {
({ id, comparator } = nextResult);
if (null == currentUser) {
2026-08-07 06:50:47 +00:00
let tmp6 = authStore;
let tmp7 = id;
2026-07-29 08:29:29 +00:00
let user = authStore.getUser(id);
let obj = user;
if (null != user) {
2026-08-07 06:50:47 +00:00
let tmp9 = user;
2026-07-29 08:29:29 +00:00
if (!obj.isProvisional) {
2026-08-07 06:50:47 +00:00
let tmp10 = user;
2026-07-29 08:29:29 +00:00
if (!obj.bot) {
obj = { user: null, comparator: null };
2026-08-07 06:50:47 +00:00
let tmp13 = user;
2026-07-29 08:29:29 +00:00
obj[0] = obj;
2026-08-07 06:50:47 +00:00
let tmp14 = comparator;
2026-07-29 08:29:29 +00:00
obj[1] = comparator;
2026-08-07 06:50:47 +00:00
let arr = items.push(obj);
2026-07-29 08:29:29 +00:00
} else {
2026-08-07 06:50:47 +00:00
let tmp11 = user;
2026-07-29 08:29:29 +00:00
if (obj.isStaff()) {
2026-08-07 06:50:47 +00:00
let isStaffResult;
2026-07-29 08:29:29 +00:00
if (currentUser != null) {
2026-08-07 06:50:47 +00:00
isStaffResult = currentUser.isStaff();
2026-07-20 16:05:17 +00:00
}
}
}
}
}
2026-07-29 08:29:29 +00:00
} else {
2026-08-07 06:50:47 +00:00
let tmp5 = id;
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
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;
2026-08-07 06:50:47 +00:00
let closure_19 = store.getFriendCount() > 0;
2026-07-29 08:29:29 +00:00
if (null != userSearchContext) {
userSearchContext.destroy();
userSearchContext = null;
}
2026-08-15 05:55:55 +00:00
userSearchContext = importDefault(7597).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-08-07 06:50:47 +00:00
return false;
2026-07-20 16:05:17 +00:00
}
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() {
2026-08-11 06:20:06 +00:00
this.waitFor(ensureGuildLoaded, hasConsented, getHash, handleChannelSelect, trackCommunicationDisabled, createGuildRecordFromRust, markAllUserIdListsStale, recomputeAffinities, mergeGuildAvatar);
2026-07-29 08:29:29 +00:00
const items = [mergeGuildAvatar, ensureGuildLoaded];
this.syncWith(items, performQuery);
const items1 = [recomputeAffinities];
this.syncWith(items1, performQueryOnAffinityChange);
2026-08-11 06:20:06 +00:00
const items2 = [markAllUserIdListsStale];
2026-07-29 08:29:29 +00:00
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-08-07 06:50:47 +00:00
return false;
2026-07-20 16:05:17 +00:00
},
2026-08-07 06:50:47 +00:00
GUILD_MEMBERS_REQUEST: function handleGuildMembersRequest(arg0) {
return false;
2026-07-20 16:05:17 +00:00
},
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;
2026-08-07 06:50:47 +00:00
let closure_19 = store.getFriendCount() > 0;
2026-07-29 08:29:29 +00:00
if (null != userSearchContext) {
userSearchContext.destroy();
userSearchContext = null;
}
2026-08-15 05:55:55 +00:00
userSearchContext = importDefault(7597).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;