-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: dev
Are you sure you want to change the base?
Conversation
src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx
Outdated
Show resolved
Hide resolved
src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx
Outdated
Show resolved
Hide resolved
src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx
Outdated
Show resolved
Hide resolved
src/components/projects/projectId/attributes/attributeId/AttributeCalculations.tsx
Outdated
Show resolved
Hide resolved
src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx
Outdated
Show resolved
Hide resolved
src/components/projects/projectId/attributes/attributeId/ExecutionContainer.tsx
Outdated
Show resolved
Hide resolved
src/components/projects/projectId/attributes/attributeId/LLMResponsePlayground.tsx
Outdated
Show resolved
Hide resolved
src/components/projects/projectId/settings/embeddings/Embeddings.tsx
Outdated
Show resolved
Hide resolved
src/components/projects/projectId/settings/labeling-tasks/LabelingTasks.tsx
Outdated
Show resolved
Hide resolved
}, []); | ||
|
||
const copyToClipboardFunc = useCallback( | ||
(name: string) => () => copyToClipboard(name), |
There was a problem hiding this comment.
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) } |
There was a problem hiding this comment.
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
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]); |
There was a problem hiding this comment.
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
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
Main PR: https://github.com/code-kern-ai/cognition-ui/pull/125