Files
discord-decomp/sources/utils/ChannelSortingUtils.tsx
T
2026-07-28 01:06:53 +03:00

507 lines
24 KiB
TypeScript

/* Metro module 15936; source: utils/ChannelSortingUtils.tsx; dependencies: [1383, 661, 11879, 5099, 2] */
import * as FileImportTrackerModule from '../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ConstantsModule from '../Constants.tsx'; /* Metro dependency 661 */
import * as ChannelRecordModule from '../records/ChannelRecord.tsx'; /* Metro dependency 1383 */
function _fun122953(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#122953, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:6, offset: 0x0257bdab, size: 217 bytes, params: 8, frame: 19
const closure = function(a0, a1) {
var r0;
var r1;
r0 = a0 != null && a1 != null;
if (r0) {
r1 = a0 === a1 || isGuildSelectableChannelType(a0) && isGuildSelectableChannelType(a1);
r1 = !r1 ? isGuildVocalChannelType(a0) && isGuildVocalChannelType(a1) : r1;
r0 = r1;
}
return r0;
};
const hoverSameType = function(a0) {
return {referenceId: a0.id, parentId: a0.parent_id};
};
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_4 = (ConstantsModule).ChannelTypes;
(FileImportTrackerModule).fileFinishedImporting('utils/ChannelSortingUtils.tsx');
exports.areTypesInSameSection = closure;
exports.getDropData = getDropData;
exports.getDnDUpdates = getDnDUpdates;
function getFirstChannelOfType(a0, a1, a2, a3) { // fn#122955, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:283, offset: 0x0257bee3, size: 132 bytes, params: 5, frame: 19
var r4;
var length;
var property;
var areTypesInSameSectionBinding;
var channel;
var type;
var value2;
const env0_0 = a1;
const env0_1 = -1;
a3.find(_fun122956);
if (!(env0_1 < 0)) {
var binding = env0_1;
if (binding >= 0) {
length = a3.length;
if (binding < length) {
r4 = binding;
loopExit3: while (true) {
property = a3[r4];
areTypesInSameSectionBinding = areTypesInSameSection;
channel = property.channel;
type = channel.type;
if (areTypesInSameSectionBinding(type, a2)) {
return property;
}
value2 = r4 + a0;
if (value2 >= 0) {
length = a3.length;
if (value2 < length) {
r4 = value2;
continue;
}
break loopExit3;
}
break loopExit3;
}
return null;
}
return null;
}
}
return null;
function _fun122956({channel}, a1) { // fn#122956, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:343, offset: 0x0257bf67, size: 38 bytes, params: 3, frame: 3
return channel.id === require && true;
}
}
function getChannelPosition(a0, a1) { // fn#122957, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:507, offset: 0x0257bf8d, size: 86 bytes, params: 3, frame: 14
const value = a2;
const env0_0 = a0;
const env0_1 = value !== undefined ? value : false;
if (a0 == null) {
return 0;
}
const env0_2 = null;
a1.filter(_fun122958).find(_fun122959);
return env0_2;
function _fun122958({channel}) { // fn#122958, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:593, offset: 0x0257bfe3, size: 65 bytes, params: 2, frame: 15
return env0_0 != null && (env0_1 || areTypesInSameSection(env0_0.type, channel.type));
}
function _fun122959({channel}, a1) { // fn#122959, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:669, offset: 0x0257c024, size: 56 bytes, params: 3, frame: 4
return env0_0 != null && channel.id === env0_0.id && true;
}
}
function getDropData(a0, a1, a2, a3, a4) { // fn#122961, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:918, offset: 0x0257c078, size: 1383 bytes, params: 6, frame: 27
var r6;
var r1;
var id;
var r9;
var r2;
var areTypesInSameSectionBinding;
var channelPosition;
var property;
var getFirstChannelOfTypeBinding;
var firstChannelOfType;
var channel;
var object;
var channelPosition2;
var firstChannelOfTypeBinding;
var isGuildSelectableChannelTypeBinding;
var channelPosition3;
var firstChannelOfType2;
var channelPosition4;
var firstChannelOfTypeBinding2;
var channelPosition5;
var firstChannelOfType3;
const value = null;
if (value == a0) {
return value;
}
if (value == a2) {
return value;
}
let GUILD_CATEGORY = ChannelTypes.GUILD_CATEGORY;
if (a0.type === GUILD_CATEGORY) {
if (a3 === a1) {
r2 = hoverSameType(a2);
} else if (a3 < a1) {
if (a0.type === a2.type) {
r2 = hoverSameType(a2);
} else if (a3 > a1) {
GUILD_CATEGORY = ChannelTypes.GUILD_CATEGORY;
channelPosition5 = getChannelPosition(a2, a4, true);
property = a4[(value != channelPosition5 ? channelPosition5 : 0) + 1];
firstChannelOfType3 = getFirstChannelOfType(-1, a2.id, a0.type, a4);
r2 = value == firstChannelOfType3 || firstChannelOfType3.channel.id === a0.id ? value : value == property ? {referenceId: firstChannelOfType3.channel.id,
parentId: value} : property.channel.type !== GUILD_CATEGORY ? value : {referenceId: firstChannelOfType3.channel.id,
parentId: value};
} else {
r2 = value;
}
} else if (a3 > a1) {
GUILD_CATEGORY = ChannelTypes.GUILD_CATEGORY;
channelPosition5 = getChannelPosition(a2, a4, true);
property = a4[(value != channelPosition5 ? channelPosition5 : 0) + 1];
firstChannelOfType3 = getFirstChannelOfType(-1, a2.id, a0.type, a4);
r2 = value == firstChannelOfType3 || firstChannelOfType3.channel.id === a0.id ? value : value == property ? {referenceId: firstChannelOfType3.channel.id,
parentId: value} : property.channel.type !== GUILD_CATEGORY ? value : {referenceId: firstChannelOfType3.channel.id,
parentId: value};
} else {
r2 = value;
}
r1 = r2;
} else {
areTypesInSameSectionBinding = areTypesInSameSection;
if (areTypesInSameSectionBinding(a0.type, a2.type)) {
r1 = hoverSameType(a2);
} else if (a3 < a1) {
if (a2.type === GUILD_CATEGORY) {
channelPosition4 = getChannelPosition(a2, a4, true);
r9 = value != channelPosition4 ? channelPosition4 : 0;
property = a4[r9 - 1];
getFirstChannelOfTypeBinding = getFirstChannelOfType;
id = a2.id;
firstChannelOfTypeBinding2 = getFirstChannelOfTypeBinding(1, id, a0.type, a4);
if (value == property) {
r9 = {'referenceId': null, 'parentId': null};
} else if (value != firstChannelOfTypeBinding2) {
areTypesInSameSectionBinding = areTypesInSameSection;
channel = property.channel;
if (areTypesInSameSectionBinding(channel.type, a0.type)) {
object = {};
channel = firstChannelOfTypeBinding2.channel;
object.referenceId = channel.id;
channel = property.channel;
object.parentId = channel.parent_id;
r9 = object;
} else if (a0.isGuildVocal()) {
isGuildSelectableChannelTypeBinding = isGuildSelectableChannelType;
channel = property.channel;
if (isGuildSelectableChannelTypeBinding(channel.type)) {
object = {};
channel = firstChannelOfTypeBinding2.channel;
object.referenceId = channel.id;
channel = property.channel;
object.parentId = channel.parent_id;
r9 = object;
} else {
channel = property.channel;
if (channel.isCategory()) {
object = {};
channel = firstChannelOfTypeBinding2.channel;
id = channel.id;
object.referenceId = id;
channel = property.channel;
id = channel.id;
object.parentId = id;
r9 = object;
} else {
r9 = value;
}
}
} else {
channel = property.channel;
if (channel.isCategory()) {
object = {};
channel = firstChannelOfTypeBinding2.channel;
id = channel.id;
object.referenceId = id;
channel = property.channel;
id = channel.id;
object.parentId = id;
r9 = object;
} else {
r9 = value;
}
}
} else {
r9 = value;
}
r6 = r9;
} else {
channelPosition3 = getChannelPosition(a2, a4, true);
r6 = value != channelPosition3 ? channelPosition3 : 0;
property = a4[r6 - 1];
firstChannelOfType2 = getFirstChannelOfType(1, a2.id, a0.type, a4);
r6 = value != property || a0.isGuildVocal() ? isGuildSelectableChannelType(a0.type) && value != firstChannelOfType2 && (isGuildSelectableChannelType(property.channel.type) || property.channel.isCategory()) ? {referenceId: firstChannelOfType2.channel.id,
parentId: a2.parent_id} : value : {referenceId: value != firstChannelOfType2 ? firstChannelOfType2.channel.id : value,
parentId: value};
}
r1 = r6;
} else if (a2.type === GUILD_CATEGORY) {
channelPosition2 = getChannelPosition(a2, a4, true);
property = a4[(value != channelPosition2 ? channelPosition2 : 0) + 1];
getFirstChannelOfTypeBinding = getFirstChannelOfType;
id = a2.id;
firstChannelOfTypeBinding = getFirstChannelOfTypeBinding(-1, id, a0.type, a4);
if (value != firstChannelOfTypeBinding) {
if (value == property) {
object = {};
id = firstChannelOfTypeBinding.channel.id;
object.referenceId = id;
id = a2.id;
object.parentId = id;
r6 = object;
} else {
areTypesInSameSectionBinding = areTypesInSameSection;
channel = property.channel;
if (areTypesInSameSectionBinding(channel.type, a0.type)) {
object = {};
channel = firstChannelOfTypeBinding.channel;
object.referenceId = channel.id;
channel = property.channel;
object.parentId = channel.parent_id;
r6 = object;
} else if (isGuildSelectableChannelType(a0.type)) {
channel = property.channel;
if (channel.isGuildVocal()) {
object = {};
channel = firstChannelOfTypeBinding.channel;
object.referenceId = channel.id;
channel = property.channel;
object.parentId = channel.parent_id;
r6 = object;
} else {
channel = property.channel;
if (channel.isCategory()) {
object = {};
id = firstChannelOfTypeBinding.channel.id;
object.referenceId = id;
id = a2.id;
object.parentId = id;
r6 = object;
} else {
r6 = value;
}
}
} else {
channel = property.channel;
if (channel.isCategory()) {
object = {};
id = firstChannelOfTypeBinding.channel.id;
object.referenceId = id;
id = a2.id;
object.parentId = id;
r6 = object;
} else {
r6 = value;
}
}
}
} else {
r6 = value;
}
r1 = r6;
} else {
channelPosition = getChannelPosition(a2, a4, true);
property = a4[(value != channelPosition ? channelPosition : 0) + 1];
firstChannelOfType = getFirstChannelOfType(-1, a2.id, a0.type, a4);
if (value == firstChannelOfType) {
r1 = value;
} else if (a0.isGuildVocal()) {
if (value == property) {
r1 = {referenceId: firstChannelOfType.channel.id, parentId: a2.parent_id};
} else {
channel = property.channel;
if (channel.isCategory()) {
r1 = {referenceId: firstChannelOfType.channel.id, parentId: a2.parent_id};
} else {
channel = property.channel;
if (channel.isGuildVocal()) {
object = {};
channel = firstChannelOfType.channel;
object.referenceId = channel.id;
channel = property.channel;
object.parentId = channel.parent_id;
r1 = object;
} else {
r1 = a0.isCategory() && (value == property || property.channel.isCategory()) ? {referenceId: firstChannelOfType.channel.id,
parentId: value} : value;
}
}
}
} else {
r1 = a0.isCategory() && (value == property || property.channel.isCategory()) ? {referenceId: firstChannelOfType.channel.id,
parentId: value} : value;
}
}
}
return r1;
}
function getDnDUpdates(a0, a1, a2, a3) { // fn#122962, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:3153, offset: 0x0257c5df, size: 441 bytes, params: 5, frame: 24
var r1;
var value;
var getChannelPositionBinding;
var value3;
var value4;
const env0_0 = a0;
const env0_1 = a2;
const items3 = [];
let items2 = [];
const _categories = a3._categories;
const generateUpdates2 = generateUpdates;
if (a0.isCategory()) {
items2 = [];
arraySpread(items2, _categories, 0, undefined);
value = items2.slice(1);
getChannelPositionBinding = getChannelPosition;
var env0_2 = getChannelPositionBinding(a0, value);
var env0_3 = getChannelPositionBinding(a1, value);
value = generateUpdates2(value);
value.unshift(_categories[0]);
r1 = value;
} else {
r1 = items2;
}
if (isGuildSelectableChannelType(a0.type)) {
value3 = (importDefault(5099) /* metro dependency 5099: getFlattedChannelList */)(r1.length > 0 ? r1 : _categories,
a3, function(a0) {
return isGuildSelectableChannelType(a0.channel.type);
});
getChannelPositionBinding = getChannelPosition;
env0_2 = getChannelPositionBinding(a0, value3);
env0_3 = getChannelPositionBinding(a1, value3);
generateUpdates2(value3);
} else if (a0.isCategory()) {
value3 = (importDefault(5099) /* metro dependency 5099: getFlattedChannelList */)(r1.length > 0 ? r1 : _categories,
a3, _fun122966);
getChannelPositionBinding = getChannelPosition;
env0_2 = getChannelPositionBinding(a0, value3);
env0_3 = getChannelPositionBinding(a1, value3);
generateUpdates2(value3);
}
if (a0.isGuildVocal()) {
value4 = (importDefault(5099) /* metro dependency 5099: getFlattedChannelList */)(r1.length > 0 ? r1 : _categories,
a3, function({channel}) {
return channel.isGuildVocal();
});
getChannelPositionBinding = getChannelPosition;
env0_2 = getChannelPositionBinding(a0, value4);
env0_3 = getChannelPositionBinding(a1, value4);
generateUpdates2(value4);
} else if (a0.isCategory()) {
value4 = (importDefault(5099) /* metro dependency 5099: getFlattedChannelList */)(r1.length > 0 ? r1 : _categories,
a3, _fun122967);
getChannelPositionBinding = getChannelPosition;
env0_2 = getChannelPositionBinding(a0, value4);
env0_3 = getChannelPositionBinding(a1, value4);
generateUpdates2(value4);
}
value = a0.parent_id !== a2;
if (value) {
value = items3.find(_fun122968);
value = value == null;
r1 = value;
} else {
r1 = value;
}
if (r1) {
items3.push({id: a0.id, parent_id: a2});
}
return items3;
function generateUpdates(a0) { // fn#122963, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:3235, owner: getDnDUpdates.generateUpdates, offset: 0x0257c798, size: 246 bytes, params: 2, frame: 19
var environment;
var r0;
var binding;
var binding2;
var binding3;
var items2;
var value7;
var defaultImport;
if (env0_2 == null) {
items2 = [];
arraySpread(items2, a0, 0, a0);
r0 = items2;
} else if (env0_3 == null) {
items2 = [];
arraySpread(items2, a0, 0, a0);
r0 = items2;
} else {
binding = env0_0;
binding2 = env0_2;
binding3 = env0_3;
r0 = binding2 != null && binding3 != null;
r0 = r0 && a0[binding2] != null;
r0 = r0 && a0[binding2].channel === binding;
r0 = r0 && a0[binding3] != null;
if (r0) {
value7 = environment.__proto__;
defaultImport = importDefault(11879) /* metro dependency 11879: DragAndDropUtils */;
r0 = defaultImport.moveItemFromTo(a0, env0_2, env0_3);
} else {
items2 = [];
arraySpread(items2, a0, 0, a0);
r0 = items2;
}
}
binding = env0_4;
const concat = binding.concat;
const defaultImport2 = importDefault(11879) /* metro dependency 11879: DragAndDropUtils */;
env0_4 = Reflect.apply(concat, binding, [defaultImport2.calculatePositionDeltas({oldOrdering: a0, newOrdering: r0,
idGetter: function(a0) {
return a0.channel.id;
}, existingPositionGetter: function(a0) {
return a0.channel.position;
}})]);
return r0;
}
function _fun122966({channel}) { // fn#122966, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:3762, offset: 0x0257c88e, size: 29 bytes, params: 2, frame: 11
return isGuildSelectableChannelType(channel.type);
}
function _fun122968(a0) { // fn#122968, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:4074, offset: 0x0257c8bf, size: 41 bytes, params: 2, frame: 4
var r0;
const value2 = a0.id === env0_0.id;
if (value2) {
a0.parent_id = importDefault;
r0 = true;
} else {
r0 = value2;
}
return r0;
}
}
}
function _fun122967({channel}) { // fn#122967, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:16144:3931, offset: 0x0257c8ab, size: 20 bytes, params: 2, frame: 9
return channel.isGuildVocal();
}
global.__d(_fun122953, 15936, [1383, 661, 11879, 5099,
2]) /* metro module 15936, dependencies: [1383, 661, 11879, 5099, 2] */;