Skip to content

Commit 746b094

Browse files
committed
feat: add navigation functionality to settings page and update Electron API
1 parent 31838df commit 746b094

4 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/main/main.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,12 @@ ipcMain.handle("clear-history", () => {
319319
}
320320
});
321321

322+
ipcMain.handle("navigate-to", (_event, page: string) => {
323+
if (win) {
324+
win.webContents.send("navigate", page);
325+
}
326+
});
327+
322328
function registerGlobalShortcut(shortcut: string = "CommandOrControl+Shift+V") {
323329
globalShortcut.unregisterAll();
324330

src/main/preload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,5 @@ contextBridge.exposeInMainWorld("electronAPI", {
2323
setOpenAIApiKey: (apiKey: string) =>
2424
ipcRenderer.invoke("set-openai-api-key", apiKey),
2525
clearHistory: () => ipcRenderer.invoke("clear-history"),
26+
navigate: (page: string) => ipcRenderer.invoke("navigate-to", page),
2627
});

src/renderer/pages/ClipboardHistory.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ export default function ClipboardHistory({}: ClipboardHistoryProps) {
110110
searchInputRef.current?.focus();
111111
}
112112
break;
113+
case ",":
114+
if (document.activeElement !== searchInputRef.current) {
115+
e.preventDefault();
116+
window.electronAPI.navigate("settings");
117+
}
118+
break;
113119
}
114120
};
115121

@@ -244,7 +250,7 @@ export default function ClipboardHistory({}: ClipboardHistoryProps) {
244250
)}
245251
</div>
246252
<p className="search-hint">
247-
{hasApiKey && "Press Enter to search • "}↑↓ Navigate • Enter/C to copy{hasApiKey && " • / to search"}
253+
{hasApiKey && "Press Enter to search • "}↑↓ Navigate • Enter/C to copy{hasApiKey && " • / to search"} • , Settings
248254
</p>
249255
</div>
250256
<main className="content">

src/renderer/types.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface ElectronAPI {
1818
setGlobalShortcut: (shortcut: string) => Promise<{ success: boolean; error?: string }>;
1919
setOpenAIApiKey: (apiKey: string) => Promise<{ success: boolean; error?: string }>;
2020
clearHistory: () => Promise<{ success: boolean; error?: string }>;
21+
navigate: (page: string) => Promise<void>;
2122
}
2223

2324
declare global {

0 commit comments

Comments
 (0)