Skip to content

Memoized icons in refinery #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open

Memoized icons in refinery #72

wants to merge 6 commits into from

Conversation

lumburovskalina
Copy link
Collaborator

@lumburovskalina lumburovskalina commented May 13, 2025

}, []);

const copyToClipboardFunc = useCallback(
(name: string) => () => copyToClipboard(name),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

returns function pointer on execution

);

const usableAttributesFinal = useMemo(() => usableAttributes.map((attribute) => (
{ ...attribute, onClick: copyToClipboardFunc(attribute.name) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

()=> copyToClipboard(name)

can be used directly imo

Comment on lines +74 to +80
const openFilterAttributesModal = useCallback((embedding: Embedding) => () => {
embedding.onQdrant ? dispatch(setModalStates(ModalEnum.FILTERED_ATTRIBUTES, { embeddingId: embedding.id, open: true, attributeNames: prepareAttributeDataByNames(embedding.filterAttributes), showEditOption: showEditOption })) : null;
}, [showEditOption]);

const embeddingsFinal = useMemo(() => embeddings.map((embedding) => (
{ ...embedding, onIconNotesClick: openFilterAttributesModal(embedding) }
)), [embeddings]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the function pointer isn't replaced when it's changed.

Easier to directly use the logic inside the Memo

Suggested change
const openFilterAttributesModal = useCallback((embedding: Embedding) => () => {
embedding.onQdrant ? dispatch(setModalStates(ModalEnum.FILTERED_ATTRIBUTES, { embeddingId: embedding.id, open: true, attributeNames: prepareAttributeDataByNames(embedding.filterAttributes), showEditOption: showEditOption })) : null;
}, [showEditOption]);
const embeddingsFinal = useMemo(() => embeddings.map((embedding) => (
{ ...embedding, onIconNotesClick: openFilterAttributesModal(embedding) }
)), [embeddings]);
const embeddingsFinal = useMemo(() => embeddings.map((embedding) => (
{ ...embedding, onIconNotesClick: embedding.onQdrant ? dispatch(setModalStates(ModalEnum.FILTERED_ATTRIBUTES, { embeddingId: embedding.id, open: true, attributeNames: prepareAttributeDataByNames(embedding.filterAttributes), showEditOption: showEditOption }) }
)), [embeddings, showEditOption /* or a s ref*/ ]);

not sure i got all the brackets right :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants