From 8d31330d3e7dfaa2b67616fb419fadb1c8b09c77 Mon Sep 17 00:00:00 2001 From: Nuckyz <61953774+Nuckyz@users.noreply.github.com> Date: Sun, 5 May 2024 02:52:41 -0300 Subject: [PATCH] Fix wrongfully logging LazyComponent factory failed --- src/utils/lazy.ts | 6 +++--- src/utils/lazyReact.tsx | 8 +++----- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/src/utils/lazy.ts b/src/utils/lazy.ts index 4a8557d0f..a98e56f45 100644 --- a/src/utils/lazy.ts +++ b/src/utils/lazy.ts @@ -9,16 +9,16 @@ export function makeLazy(factory: () => T, attempts = 5): () => T { let cache: T; const getter = () => { - if (!cache && attempts > tries++) { + if (!cache && attempts > tries) { cache = factory(); - if (!cache && attempts === tries) { + if (!cache && attempts === ++tries) { console.error(`Lazy factory failed:\n\n${factory}`); } } return cache; }; - getter.$$vencordLazyFailed = () => tries >= attempts; + getter.$$vencordLazyFailed = () => tries === attempts; return getter; } diff --git a/src/utils/lazyReact.tsx b/src/utils/lazyReact.tsx index 14654406a..f7f6b0ff0 100644 --- a/src/utils/lazyReact.tsx +++ b/src/utils/lazyReact.tsx @@ -23,15 +23,13 @@ export function LazyComponent(factory: () => React.Compo let Component = (() => { console.error(`LazyComponent factory failed:\n\n${factory}`); - return NoopComponent; - })() as React.ComponentType; + return null; + }) as React.ComponentType; // @ts-ignore if (!get.$$vencordLazyFailed()) { const result = get(); - if (result != null) { - Component = result; - } + if (result != null) Component = result; } return ;