Skip to content

Commit d80d44a

Browse files
timcheclaude
andauthored
hide account badge in google app window when only one account (#552)
* hide account badge in google app window when only one account https://claude.ai/code/session_016BG78TYNmhifvxirqH41WA * move single-account badge check to google app renderer Use useConfig + skipToken to avoid invoking googleApp.getAccount when only one account exists, instead of gating in the main handler. https://claude.ai/code/session_016BG78TYNmhifvxirqH41WA * pass accountId via search param to google app renderer Replace the googleApp.getAccount IPC with an accountId query string parameter. The renderer reads it with useSearchParams from wouter and looks up the account in useConfig, rendering the badge only when more than one account exists. https://claude.ai/code/session_016BG78TYNmhifvxirqH41WA --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent e711096 commit d80d44a

4 files changed

Lines changed: 17 additions & 12 deletions

File tree

packages/app/google-app.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,14 @@ export class GoogleApp {
260260
...options,
261261
});
262262

263+
const searchParams = new URLSearchParams();
264+
265+
searchParams.set("accountId", this.accountId);
266+
263267
loadRenderer(browserWindow, {
264268
renderer: "google-app",
265269
port: 3002,
270+
searchParams,
266271
});
267272

268273
return browserWindow;

packages/app/ipc.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,6 @@ class Ipc {
184184
selectedAccount.instance.gmail.search(searchQuery);
185185
});
186186

187-
ipc.main.handle("googleApp.getAccount", (event) => {
188-
return GoogleApp.fromWebContents(event.sender).account.config;
189-
});
190-
191187
ipc.main.handle("googleApp.getLoadingState", (event) => {
192188
return GoogleApp.fromWebContents(event.sender).isLoading;
193189
});

packages/renderer-google-app/index.tsx

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
TitlebarPageTitle,
1212
TitlebarRight,
1313
} from "@meru/ui/components/titlebar";
14-
import { useQuery } from "@tanstack/react-query";
14+
import { useConfig } from "@meru/shared/renderer/react-query";
1515
import {
1616
ArrowLeftIcon,
1717
ArrowRightIcon,
@@ -24,6 +24,7 @@ import {
2424
XIcon,
2525
} from "lucide-react";
2626
import { useEffect, useState } from "react";
27+
import { useSearchParams } from "wouter";
2728

2829
function RecentDownloadHistoryButton() {
2930
return (
@@ -120,11 +121,13 @@ function App() {
120121
totalMatches: 0,
121122
});
122123

123-
const { data: account } = useQuery({
124-
queryKey: ["googleApp.account"],
125-
queryFn: () => ipc.main.invoke("googleApp.getAccount"),
126-
staleTime: Number.POSITIVE_INFINITY,
127-
});
124+
const { config } = useConfig();
125+
126+
const [searchParams] = useSearchParams();
127+
128+
const account = config?.accounts.find(
129+
(accountConfig) => accountConfig.id === searchParams.get("accountId"),
130+
);
128131

129132
useEffect(() => {
130133
return ipc.renderer.on("googleApp.navigationStateChanged", (_event, state) => {
@@ -174,7 +177,9 @@ function App() {
174177
</TitlebarIconButton>
175178
<ReloadButton />
176179
</TitlebarButtonGroup>
177-
{account && <AccountBadge label={account.label} color={account.color} />}
180+
{config && config.accounts.length > 1 && account && (
181+
<AccountBadge label={account.label} color={account.color} />
182+
)}
178183
<TitlebarPageTitle>{pageTitle}</TitlebarPageTitle>
179184
</TitlebarLeft>
180185
<TitlebarRight>

packages/shared/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,6 @@ export type IpcMainEvents =
236236
"app.setLoginItemSettings": (settings: Partial<LoginItemSettings>) => void;
237237
"app.getIsDefaultMailtoClient": () => boolean;
238238
"app.setAsDefaultMailtoClient": () => void;
239-
"googleApp.getAccount": () => AccountConfig;
240239
"googleApp.getLoadingState": () => boolean;
241240
};
242241

0 commit comments

Comments
 (0)