fix: BetterFolders, CallTimer, Cloud tab, ChannelTabs (#1055)

* fix betterfolders?

* fix calltimer

* fix cloud tab

* fix channeltabs

* Update index.tsx

---------

Co-authored-by: thororen <78185467+thororen1234@users.noreply.github.com>
This commit is contained in:
creations 2026-05-06 16:53:16 -04:00 • committed by GitHub
parent 56e2e46a8b
commit 520532a08a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 23 additions and 42 deletions

View file

@ -30,6 +30,7 @@ import { Link } from "@components/Link";
import { Notice } from "@components/Notice"; import { Notice } from "@components/Notice";
import { Paragraph } from "@components/Paragraph"; import { Paragraph } from "@components/Paragraph";
import { SettingsTab, wrapTab } from "@components/settings/tabs/BaseTab"; import { SettingsTab, wrapTab } from "@components/settings/tabs/BaseTab";
import { localStorage } from "@utils/localStorage";
import { Margins } from "@utils/margins"; import { Margins } from "@utils/margins";
import { useForceUpdater } from "@utils/react"; import { useForceUpdater } from "@utils/react";
import { findComponentByCodeLazy } from "@webpack"; import { findComponentByCodeLazy } from "@webpack";

View file

@ -39,11 +39,9 @@ function AnimationSettings(): JSX.Element {
{ label: "Active Quests Gradient", value: "quests-active", selected: settings.store.animationQuestsActive } { label: "Active Quests Gradient", value: "quests-active", selected: settings.store.animationQuestsActive }
]; ];
const [currentValue, setCurrentValue] = useState(animationOptions.filter(option => option.selected)); const [currentValue, setCurrentValue] = useState(animationOptions.filter(option => option.selected).map(option => option.value));
function updateSettingsTruthy(enabled: DynamicDropdownSettingOption[]) {
const enabledValues = enabled.map(option => option.value);
function updateSettingsTruthy(enabledValues: string[]) {
animationOptions.forEach(option => { animationOptions.forEach(option => {
option.selected = enabledValues.includes(option.value); option.selected = enabledValues.includes(option.value);
}); });
@ -64,23 +62,24 @@ function AnimationSettings(): JSX.Element {
settings.store.animationResizeHandle = enabledValues.includes("resize-handle"); settings.store.animationResizeHandle = enabledValues.includes("resize-handle");
settings.store.animationQuestsActive = enabledValues.includes("quests-active"); settings.store.animationQuestsActive = enabledValues.includes("quests-active");
setCurrentValue(enabled); setCurrentValue(enabledValues);
} }
function handleChange(values: Array<DynamicDropdownSettingOption | string>) { function handleChange(values: Array<DynamicDropdownSettingOption | string>) {
if (values.length === 0) { const valueStrings = values.map(v => typeof v === "string" ? v : v.value);
updateSettingsTruthy([]); const toggled = valueStrings.length > currentValue.length
? valueStrings.find(v => !currentValue.includes(v))
: currentValue.find(v => !valueStrings.includes(v));
if (toggled == null) {
updateSettingsTruthy(valueStrings);
return; return;
} }
const stringlessValues = values.filter(v => typeof v !== "string") as DynamicDropdownSettingOption[]; if (currentValue.includes(toggled)) {
const selectedOption = values.find(v => typeof v === "string") as string; updateSettingsTruthy(currentValue.filter(v => v !== toggled));
const option = animationOptions.find(option => option.value === selectedOption) as DynamicDropdownSettingOption;
if (option.selected) {
updateSettingsTruthy(stringlessValues.filter(v => v.value !== selectedOption));
} else { } else {
updateSettingsTruthy([...stringlessValues, option]); updateSettingsTruthy([...currentValue, toggled]);
} }
} }

View file

@ -148,40 +148,21 @@ function closeFolders() {
} }
// Nuckyz: Unsure if this should be a general utility or not // Nuckyz: Unsure if this should be a general utility or not
function filterTreeWithTargetNode(children: any, predicate: (node: any) => boolean, visited = new WeakSet<object>(), depth = 0) { function containsTargetNode(children: any, predicate: (node: any) => boolean, visited = new WeakSet<object>(), depth = 0): boolean {
if (children == null) { if (children == null) return false;
return false; if (depth > MAX_TREE_FILTER_DEPTH) return false;
}
if (depth > MAX_TREE_FILTER_DEPTH) {
return false;
}
if (typeof children === "object") { if (typeof children === "object") {
if (visited.has(children)) return false; if (visited.has(children)) return false;
visited.add(children); visited.add(children);
} }
if (!Array.isArray(children)) { if (Array.isArray(children)) {
if (predicate(children)) { return children.some(child => containsTargetNode(child, predicate, visited, depth + 1));
return true;
}
return filterTreeWithTargetNode(children.props?.children, predicate, visited, depth + 1);
} }
let childIsTargetChild = false; if (predicate(children)) return true;
for (let i = 0; i < children.length; i++) { return containsTargetNode(children.props?.children, predicate, visited, depth + 1);
const shouldKeep = filterTreeWithTargetNode(children[i], predicate, visited, depth + 1);
if (shouldKeep) {
childIsTargetChild = true;
continue;
}
children.splice(i--, 1);
}
return childIsTargetChild;
} }
function getNestedFolderMap(): Record<string, string> { function getNestedFolderMap(): Record<string, string> {
@ -853,7 +834,7 @@ export default definePlugin({
} }
try { try {
return filterTreeWithTargetNode(child, child => child?.props?.renderTreeNode != null); return containsTargetNode(child, c => c?.props?.renderTreeNode != null);
} catch { } catch {
return true; return true;
} }

View file

@ -139,7 +139,7 @@ export default definePlugin({
find: "renderConnectionStatus(){", find: "renderConnectionStatus(){",
replacement: { replacement: {
match: /(renderConnectionStatus\(\).{0,1000}?lineClamp:1,children:)(\i)(?=,|}\))/, match: /(renderConnectionStatus\(\).{0,1000}?lineClamp:1,children:)(\i)(?=,|}\))/,
replace: "$1[$2,$self.renderTimer({ channelId: this?.props?.channel?.id })]" replace: "$1[$2,$self.renderConnectionTimer({ channelId: this?.props?.channel?.id })]"
} }
} }
], ],