Skip to content

Commit

Permalink
fix: dont print the same log multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
sebasti810 committed Jan 21, 2025
1 parent 6f317f6 commit 9cfb140
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions src/lib/use-light-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ export const useLightClient = () => {
const latestTargetHeight = useRef(0);

const addLog = useCallback((message: string, type: LogEntry['type'] = 'info') => {
setLogs((prev) => [
...prev,
{
timestamp: new Date().toLocaleTimeString(),
message,
type,
},
]);
setLogs((prev) => {
if (prev.length > 0 && prev[prev.length - 1].message === message) {
return prev;
}
return [
...prev,
{
timestamp: new Date().toLocaleTimeString(),
message,
type,
},
];
});
}, []);

const updateProgress = useCallback(() => {
Expand Down

0 comments on commit 9cfb140

Please sign in to comment.