56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
// Metro module 12632 (f12633).
|
|
import ChannelStore from "../../stores/ChannelStore";
|
|
import { ChannelTypes } from "../../Constants";
|
|
export default function compareChannelsByScoreAndPosition(a0, a1) {
|
|
let r26, r51;
|
|
if (a0.score !== a1.score) {
|
|
return a1.score - a0.score;
|
|
}
|
|
const record = a0.record;
|
|
if (record.parent_id == null) {
|
|
r26 = record.type === ChannelTypes.GUILD_CATEGORY ? 1000 * (record.position + 1) : record.position;
|
|
} else {
|
|
let r18 = ChannelStore.getChannel(record.parent_id)?.position;
|
|
if (r18 == null) {
|
|
r18 = 0;
|
|
}
|
|
const r19 = r18 + 1;
|
|
const isGuildVocal = record.isGuildVocal();
|
|
const r25 = 1000 * r19 + record.position;
|
|
r26 = isGuildVocal ? r25 + 500 : r25;
|
|
}
|
|
const record2 = a1.record;
|
|
if (record2.parent_id == null) {
|
|
r51 = record2.type === ChannelTypes.GUILD_CATEGORY ? 1000 * (record2.position + 1) : record2.position;
|
|
} else {
|
|
let r42 = ChannelStore.getChannel(record2.parent_id)?.position;
|
|
if (r42 == null) {
|
|
r42 = 0;
|
|
}
|
|
const r44 = r42 + 1;
|
|
const isGuildVocal2 = record2.isGuildVocal();
|
|
const r50 = 1000 * r44 + record2.position;
|
|
r51 = isGuildVocal2 ? r50 + 500 : r50;
|
|
}
|
|
if (r26 !== r51) {
|
|
return r26 - r51;
|
|
}
|
|
let sortable = a0.sortable;
|
|
if (sortable == null) {
|
|
const comparator2 = a0.comparator;
|
|
sortable = comparator2 == null ? void 0 : comparator2.toLocaleLowerCase();
|
|
}
|
|
if (sortable == null) {
|
|
sortable = "";
|
|
}
|
|
let sortable2 = a0.sortable;
|
|
if (sortable2 == null) {
|
|
const comparator = a1.comparator;
|
|
sortable2 = comparator == null ? void 0 : comparator.toLocaleLowerCase();
|
|
}
|
|
if (sortable2 == null) {
|
|
sortable2 = "";
|
|
}
|
|
return sortable < sortable2 ? -1 : sortable > sortable2 ? 1 : 0;
|
|
};
|