mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-31 22:43:11 +02:00
Backspace to delete selected in sidebar
This commit is contained in:
@@ -2,13 +2,13 @@ import { useDeleteAnyGrpcRequest } from './useDeleteAnyGrpcRequest';
|
||||
import { useDeleteAnyHttpRequest } from './useDeleteAnyHttpRequest';
|
||||
import { useFastMutation } from './useFastMutation';
|
||||
|
||||
export function useDeleteRequest(id: string | null) {
|
||||
export function useDeleteAnyRequest() {
|
||||
const deleteAnyHttpRequest = useDeleteAnyHttpRequest();
|
||||
const deleteAnyGrpcRequest = useDeleteAnyGrpcRequest();
|
||||
|
||||
return useFastMutation<void, string>({
|
||||
mutationKey: ['delete_request', id],
|
||||
mutationFn: async () => {
|
||||
return useFastMutation<void, string, string>({
|
||||
mutationKey: ['delete_request'],
|
||||
mutationFn: async (id) => {
|
||||
if (id == null) return;
|
||||
// We don't know what type it is based on the ID, so just try deleting both
|
||||
deleteAnyHttpRequest.mutate(id);
|
||||
@@ -15,6 +15,7 @@ export type HotkeyAction =
|
||||
| 'grpc_request.send'
|
||||
| 'hotkeys.showHelp'
|
||||
| 'http_request.create'
|
||||
| 'http_request.delete'
|
||||
| 'http_request.duplicate'
|
||||
| 'http_request.send'
|
||||
| 'request_switcher.next'
|
||||
@@ -34,6 +35,7 @@ const hotkeys: Record<HotkeyAction, string[]> = {
|
||||
'grpc_request.send': ['CmdCtrl+Enter', 'CmdCtrl+r'],
|
||||
'hotkeys.showHelp': ['CmdCtrl+Shift+/'],
|
||||
'http_request.create': ['CmdCtrl+n'],
|
||||
'http_request.delete': ['Backspace'],
|
||||
'http_request.duplicate': ['CmdCtrl+d'],
|
||||
'http_request.send': ['CmdCtrl+Enter', 'CmdCtrl+r'],
|
||||
'request_switcher.next': ['Control+Shift+Tab'],
|
||||
@@ -54,6 +56,7 @@ const hotkeyLabels: Record<HotkeyAction, string> = {
|
||||
'grpc_request.send': 'Send Message',
|
||||
'hotkeys.showHelp': 'Show Keyboard Shortcuts',
|
||||
'http_request.create': 'New Request',
|
||||
'http_request.delete': 'Delete Request',
|
||||
'http_request.duplicate': 'Duplicate Request',
|
||||
'http_request.send': 'Send Request',
|
||||
'request_switcher.next': 'Go To Previous Request',
|
||||
@@ -95,8 +98,8 @@ export function useHotKey(
|
||||
}
|
||||
|
||||
// Don't add key if not holding modifier
|
||||
const isHoldingModifier = e.altKey || e.ctrlKey || e.metaKey || e.shiftKey;
|
||||
if (!isHoldingModifier) {
|
||||
const isValidKeymapKey = e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || e.key === 'Backspace';
|
||||
if (!isValidKeymapKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -189,6 +192,8 @@ export function useFormattedHotkey(action: HotkeyAction | null): string[] | null
|
||||
labelParts.push('↩');
|
||||
} else if (p === 'Tab') {
|
||||
labelParts.push('⇥');
|
||||
} else if (p === 'Backspace') {
|
||||
labelParts.push('⌫');
|
||||
} else {
|
||||
labelParts.push(capitalize(p));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user