Fix voice preview not updating when age category changes
- Clear all cached previews for a role when age changes - Clear all cached previews for a role when voice changes - Now preview correctly reflects the selected age speed modifier
This commit is contained in:
@@ -164,27 +164,32 @@ export default function VoiceAssignmentSection({
|
||||
|
||||
const handleVoiceSelect = (roleId: string, voiceId: string) => {
|
||||
onVoiceChange(roleId, voiceId);
|
||||
// Clear cached preview when voice changes
|
||||
const cacheKey = `${roleId}-${voiceId}`;
|
||||
// Clear all cached previews for this role when voice changes
|
||||
setAudioCache(prev => {
|
||||
const newCache = new Map(prev);
|
||||
newCache.delete(cacheKey);
|
||||
// Remove all cache entries that start with this roleId
|
||||
Array.from(newCache.keys()).forEach(key => {
|
||||
if (key.startsWith(`${roleId}-`)) {
|
||||
newCache.delete(key);
|
||||
}
|
||||
});
|
||||
return newCache;
|
||||
});
|
||||
};
|
||||
|
||||
const handleAgeSelect = (roleId: string, age: AgeCategory) => {
|
||||
onAgeChange(roleId, age);
|
||||
// Clear cached preview when age changes
|
||||
const voiceId = voiceAssignments.get(roleId);
|
||||
if (voiceId) {
|
||||
const cacheKey = `${roleId}-${voiceId}`;
|
||||
setAudioCache(prev => {
|
||||
const newCache = new Map(prev);
|
||||
newCache.delete(cacheKey);
|
||||
return newCache;
|
||||
// Clear all cached previews for this role when age changes
|
||||
setAudioCache(prev => {
|
||||
const newCache = new Map(prev);
|
||||
// Remove all cache entries that start with this roleId
|
||||
Array.from(newCache.keys()).forEach(key => {
|
||||
if (key.startsWith(`${roleId}-`)) {
|
||||
newCache.delete(key);
|
||||
}
|
||||
});
|
||||
}
|
||||
return newCache;
|
||||
});
|
||||
};
|
||||
|
||||
const handlePreview = async (roleId: string) => {
|
||||
|
||||
Reference in New Issue
Block a user