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(filters): use quick access, fix weird virtual scroll (#1854)

Seamus498ff680320e
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-controls.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-controls.tsx
index 1f0ea0ba49..a69b9f57e4 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-controls.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-controls.tsx
@@ -8,7 +8,7 @@ import { createMemo, Show } from 'solid-js';
import { VIEW_TAB_PRESETS } from '@app/component/app-sidebar/soup-filter-presets';
import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
import { UserIcon } from '@core/component/UserIcon';
-import { useContacts } from '@queries/contacts/contacts';
+import { filterMap } from '@core/util/list';
import { useUserId } from '@core/context/user';
import { NO_ASSIGNEE } from '@app/component/next-soup/soup-view/task-sub-filter-matcher';
import { PropertyValueIcon } from '@core/component/Properties/component/propertyValue/PropertyValueIcon';
@@ -30,32 +30,54 @@ import {
type Option,
} from './filter-primitives';
import { useFilterOptions } from './use-filter-options';
+import { useQuickAccess } from '@core/context/quickAccess';
export const AssigneeFilter = () => {
const { assigneeFilter, setAssigneeFilter } = useSoupView();
- const contacts = useContacts();
+ const { useList } = useQuickAccess();
+ const contacts = useList('person');
const userId = useUserId();
const assigneeOptions = createMemo((): Option[] => {
const currentUserId = userId();
+
const noAssigneeOption: Option = {
value: NO_ASSIGNEE,
label: 'No Assignee',
icon: () => <CircleDashedIcon class="size-4 text-ink-muted" />,
};
- const contactOptions = contacts().map((contact) => ({
- value: contact.id,
- label:
- contact.id === currentUserId
- ? contact.name
- ? `${contact.name} (me)`
- : 'Me'
- : contact.name || contact.id,
- icon: () => (
- <UserIcon id={contact.id} size="xs" suppressClick showTooltip={false} />
- ),
- }));
- return [noAssigneeOption, ...contactOptions];
+
+ let me: Option | undefined;
+
+ const otherContactOptions = filterMap(
+ contacts(),
+ (contact): Option | undefined => {
+ const opt: Option = {
+ value: contact.id,
+ label:
+ contact.id === currentUserId
+ ? `${contact.data.name || 'Me'} (me)`
+ : contact.data.name || contact.id,
+ icon: () => (
+ <UserIcon
+ id={contact.id}
+ size="xs"
+ suppressClick
+ showTooltip={false}
+ />
+ ),
+ };
+
+ if (contact.id === currentUserId) {
+ me = opt;
+ return undefined;
+ }
+
+ return opt;
+ }
+ );
+
+ return [noAssigneeOption, ...(me ? [me] : []), ...otherContactOptions];
});
const activeAssignee = createMemo((): Option[] => {
@@ -490,16 +512,27 @@ export const FoldersFilter = () => {
export const FromSenderFilter = () => {
const { setQueryFilters, queryFilters } = useSoupView();
- const contacts = useContacts();
+ const { useList } = useQuickAccess();
+ const contacts = useList('person');
const senderOptions = createMemo((): Option[] => {
- return contacts().map((contact) => ({
- value: contact.email ?? contact.id,
- label: contact.name || contact.email || contact.id,
- icon: () => (
- <UserIcon id={contact.id} size="xs" suppressClick showTooltip={false} />
- ),
- }));
+ return filterMap(contacts(), (contact): Option | undefined => {
+ const value = contact.data.email ?? contact.id;
+ if (!value) return undefined;
+
+ return {
+ value,
+ label: contact.data.name || contact.data.email || contact.id,
+ icon: () => (
+ <UserIcon
+ id={contact.id}
+ size="xs"
+ suppressClick
+ showTooltip={false}
+ />
+ ),
+ };
+ });
});
const activeSenderFilter = createMemo((): Option[] => {
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-primitives.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-primitives.tsx
index 9c91cbeaf1..fbe4b79342 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-primitives.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-primitives.tsx
@@ -33,9 +33,9 @@ export const FilterSelect = (props: FilterSelectProps) => {
const renderItem = (itemProps: { item: CollectionNode<Option> }) => (
<KSelect.Item
item={itemProps.item}
- class="w-full flex items-center gap-2.5 p-2 rounded-xs text-left text-xs transition-colors hover:bg-ink/5 group"
+ class="w-full flex items-center gap-2.5 p-2 rounded-xs text-left text-xs hover:bg-ink/5 group"
>
- <span class="size-4 flex items-center justify-center shrink-0 rounded-xs border border-edge-muted transition-colors group-data-[selected]:bg-accent group-data-[selected]:border-accent">
+ <span class="size-4 flex items-center justify-center shrink-0 rounded-xs border border-edge-muted group-data-[selected]:bg-accent group-data-[selected]:border-accent">
<KSelect.ItemIndicator>
<CheckIcon class="size-2.5 text-page" />
</KSelect.ItemIndicator>
@@ -130,9 +130,9 @@ const COMBOBOX_ITEM_HEIGHT = 36;
const ComboboxItem = (itemProps: { item: CollectionNode<Option> }) => (
<Combobox.Item
item={itemProps.item}
- class="w-full flex items-center gap-2.5 px-3 py-2 rounded-xs text-left text-xs transition-colors hover:bg-ink/5 data-[highlighted]:bg-ink/5 group"
+ class="w-full flex items-center gap-2.5 px-3 py-2 rounded-xs text-left text-xs data-[highlighted]:bg-ink/5 group"
>
- <span class="size-4 flex items-center justify-center shrink-0 rounded-xs border border-edge transition-colors group-data-[selected]:bg-accent group-data-[selected]:border-accent">
+ <span class="size-4 flex items-center justify-center shrink-0 rounded-xs border border-edge group-data-[selected]:bg-accent group-data-[selected]:border-accent">
<Combobox.ItemIndicator>
<CheckIcon class="size-2.5 text-page" />
</Combobox.ItemIndicator>
@@ -167,7 +167,7 @@ const VirtualizedListbox = (props: VirtualizedListboxProps) => {
scrollToItem={(key) => {
const index = props.options.findIndex((opt) => opt.value === key);
if (index !== -1) {
- virtualizerHandle?.scrollToIndex(index);
+ virtualizerHandle?.scrollToIndex(index, { align: 'nearest' });
}
}}
class="max-h-[200px] overflow-y-auto"
@@ -330,7 +330,7 @@ export const FilterCombobox = (props: FilterComboboxProps) => {
<Button
variant="ghost"
size="sm"
- class="ml-auto rounded-xs"
+ class="ml-auto rounded-xs w-full"
onClick={() => props.onChange([])}
>
Clear