-
-
Notifications
You must be signed in to change notification settings - Fork 11
group mutual texts with or without id #95
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: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,18 +17,29 @@ | |
|
|
||
| type Props = { | ||
| node: NodeInfo; | ||
| groupedNodes?: NodeInfo[]; | ||
| duplicatesCount?: number; | ||
| loadedNamespaces: UsedNamespaceModel[] | undefined; | ||
| hasNamespacesEnabled: boolean; | ||
| onRefreshNamespaces?: () => void; | ||
| }; | ||
|
|
||
| export const ListItem = ({ | ||
| node, | ||
| groupedNodes, | ||
| duplicatesCount, | ||
| loadedNamespaces, | ||
| hasNamespacesEnabled, | ||
| onRefreshNamespaces, | ||
| }: Props) => { | ||
| const nodeId = node?.id ?? ""; | ||
| const effectiveNodes = useMemo( | ||
| () => | ||
|
Check failure on line 37 in src/ui/views/Index/ListItem.tsx
|
||
| groupedNodes && groupedNodes.length > 0 | ||
| ? groupedNodes | ||
| : [node], | ||
| [groupedNodes, node] | ||
| ); | ||
|
Comment on lines
+36
to
+42
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoid bulk-rewriting grouped nodes on initial render. With the new grouping in Also applies to: 75-92 🧰 Tools🪛 GitHub Check: Static check 🪲[failure] 37-37: 🤖 Prompt for AI Agents |
||
| const tolgeeConfig = useGlobalState((c) => c.config); | ||
|
|
||
| const prefilledKey = usePrefilledKey( | ||
|
|
@@ -62,15 +73,26 @@ | |
|
|
||
| // Debounced mutation: only update Figma nodes after user stops typing | ||
| useEffect(() => { | ||
| if (!node.connected && debouncedKeyName !== (node.key || "")) { | ||
| const hasConnected = effectiveNodes.some((current) => current.connected); | ||
| if (hasConnected) { | ||
| return; | ||
| } | ||
| const shouldUpdate = effectiveNodes.some( | ||
| (current) => debouncedKeyName !== (current.key || "") | ||
| ); | ||
| if (shouldUpdate) { | ||
| setNodesDataMutation.mutate({ | ||
| nodes: [{ ...node, key: debouncedKeyName, ns: namespace }], | ||
| nodes: effectiveNodes.map((current) => ({ | ||
| ...current, | ||
| key: debouncedKeyName, | ||
| ns: namespace, | ||
| })), | ||
| }); | ||
| } | ||
| }, [debouncedKeyName, namespace, node, node.connected]); | ||
| }, [debouncedKeyName, namespace, effectiveNodes]); | ||
|
|
||
| const handleConnect = (node: NodeInfo) => { | ||
| setRoute("connect", { node }); | ||
| const handleConnect = () => { | ||
| setRoute("connect", { nodes: effectiveNodes }); | ||
| }; | ||
|
|
||
| const namespaces = useMemo( | ||
|
|
@@ -89,25 +111,43 @@ | |
| }; | ||
|
|
||
| useEffect(() => { | ||
| if (!node.connected && keyName && namespace !== node.ns) { | ||
| const hasConnected = effectiveNodes.some((current) => current.connected); | ||
| if (hasConnected || !keyName) { | ||
| return; | ||
| } | ||
| const shouldUpdate = effectiveNodes.some( | ||
| (current) => current.ns !== namespace | ||
| ); | ||
| if (shouldUpdate) { | ||
| setNodesDataMutation.mutate({ | ||
| nodes: [{ ...node, key: keyName, ns: namespace }], | ||
| nodes: effectiveNodes.map((current) => ({ | ||
| ...current, | ||
| key: keyName, | ||
| ns: namespace, | ||
| })), | ||
| }); | ||
| } | ||
| }, [namespace, node.connected]); | ||
| }, [namespace, keyName, effectiveNodes]); | ||
|
|
||
| const handleNsChange = (node: NodeInfo) => (value: string) => { | ||
| const handleNsChange = () => (value: string) => { | ||
| setNamespace(value); | ||
| setNodesDataMutation.mutate({ | ||
| nodes: [{ ...node, key: keyName, ns: value }], | ||
| nodes: effectiveNodes.map((current) => ({ | ||
| ...current, | ||
| key: keyName, | ||
| ns: value, | ||
| })), | ||
| }); | ||
| effectiveNodes.forEach((current) => { | ||
| current.key = keyName; | ||
| current.ns = value; | ||
| }); | ||
|
Comment on lines
+132
to
144
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Don't mutate These objects come from props/selection state. Rewriting 🤖 Prompt for AI Agents |
||
| node.key = keyName; | ||
| node.ns = value; | ||
| }; | ||
|
|
||
| return ( | ||
| <NodeRow | ||
| node={node} | ||
| duplicatesCount={duplicatesCount} | ||
| keyComponent={ | ||
| !node.connected && ( | ||
| <KeyInput value={keyName || ""} onChange={handleKeyChange()} /> | ||
|
|
@@ -119,7 +159,7 @@ | |
| <NamespaceSelect | ||
| value={namespace ?? ""} | ||
| namespaces={namespaces} | ||
| onChange={handleNsChange(node)} | ||
| onChange={handleNsChange()} | ||
| onRefresh={onRefreshNamespaces} | ||
| /> | ||
| ) | ||
|
|
@@ -134,7 +174,7 @@ | |
| ? "Connect to existing key" | ||
| : "Edit key connection" | ||
| } | ||
| onClick={() => handleConnect(node)} | ||
| onClick={handleConnect} | ||
| className={styles.connectButton} | ||
| > | ||
| {node.connected ? ( | ||
|
|
||
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.
Don't group whitespace-distinct texts together.
Using
trim()here makes"Hello"and"Hello "share one row, but the rest of the pipeline still treatscharactersas exact text. That lets bulk edits/connects fan out across nodes that can still conflict on push. Group on the rawcharactersvalue, or normalize whitespace consistently everywhere.🤖 Prompt for AI Agents