Skip to content
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

fix(llm): πŸ› release debounce memo tag changes #8635

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/brown-hats-think.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"live-mobile": minor
---

Debounce memo tag changes
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FC, useCallback, useState } from "react";
import debounce from "lodash/debounce";
import { FC, useCallback, useMemo, useState } from "react";

import { useFeature } from "@ledgerhq/live-common/featureFlags/index";
import { Transaction } from "@ledgerhq/live-common/generated/types";
Expand All @@ -18,14 +19,20 @@ export const useMemoTagInput = (

const [isEmpty, setIsEmpty] = useState(true);
const [error, setError] = useState<Error | undefined>();
const debouncedUpdateTransaction = useMemo(
() => debounce(updateTransaction, DEBOUNCE_DELAY),
[updateTransaction],
);
const handleChange = useCallback<MemoTagInputProps["onChange"]>(
({ patch, value, error }) => {
setIsEmpty(!value);
setError(error);
updateTransaction(patch);
debouncedUpdateTransaction(patch);
},
[updateTransaction],
[debouncedUpdateTransaction],
);

return Input && { Input, isEmpty, error, handleChange };
};

const DEBOUNCE_DELAY = 300;