Force reinitialize when chat changed
This commit is contained in:
parent
d3a7466929
commit
2a3e71bf6e
|
@ -1,4 +1,4 @@
|
||||||
import { cancelTtsPlay, eventSource, event_types, isStreamingEnabled, name2, saveSettingsDebounced, substituteParams } from '../../../script.js';
|
import { cancelTtsPlay, eventSource, event_types, getCurrentChatId, isStreamingEnabled, name2, saveSettingsDebounced, substituteParams } from '../../../script.js';
|
||||||
import { ModuleWorkerWrapper, doExtrasFetch, extension_settings, getApiUrl, getContext, modules, renderExtensionTemplateAsync } from '../../extensions.js';
|
import { ModuleWorkerWrapper, doExtrasFetch, extension_settings, getApiUrl, getContext, modules, renderExtensionTemplateAsync } from '../../extensions.js';
|
||||||
import { delay, escapeRegex, getBase64Async, getStringHash, onlyUnique } from '../../utils.js';
|
import { delay, escapeRegex, getBase64Async, getStringHash, onlyUnique } from '../../utils.js';
|
||||||
import { EdgeTtsProvider } from './edge.js';
|
import { EdgeTtsProvider } from './edge.js';
|
||||||
|
@ -1022,11 +1022,18 @@ export async function initVoiceMap(unrestricted = false) {
|
||||||
}
|
}
|
||||||
|
|
||||||
currentInitVoiceMapPromise = (async () => {
|
currentInitVoiceMapPromise = (async () => {
|
||||||
|
const initialChatId = getCurrentChatId();
|
||||||
try {
|
try {
|
||||||
await initVoiceMapInternal(unrestricted);
|
await initVoiceMapInternal(unrestricted);
|
||||||
} finally {
|
} finally {
|
||||||
currentInitVoiceMapPromise = null;
|
currentInitVoiceMapPromise = null;
|
||||||
}
|
}
|
||||||
|
const currentChatId = getCurrentChatId();
|
||||||
|
|
||||||
|
if (initialChatId !== currentChatId) {
|
||||||
|
// Chat changed during initialization, reinitialize
|
||||||
|
await initVoiceMap(unrestricted);
|
||||||
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
return currentInitVoiceMapPromise;
|
return currentInitVoiceMapPromise;
|
||||||
|
|
Loading…
Reference in New Issue