Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions apps/web/src/hooks/use-global-shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,26 +129,25 @@ export function useGlobalShortcuts({ navigate, isAuthenticated, pathname }: UseG
const isMac = useMemo(() => isMacPlatform(), []);
const onChatRoute = isChatRoute(pathname);

const bindingsRef = useRef(bindings);
bindingsRef.current = bindings;
const bindingMap = useMemo(() => getEffectiveBindingsMap(bindings, isMac), [bindings, isMac]);
const bindingMapRef = useRef(bindingMap);
bindingMapRef.current = bindingMap;

const isAuthenticatedRef = useRef(isAuthenticated);
isAuthenticatedRef.current = isAuthenticated;
const navigateRef = useRef(navigate);
navigateRef.current = navigate;
const onChatRouteRef = useRef(onChatRoute);
onChatRouteRef.current = onChatRoute;
const isMacRef = useRef(isMac);
isMacRef.current = isMac;

useMountEffect(() => {
function onKeyDown(event: KeyboardEvent) {
if (event.defaultPrevented || event.repeat || event.isComposing) return;

const bindingMap = getEffectiveBindingsMap(bindingsRef.current, isMacRef.current);
const currentBinding = eventToBinding(event);
if (!currentBinding) return;

const matched: ShortcutDefinition | undefined = bindingMap.get(currentBinding);
const matched: ShortcutDefinition | undefined = bindingMapRef.current.get(currentBinding);
if (!matched) return;

if (!isAuthenticatedRef.current) return;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/src/stores/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ export function useModels() {
});

const models = cache.models ?? getFallbackModels();
const isLoading = cache.loading;
const isLoading = cache.loading || (cache.models === null && cache.error === null);
const error = cache.error;

const reload = useCallback(async () => {
Expand Down
Loading