Skip to content
This repository has been archived by the owner on Mar 12, 2024. It is now read-only.

Commit

Permalink
fix: copy bug
Browse files Browse the repository at this point in the history
  • Loading branch information
flytam committed Jan 26, 2024
1 parent f751878 commit f1646cf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 2 additions & 3 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ function App() {
const [activeIndexList, setActiveIndexList] = useState<number[]>([0]);

const doCopy = useMemoizedFn(async (index: number) => {
copyToClipBoard(clipBoardList[index]);
paste();
if (index === 0) {
paste();
return;
}
copyToClipBoard(clipBoardList[index]);
paste();
setTimeout(() => {
clearOne(clipBoardList[index].timestamp!);

Expand Down
5 changes: 4 additions & 1 deletion src/hooks/useClipboardData.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect, useMemo, useState } from "react";
import { useEffect, useMemo, useRef, useState } from "react";
import { useLocalStorageState, useMemoizedFn } from "ahooks";
import {
ClipBoardDataType,
Expand Down Expand Up @@ -28,6 +28,8 @@ export const useClipboardData = ({ filter }: params = {}) => {
);

const [filterText, setFilterText] = useState<string>("");
const filterTextRef = useRef(filterText);
filterTextRef.current = filterText;

useEffect(() => {
const changeFn = async () => {
Expand Down Expand Up @@ -58,6 +60,7 @@ export const useClipboardData = ({ filter }: params = {}) => {
"搜索内容",
true
);
utools.setSubInputValue(filterTextRef.current);
}
};
document.addEventListener("visibilitychange", visibilitychangeCb);
Expand Down

0 comments on commit f1646cf

Please sign in to comment.