Files
discord-decomp/stores/DimensionStore.tsx
T
2026-11-01 12:12:55 +02:00

101 lines
2.5 KiB
TypeScript

// Metro module 4859 (f4860).
import shallowEqual from "../_bundle/shallowEqual";
import Module589 from "../_bundle/Module589";
import Dispatcher from "../Dispatcher";
let c2992_2 = {};
let c2992_3 = {};
let c2992_4 = {
scrollTop: 0
};
class DimensionStore extends Module589.Store {
static displayName = "DimensionStore";
percentageScrolled(a0) {
if (c2992_2[a0] != null) {
const r6 = c2992_2[a0];
return r6.scrollTop / r6.scrollHeight;
}
return 1;
}
getChannelDimensions(a0) {
return c2992_2[a0];
}
getGuildDimensions(a0) {
let r5 = c2992_3[a0];
if (r5 == null) {
r5 = {
guildId: a0,
scrollTop: null,
scrollTo: null
};
}
return r5;
}
getGuildListDimensions() {
return c2992_4;
}
isAtBottom(a0) {
const r1 = c2992_2[a0] != null;
let r6 = void 0;
if (r1) {
const r7 = c2992_2[a0];
r6 = r7.scrollTop === r7.scrollHeight - r7.offsetHeight;
}
return r6;
}
}
const dimensionStore = new DimensionStore(Dispatcher, {
UPDATE_CHANNEL_DIMENSIONS: function handleChannelScroll({ channelId, scrollTop, scrollHeight, offsetHeight }) {
const r4 = c2992_2[channelId];
if (scrollTop != null && (scrollHeight != null && offsetHeight != null)) {
const r5 = {
channelId,
scrollTop,
scrollHeight,
offsetHeight
};
if (r4 != null && shallowEqual(r4, r5)) {
return false;
}
c2992_2[channelId] = r5;
} else {
if (r4 == null) {
return false;
}
delete c2992_2[channelId];
}
},
UPDATE_CHANNEL_LIST_DIMENSIONS: function handleGuildUpdate({ guildId, scrollTop, scrollTo }) {
if (c2992_3[guildId] == null) {
c2992_3[guildId] = {
guildId,
scrollTop: null,
scrollTo: null
};
}
if (scrollTop !== void 0) {
c2992_3[guildId].scrollTop = scrollTop;
}
let r1 = false;
if (scrollTo !== void 0) {
r1 = c2992_3[guildId].scrollTo !== scrollTo;
c2992_3[guildId].scrollTo = scrollTo;
}
return scrollTo != null || r1;
},
UPDATE_GUILD_LIST_DIMENSIONS: function handleGuildListUpdate(a0) {
c2992_4.scrollTop = a0.scrollTop;
},
CALL_CREATE: function handleCallCreate({ channelId }) {
const r2 = c2992_2[channelId] != null;
let r0 = void 0;
if (r2) {
const r11 = c2992_2[channelId];
r0 = r11.scrollTop === r11.scrollHeight - r11.offsetHeight;
}
if (r0) {
delete c2992_2[channelId];
}
}
});
export default dimensionStore;