chore: prevent shortcuts from invoking recording when in shortcut recording state
This commit is contained in:
parent
fd7f4bff49
commit
3f8ea518f6
5 changed files with 60 additions and 2 deletions
|
|
@ -141,14 +141,18 @@ export function ShortcutInput({
|
|||
onRecordingShortcutChange,
|
||||
}: ShortcutInputProps) {
|
||||
const [activeKeys, setActiveKeys] = useState<string[]>([]);
|
||||
const setRecordingStateMutation =
|
||||
api.settings.setShortcutRecordingState.useMutation();
|
||||
|
||||
const handleStartRecording = () => {
|
||||
onRecordingShortcutChange(true);
|
||||
setRecordingStateMutation.mutate(true);
|
||||
};
|
||||
|
||||
const handleCancelRecording = () => {
|
||||
onRecordingShortcutChange(false);
|
||||
setActiveKeys([]);
|
||||
setRecordingStateMutation.mutate(false);
|
||||
};
|
||||
|
||||
// Subscribe to key events when recording
|
||||
|
|
@ -169,6 +173,7 @@ export function ShortcutInput({
|
|||
}
|
||||
|
||||
onRecordingShortcutChange(false);
|
||||
setRecordingStateMutation.mutate(false);
|
||||
}
|
||||
},
|
||||
onError: (error) => {
|
||||
|
|
|
|||
|
|
@ -74,8 +74,14 @@ export class AppManager {
|
|||
// tRPC handler is now set up in WindowManager when windows are created
|
||||
|
||||
if (app.dock) {
|
||||
app.dock.show();
|
||||
logger.main.info("Explicitly showing app in dock");
|
||||
app.dock
|
||||
.show()
|
||||
.then(() => {
|
||||
logger.main.info("Explicitly showing app in dock");
|
||||
})
|
||||
.catch((error) => {
|
||||
logger.main.error("Error showing app in dock", error);
|
||||
});
|
||||
} else {
|
||||
logger.main.warn("app.dock is not available");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,4 +156,11 @@ export const setupApplicationMenu = (
|
|||
|
||||
const menu = Menu.buildFromTemplate(menuTemplate);
|
||||
Menu.setApplicationMenu(menu);
|
||||
|
||||
// Add "Version" prefix on macOS About panel
|
||||
if (process.platform === "darwin") {
|
||||
app.setAboutPanelOptions({
|
||||
applicationVersion: `Version ${app.getVersion()}`,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ export class ShortcutManager extends EventEmitter {
|
|||
};
|
||||
private settingsService: SettingsService;
|
||||
private swiftIOBridge: SwiftIOBridge | null = null;
|
||||
private isRecordingShortcut: boolean = false;
|
||||
|
||||
constructor(settingsService: SettingsService) {
|
||||
super();
|
||||
|
|
@ -52,6 +53,11 @@ export class ShortcutManager extends EventEmitter {
|
|||
await this.loadShortcuts();
|
||||
}
|
||||
|
||||
setIsRecordingShortcut(isRecording: boolean) {
|
||||
this.isRecordingShortcut = isRecording;
|
||||
log.info("Shortcut recording state changed", { isRecording });
|
||||
}
|
||||
|
||||
private setupEventListeners() {
|
||||
if (!this.swiftIOBridge) {
|
||||
log.warn("SwiftIOBridge not available, shortcuts will not work");
|
||||
|
|
@ -139,6 +145,11 @@ export class ShortcutManager extends EventEmitter {
|
|||
}
|
||||
|
||||
private checkShortcuts() {
|
||||
// Skip shortcut detection when recording shortcuts
|
||||
if (this.isRecordingShortcut) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check PTT shortcut
|
||||
const isPTTPressed = this.isPTTShortcutPressed();
|
||||
this.emit("ptt-state-changed", isPTTPressed);
|
||||
|
|
|
|||
|
|
@ -136,6 +136,35 @@ export const settingsRouter = t.router({
|
|||
}
|
||||
}),
|
||||
|
||||
// Set shortcut recording state
|
||||
setShortcutRecordingState: t.procedure
|
||||
.input(z.boolean())
|
||||
.mutation(async ({ input }) => {
|
||||
try {
|
||||
if (!globalThis.shortcutManager) {
|
||||
throw new Error("ShortcutManager not available");
|
||||
}
|
||||
|
||||
globalThis.shortcutManager.setIsRecordingShortcut(input);
|
||||
|
||||
if (globalThis.logger) {
|
||||
globalThis.logger.main.info("Shortcut recording state updated", {
|
||||
isRecording: input,
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
} catch (error) {
|
||||
if (globalThis.logger) {
|
||||
globalThis.logger.main.error(
|
||||
"Error setting shortcut recording state:",
|
||||
error,
|
||||
);
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}),
|
||||
|
||||
// Active keys subscription for shortcut recording
|
||||
activeKeysUpdates: t.procedure.subscription(() => {
|
||||
return observable<string[]>((emit) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue