ServerDrawer: transparent quest dock and full rail collapse

This commit is contained in:
Rosie Val 2026-08-07 01:16:03 -04:00
parent 885718b057
commit af130f158e
3 changed files with 39 additions and 15 deletions

View file

@ -182,25 +182,22 @@ interface TypeDetector { justFired?: boolean }
* Returns the collapse depth a parent element should inherit from its children, or 0 for "leave
* this element alone."
*
* Only collapses a parent that has this element as its *only* child. That guard is the whole
* safety story here: a wrapper whose sole content is the server rail is, by definition, only there
* to size and position the rail, so zeroing it is correct. A container that also holds the channel
* list or the rest of the guilds screen has other children, propagation stops there, and the rest
* of the UI is untouched.
* Returns the *maximum* collapse budget among real children. Previously this guarded against parents
* with multiple children, but the live GuildsBar rail has sibling wrappers (avatar/dm tile) inside
* the same outer container - the rail itself needs to be zeroed out too, and the replaced GuildsBar
* child is the only collapsed one.
*/
function inheritedCollapseDepth(props: any): number {
const children = props?.children;
if (children == null) return 0;
if (Array.isArray(children)) {
let only: any = null;
let deepest = 0;
for (const child of children) {
if (child == null || child === false) continue;
if (only) return 0; // more than one real child - not a rail-only wrapper
only = child;
if (child == null || child === false || typeof child !== "object") continue;
deepest = Math.max(deepest, collapseMarks.get(child) ?? 0);
}
if (!only) return 0;
return (typeof only === "object" ? collapseMarks.get(only) : 0) ?? 0;
return deepest;
}
if (typeof children !== "object") return 0;
@ -215,7 +212,7 @@ function resolveReplacement(type: any, props: any): { type: any; props: any; col
if (effectiveProps) {
for (const { predicate, transform } of propsTransforms) {
try {
if (predicate(effectiveProps)) {
if (predicate(effectiveProps, type)) {
effectiveProps = transform(effectiveProps);
}
} catch {
@ -227,7 +224,7 @@ function resolveReplacement(type: any, props: any): { type: any; props: any; col
if (effectiveProps) {
for (const { predicate, replacement } of propsIntercepts) {
try {
if (predicate(effectiveProps)) {
if (predicate(effectiveProps, type)) {
return replacement ? { type: replacement, props: effectiveProps } : null;
}
} catch {

View file

@ -1,7 +1,7 @@
import { React } from "@vendetta/metro/common";
import { rawFind } from "../lib/rawFind";
import ServerDrawerSheet from "../components/ServerDrawerSheet";
import { registerIntercept, registerTypeDetector } from "../lib/createElementIntercept";
import { registerIntercept, registerPropsTransform, registerTypeDetector } from "../lib/createElementIntercept";
const TAG = "[ServerDrawer]";
@ -24,6 +24,19 @@ function isNamed(name: string) {
type?.type?.name === name || type?.type?.displayName === name;
}
const QUEST_DOCK_NAMES = [
"QuestDock",
"QuestDockBase",
"QuestDockWithQuestContext",
"QuestDockMain",
"QuestDockContent",
"QuestDockExpanded",
];
function isQuestDock(type: any): boolean {
return QUEST_DOCK_NAMES.some((name) => isNamed(name)(type));
}
function ServerDrawerSheetWrapper() {
return <ServerDrawerSheet gestureContext={getGestureContext()} />;
}
@ -45,6 +58,20 @@ function ServerDrawerSheetWrapper() {
* when the race is won, and still shows correctly even when it's lost.
*/
export function patchExpanded(cleanups: (() => void)[]): boolean {
const questDockTypes = new Set<any>();
// Make the quest dock's wrapper(s) transparent - the ServerDrawerSheet content still renders on
// top, but the panel/drawer background that used to be behind the quest menu is removed.
registerPropsTransform(
(_props: any, type: any) => questDockTypes.has(type),
(props: any) => ({ ...props, style: [props?.style, { backgroundColor: "transparent" }] }),
);
registerTypeDetector("ServerDrawer.QuestDockBg", isQuestDock, (real) => {
questDockTypes.add(real);
console.log(TAG, "PATCH: QuestDock wrapper set transparent", real?.name ?? real?.displayName);
}, { persistent: true });
registerTypeDetector("ServerDrawer.Expanded", isNamed("QuestDockContentExpanded"), (real) => {
registerIntercept(real, ServerDrawerSheetWrapper);
console.log(TAG, "PATCH: QuestDockContentExpanded replaced (type detector)");

View file

@ -69,7 +69,7 @@ export function patchHideGuildsBar(cleanups: (() => void)[]): boolean {
registerTypeDetector("ServerDrawer.HideGuildsBar", isGuildsBar, (realGuildsBar) => {
// Ask createElementIntercept to collapse a few ancestor levels as well so wrapper
// containers around the rail don't leave a leftover gap.
registerIntercept(realGuildsBar, Nothing, undefined, { collapseAncestors: 3 });
registerIntercept(realGuildsBar, Nothing, undefined, { collapseAncestors: 6 });
console.log(TAG, "PATCH: found a real GuildsBar reference, now rendering nothing");
}, { persistent: true });
cleanups.push(() => {