fix: update save_file method to accept additional keyword arguments; enhance AgentImage component with useEffect for dynamic source updates

This commit is contained in:
Alex
2025-10-06 14:41:51 +01:00
parent 045630b8a5
commit 498e2b772c
2 changed files with 12 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { useState } from 'react';
import { useState, useEffect } from 'react';
import Robot from '../assets/robot.svg';
type AgentImageProps = {
@@ -14,8 +14,16 @@ export default function AgentImage({
className = '',
fallbackSrc = Robot,
}: AgentImageProps) {
const initialSrc = src && src.trim() !== '' ? src : fallbackSrc;
const [currentSrc, setCurrentSrc] = useState(initialSrc);
const [currentSrc, setCurrentSrc] = useState(
src && src.trim() !== '' ? src : fallbackSrc,
);
useEffect(() => {
const newSrc = src && src.trim() !== '' ? src : fallbackSrc;
if (newSrc !== currentSrc) {
setCurrentSrc(newSrc);
}
}, [src, fallbackSrc]);
return (
<img
@@ -30,5 +38,3 @@ export default function AgentImage({
/>
);
}