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

232 lines
5.3 KiB
TypeScript

// Metro module 12974 (f12975).
import Module38 from "../../_bundle/Module38";
import Module589 from "../../_bundle/Module589";
import { getMainWindowId } from "../../utils/web/WindowIdUtils";
import Dispatcher from "../../Dispatcher";
let windowId = null;
let c8958_4 = new Map();
let c8958_5 = new Set();
class WindowStore extends Module589.Store {
static displayName = "WindowStore";
isFocused(r3 = getMainWindowId()) {
let r10 = c8958_4.get(r3);
const r12 = r3;
if (r10 == null) {
c8958_5.has(r12);
r10 = {
isElementFullscreen: false,
focused: false,
windowSize: {
width: 0,
height: 0
},
visible: false
};
}
return r10.focused;
}
isAppFocused() {
return this.getFocusedWindowId() != null;
}
isVisible(r3 = getMainWindowId()) {
let r10 = c8958_4.get(r3);
const r12 = r3;
if (r10 == null) {
c8958_5.has(r12);
r10 = {
isElementFullscreen: false,
focused: false,
windowSize: {
width: 0,
height: 0
},
visible: false
};
}
return r10.visible;
}
getFocusedWindowId() {
let c20321_0 = null;
c8958_4.forEach((item, index) => {
if (item.focused) {
c20321_0 = index;
}
});
return c20321_0;
}
getLastFocusedWindowId() {
return windowId;
}
isElementFullScreen(r3 = getMainWindowId()) {
let r10 = c8958_4.get(r3);
const r12 = r3;
if (r10 == null) {
c8958_5.has(r12);
r10 = {
isElementFullscreen: false,
focused: false,
windowSize: {
width: 0,
height: 0
},
visible: false
};
}
return r10.isElementFullscreen;
}
windowSize(r3 = getMainWindowId()) {
let r10 = c8958_4.get(r3);
const r12 = r3;
if (r10 == null) {
c8958_5.has(r12);
r10 = {
isElementFullscreen: false,
focused: false,
windowSize: {
width: 0,
height: 0
},
visible: false
};
}
return r10.windowSize;
}
}
const windowStore = new WindowStore(Dispatcher, {
WINDOW_INIT: function handleWindowInit(a0) {
Module38(!c8958_4.has(a0.windowId), "Window initialized multiple times");
const { width, height, isElementFullscreen, focused } = a0;
c8958_4.set(a0.windowId, {
windowSize: {
width,
height
},
isElementFullscreen,
focused,
visible: a0.visible
});
if (focused) {
windowId = a0.windowId;
}
return true;
},
WINDOW_FULLSCREEN_CHANGE: function handleWindowFullscreenChange(a0) {
const windowId2 = a0.windowId;
let r7 = c8958_4.get(windowId2);
if (r7 == null) {
c8958_5.has(windowId2);
r7 = {
isElementFullscreen: false,
focused: false,
windowSize: {
width: 0,
height: 0
},
visible: false
};
}
let r17 = r7.isElementFullscreen !== a0.isElementFullscreen;
if (r17) {
c8958_4.set(a0.windowId, {
...r7,
isElementFullscreen: a0.isElementFullscreen
});
r17 = true;
}
return r17;
},
WINDOW_FOCUS: function handleWindowFocus(a0) {
const windowId2 = a0.windowId;
let r7 = c8958_4.get(windowId2);
if (r7 == null) {
c8958_5.has(windowId2);
r7 = {
isElementFullscreen: false,
focused: false,
windowSize: {
width: 0,
height: 0
},
visible: false
};
}
let r17 = r7.focused !== a0.focused;
if (r17) {
if (a0.focused) {
windowId = a0.windowId;
}
c8958_4.set(a0.windowId, {
...r7,
focused: a0.focused
});
r17 = true;
}
return r17;
},
WINDOW_RESIZED: function handleWindowResize(a0) {
const windowId2 = a0.windowId;
let r6 = c8958_4.get(windowId2);
if (r6 == null) {
c8958_5.has(windowId2);
r6 = {
isElementFullscreen: false,
focused: false,
windowSize: {
width: 0,
height: 0
},
visible: false
};
}
let r19 = r6.windowSize.width !== a0.width || r6.windowSize.height !== a0.height;
if (r19) {
c8958_4.set(a0.windowId, {
...r6,
windowSize: {
width: a0.width,
height: a0.height
}
});
r19 = true;
}
return r19;
},
WINDOW_UNLOAD: function handleWindowUnload(a0) {
c8958_5.add(a0.windowId);
c8958_4.delete(a0.windowId);
if (windowId === a0.windowId) {
windowId = null;
}
return true;
},
WINDOW_VISIBILITY_CHANGE: function handleWindowVisibilityChange(a0) {
const windowId2 = a0.windowId;
let r7 = c8958_4.get(windowId2);
if (r7 == null) {
c8958_5.has(windowId2);
r7 = {
isElementFullscreen: false,
focused: false,
windowSize: {
width: 0,
height: 0
},
visible: false
};
}
let r17 = r7.visible !== a0.visible;
if (r17) {
c8958_4.set(a0.windowId, {
...r7,
visible: a0.visible
});
r17 = true;
}
return r17;
}
});
import("../../utils/AnalyticsUtils").then((result) => {
(0, result.addExtraAnalyticsDecorator)(() => {});
});
export default windowStore;