Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

fix(settings): hide the account row again when a later availability check fails

ARAYN70114cc80937fedc
diff --git a/src/components/AccountMenu.sheet.test.ts b/src/components/AccountMenu.sheet.test.ts
index 5ca257ceb3..3913679539 100644
--- a/src/components/AccountMenu.sheet.test.ts
+++ b/src/components/AccountMenu.sheet.test.ts
@@ -52,3 +52,12 @@ it("stays hidden when asking fails, and never asks when it is not wanted or the
render(); f.effects[0]!(); await flush(); render();
expect(result).toBe(false);
});
+
+it("hides the row again when a later check fails after an earlier yes", async () => {
+ const offered = vi.fn().mockResolvedValueOnce(true).mockRejectedValueOnce(new Error("no"));
+ vi.stubGlobal("window", { ogb: { accountSheet: { offered, open: vi.fn() } } });
+ render(); f.effects[0]!(); await flush(); render();
+ expect(result).toBe(true);
+ f.effects[0]!(); await flush(); render();
+ expect(result).toBe(false);
+});
diff --git a/src/components/AccountMenu.tsx b/src/components/AccountMenu.tsx
index cc06b5ef4a..72e88a69eb 100644
--- a/src/components/AccountMenu.tsx
+++ b/src/components/AccountMenu.tsx
@@ -39,7 +39,7 @@ export function useSheetOffered(enabled = true): boolean {
useEffect(() => {
if (!enabled || !remote) return;
let alive = true;
- void remote.offered().then((yes) => { if (alive) setOffered(yes === true); }).catch(() => {});
+ void remote.offered().then((yes) => { if (alive) setOffered(yes === true); }).catch(() => { if (alive) setOffered(false); });
return () => { alive = false; };
}, [enabled, remote]);
return enabled && offered && Boolean(remote);