Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix: attach hotkey to search bar component (#90)

gbirmanf6bf7b926fef
diff --git a/js/app/packages/app/component/Soup.tsx b/js/app/packages/app/component/Soup.tsx
index a4aba3059b..a37688fbec 100644
--- a/js/app/packages/app/component/Soup.tsx
+++ b/js/app/packages/app/component/Soup.tsx
@@ -9,10 +9,7 @@ import { Button } from '@core/component/FormControls/Button';
import { SegmentedControl } from '@core/component/FormControls/SegmentControls';
import { ContextMenuContent, MenuItem } from '@core/component/Menu';
import { fileTypeToBlockName } from '@core/constant/allBlocks';
-import {
- ENABLE_FOLDER_UPLOAD,
- ENABLE_SEARCH_VIEW,
-} from '@core/constant/featureFlags';
+import { ENABLE_FOLDER_UPLOAD } from '@core/constant/featureFlags';
import { fileFolderDrop } from '@core/directive/fileFolderDrop';
import { TOKENS } from '@core/hotkey/tokens';
import {
@@ -44,7 +41,6 @@ import {
For,
Match,
onCleanup,
- onMount,
type ParentComponent,
Show,
Suspense,
@@ -152,30 +148,6 @@ export function Soup() {
const entityQueryClient = useEntityQueryClient();
- onMount(() => {
- if (!ENABLE_SEARCH_VIEW) return;
-
- const { dispose } = registerHotkey({
- hotkey: ['/'],
- scopeId: splitHotkeyScope,
- description: 'Search in current view',
- hotkeyToken: TOKENS.soup.openSearch,
- keyDownHandler: () => {
- setTimeout(() => {
- const searchInput = document.getElementById(
- `search-input-${selectedView()}`
- ) as HTMLInputElement;
- searchInput?.focus();
- }, 0);
- return true;
- },
- displayPriority: 5,
- });
- onCleanup(() => {
- dispose();
- });
- });
-
registerHotkey({
hotkey: ['shift+/'],
scopeId: splitHotkeyScope,
diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsx
index eb09f51d58..e5f99b613e 100644
--- a/js/app/packages/app/component/UnifiedListView.tsx
+++ b/js/app/packages/app/component/UnifiedListView.tsx
@@ -27,6 +27,8 @@ import {
ENABLE_PREVIEW,
ENABLE_SOUP_FROM_FILTER,
} from '@core/constant/featureFlags';
+import { registerHotkey } from '@core/hotkey/hotkeys';
+import { TOKENS } from '@core/hotkey/tokens';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { isMobileWidth } from '@core/mobile/mobileWidth';
import { useCombinedRecipients } from '@core/signal/useCombinedRecipient';
@@ -96,6 +98,8 @@ import {
createSignal,
mergeProps,
on,
+ onCleanup,
+ onMount,
type ParentProps,
type Setter,
Show,
@@ -1453,6 +1457,7 @@ function SearchBar(props: {
isLoading: Accessor<boolean>;
setIsLoading: Setter<boolean>;
}) {
+ const splitContext = useSplitPanelOrThrow();
const {
viewsDataStore,
selectedView,
@@ -1460,7 +1465,7 @@ function SearchBar(props: {
entitiesSignal: [entities],
virtualizerHandleSignal: [virtualizerHandle],
entityListRefSignal: [entityListRef],
- } = useSplitPanelOrThrow().unifiedListContext;
+ } = splitContext.unifiedListContext;
const viewData = createMemo(() => viewsDataStore[selectedView()]);
let inputRef: HTMLInputElement | undefined;
@@ -1541,6 +1546,28 @@ function SearchBar(props: {
return loading;
}, props.isLoading());
+ onMount(() => {
+ const { dispose } = registerHotkey({
+ hotkey: ['/'],
+ scopeId: splitContext.splitHotkeyScope,
+ description: 'Search in current view',
+ hotkeyToken: TOKENS.soup.openSearch,
+ keyDownHandler: () => {
+ setTimeout(() => {
+ const searchInput = document.getElementById(
+ `search-input-${selectedView()}`
+ ) as HTMLInputElement;
+ searchInput?.focus();
+ }, 0);
+ return true;
+ },
+ displayPriority: 5,
+ });
+ onCleanup(() => {
+ dispose();
+ });
+ });
+
return (
<SplitToolbarLeft>
<div class="flex ml-2 h-full items-center gap-1">
diff --git a/js/app/packages/core/constant/featureFlags.ts b/js/app/packages/core/constant/featureFlags.ts
index 5b5b0bd091..519a58fc76 100644
--- a/js/app/packages/core/constant/featureFlags.ts
+++ b/js/app/packages/core/constant/featureFlags.ts
@@ -147,8 +147,6 @@ export const ENABLE_PROPERTIES_METADATA = DEV_MODE_ENV;
export const ENABLE_EMAIL_VIEW = true;
-export const ENABLE_SEARCH_VIEW = true;
-
export const ENABLE_SOUP_FROM_FILTER = DEV_MODE_ENV;
export const ENABLE_PREVIEW = true;
diff --git a/js/app/packages/core/types/view.ts b/js/app/packages/core/types/view.ts
index 286abe81c2..fd6858abb0 100644
--- a/js/app/packages/core/types/view.ts
+++ b/js/app/packages/core/types/view.ts
@@ -1,7 +1,4 @@
-import {
- ENABLE_EMAIL_VIEW,
- ENABLE_SEARCH_VIEW,
-} from 'core/constant/featureFlags';
+import { ENABLE_EMAIL_VIEW } from 'core/constant/featureFlags';
export const DEFAULT_VIEWS = [
'inbox',
@@ -19,7 +16,7 @@ export type ConditionalView = (typeof CONDITIONAL_VIEWS)[number];
export type View = DefaultView | ConditionalView;
const VIEW_DEFINITIONS: Array<{ key: View; disabled?: boolean }> = [
- { key: 'all', disabled: !ENABLE_SEARCH_VIEW },
+ { key: 'all' },
{ key: 'inbox' },
{ key: 'emails', disabled: !ENABLE_EMAIL_VIEW },
{ key: 'comms' },