Files
discord-decomp/modules/guilds_bar/native/GuildsBarDnDStore.tsx
T
2026-11-01 12:12:55 +02:00

222 lines
6.2 KiB
TypeScript

// Metro module 14941 (f14942).
import { GuildsNodeType } from "../../../stores/SortedGuildStore";
import { createWithEqualityFn } from "../../../_bundle/identity_700";
import { makeMutable } from "../../reanimated/ReanimatedRexport";
import { batchUpdates } from "../../../_bundle/Module705";
import SentryUtils_native from "../../../utils/SentryUtils.native";
import { shallow } from "../../../_bundle/Module3802";
let c10569_4 = {
mode: null,
initialX: 0,
initialY: 0,
absoluteX: 0,
absoluteY: 0
};
let c10569_5 = -1;
const withEqualityFn = createWithEqualityFn((c21471_0, c21471_1) => ({
dragSpecs: void 0,
overSpecs: void 0,
dropSpecs: void 0,
dragRegion: makeMutable({
min: 0,
max: 0
}),
gestureState: makeMutable(c10569_4),
dragDropInProgress: makeMutable(false),
listInsets: makeMutable({
start: 0,
end: 0
}),
scrollPosition: makeMutable(0),
windowSize: 0,
setStateShallow: (a0) => {
const r10 = c21471_1();
let c27867_1 = r10;
for (const key in a0) {
if (r10[key] !== a0[key]) {
batchUpdates(() => c21471_0({
...c27867_1,
...a0
}));
return void 0;
}
}
},
dropStart: (a0) => {
const dropSpecs = a0;
const r17 = c21471_1();
const { dropSpecs: dropSpecs2, gestureState } = r17;
SentryUtils_native.addBreadcrumb({
category: "GuildsBarGesture",
message: "dropStart started",
data: {
newDropSpec: a0,
dropSpecs: dropSpecs2,
gestureState: gestureState.get()
}
});
if (dropSpecs2 != null) {
throw new Error("GuildsBarDnDStore.dropStart: you cannot start a drop while an existing drop is in progress");
}
batchUpdates(() => c21471_0({
dropSpecs,
dragSpecs: void 0,
overSpecs: void 0
}));
clearTimeout(c10569_5);
c10569_5 = setTimeout(() => {
const r4 = gestureState.get();
if (r4.mode === "drag") {
gestureState.set({
...r4,
mode: null
});
}
}, 0);
},
dropComplete: () => {
const r17 = c21471_1();
const { gestureState: gestureState2, dragDropInProgress, dropSpecs: dropSpecs2, dragSpecs } = r17;
SentryUtils_native.addBreadcrumb({
category: "GuildsBarGesture",
message: "dropComplete started",
data: {
gestureState: gestureState2.get(),
dropSpecs: dropSpecs2,
dragSpecs
}
});
if (dropSpecs2 != null) {
batchUpdates(() => c21471_0({
dropSpecs: void 0
}));
clearTimeout(c10569_5);
if (dragSpecs == null) {
dragDropInProgress.set(false);
}
const r36 = gestureState2.get();
if (r36.mode === "drag") {
gestureState2.set({
...r36,
mode: null
});
}
}
}
}));
export default withEqualityFn;
export { c10569_4 as INITIAL_GESTURE_STATE };
export function useItemDragState(c21472_0, c21472_1) {
return withEqualityFn(({ dragSpecs, overSpecs, dropSpecs: dropSpecs2, dragDropInProgress }) => {
if (dragSpecs == null && dropSpecs2 == null) {
return {
isDragTarget: false,
dragState: void 0,
overState: void 0,
itemSize: 0,
dragDropInProgress
};
}
let isDragTarget = !c21472_1;
if (!c21472_1) {
const r13 = dragSpecs == null ? void 0 : dragSpecs.node.id;
isDragTarget = r13 === c21472_0 && overSpecs?.node != null || (dropSpecs2 == null ? void 0 : dropSpecs2.dragNode.id) === c21472_0;
}
let r21 = !c21472_1;
if (!c21472_1) {
const r23 = overSpecs == null ? void 0 : overSpecs.node.id;
r21 = r23 === c21472_0 || (dropSpecs2 == null ? void 0 : dropSpecs2.overNode.id) === c21472_0;
}
const dragState = isDragTarget ? dropSpecs2 == null ? "dragging" : "dropping" : r21 ? dropSpecs2 == null ? "dragging" : "dropping" : void 0;
let overState = void 0;
if (r21) {
let r35 = dropSpecs2?.overState;
if (r35 == null) {
r35 = overSpecs?.state;
}
overState = r35;
}
let itemSize = 0;
if (r21) {
let r40 = dropSpecs2?.itemSize;
if (r40 == null) {
r40 = dragSpecs?.itemSize;
}
if (r40 == null) {
r40 = 0;
}
itemSize = r40;
}
return {
isDragTarget,
dragState,
overState,
itemSize,
dragDropInProgress
};
}, shallow);
}
export function useFolderBGHeightOffset(c21473_0) {
return withEqualityFn((a0) => {
let r1, r27;
const { dragSpecs, overSpecs } = a0;
const r3 = a0.dropSpecs != null;
let r12 = 0;
if (!r3) {
const r13 = overSpecs == null;
r12 = 0;
if (!r13) {
const r14 = dragSpecs == null;
r12 = 0;
if (!r14) {
const state = overSpecs.state;
r12 = 0;
if (state !== "self") {
const type = dragSpecs.node.type;
const GUILD = GuildsNodeType.GUILD;
r12 = 0;
if (type === GUILD) {
L16: {
const parentId = dragSpecs.node.parentId;
if (parentId === c21473_0) {
L15: {
const parentId2 = overSpecs.node.parentId;
r1 = 0;
if (parentId2 !== c21473_0) {
if (overSpecs.node.id === c21473_0) {
const state3 = overSpecs.state;
r1 = 0;
if (state3 === "after") {
break L15;
}
}
r1 = -1 * dragSpecs.itemSize;
}
}
r27 = r1;
} else {
if (overSpecs.node.parentId !== c21473_0) {
const id = overSpecs.node.id;
r27 = 0;
if (id !== c21473_0) {
break L16;
}
const state2 = overSpecs.state;
r27 = 0;
if (state2 !== "after") {
break L16;
}
}
r27 = dragSpecs.itemSize;
}
}
r12 = r27;
}
}
}
}
}
return r12;
});
}