Add check for enabled module
This commit is contained in:
parent
e4efb3a10a
commit
63ab16161f
|
@ -572,8 +572,7 @@ async function moduleWorker() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const lastMessageChanged = !((lastCharacter === context.characterId || lastCharacter === context.groupId)
|
const lastMessageChanged = !((lastCharacter === context.characterId || lastCharacter === context.groupId) && lastMessage === currentLastMessage.mes);
|
||||||
&& lastMessage === currentLastMessage.mes);
|
|
||||||
|
|
||||||
// check if last message changed
|
// check if last message changed
|
||||||
if (!lastMessageChanged) {
|
if (!lastMessageChanged) {
|
||||||
|
@ -639,6 +638,11 @@ async function moduleWorker() {
|
||||||
* A talkinghead API call is made only when the talking state changes.
|
* A talkinghead API call is made only when the talking state changes.
|
||||||
*/
|
*/
|
||||||
async function updateTalkingState() {
|
async function updateTalkingState() {
|
||||||
|
// Don't bother if talkinghead is disabled or not loaded.
|
||||||
|
if (!isTalkingHeadEnabled() || !modules.includes('talkinghead')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const context = getContext();
|
const context = getContext();
|
||||||
const currentLastMessage = getLastCharacterMessage();
|
const currentLastMessage = getLastCharacterMessage();
|
||||||
|
|
||||||
|
@ -646,33 +650,30 @@ async function updateTalkingState() {
|
||||||
// TODO: Not sure if we need also "&& !context.groupId" here - the classify check in `moduleWorker`
|
// TODO: Not sure if we need also "&& !context.groupId" here - the classify check in `moduleWorker`
|
||||||
// (that similarly checks the streaming processor state) does that for some reason.
|
// (that similarly checks the streaming processor state) does that for some reason.
|
||||||
// Talkinghead isn't currently designed to work with groups.
|
// Talkinghead isn't currently designed to work with groups.
|
||||||
if (isTalkingHeadEnabled()) {
|
const lastMessageChanged = !((lastCharacter === context.characterId || lastCharacter === context.groupId) && lastTalkingStateMessage === currentLastMessage.mes);
|
||||||
const lastMessageChanged = !((lastCharacter === context.characterId || lastCharacter === context.groupId)
|
const url = new URL(getApiUrl());
|
||||||
&& lastTalkingStateMessage === currentLastMessage.mes);
|
let newTalkingState;
|
||||||
const url = new URL(getApiUrl());
|
if (context.streamingProcessor && !context.streamingProcessor.isFinished &&
|
||||||
let newTalkingState;
|
currentLastMessage.mes.length !== 0 && currentLastMessage.mes !== '...' && lastMessageChanged) {
|
||||||
if (context.streamingProcessor && !context.streamingProcessor.isFinished &&
|
url.pathname = '/api/talkinghead/start_talking';
|
||||||
currentLastMessage.mes.length !== 0 && currentLastMessage.mes !== '...' && lastMessageChanged) {
|
newTalkingState = true;
|
||||||
url.pathname = '/api/talkinghead/start_talking';
|
} else {
|
||||||
newTalkingState = true;
|
url.pathname = '/api/talkinghead/stop_talking';
|
||||||
} else {
|
newTalkingState = false;
|
||||||
url.pathname = '/api/talkinghead/stop_talking';
|
}
|
||||||
newTalkingState = false;
|
try {
|
||||||
}
|
// Call the talkinghead API only if the talking state changed.
|
||||||
try {
|
if (newTalkingState !== lastTalkingState) {
|
||||||
// Call the talkinghead API only if the talking state changed.
|
console.debug(`updateTalkingState: calling ${url.pathname}`);
|
||||||
if (newTalkingState !== lastTalkingState) {
|
await doExtrasFetch(url);
|
||||||
console.debug(`updateTalkingState: calling ${url.pathname}`);
|
|
||||||
await doExtrasFetch(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (error) {
|
|
||||||
// it's ok if not supported
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
lastTalkingState = newTalkingState;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (error) {
|
||||||
|
// it's ok if not supported
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
lastTalkingState = newTalkingState;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
// console.log(error);
|
// console.log(error);
|
||||||
|
@ -1573,8 +1574,8 @@ function setExpressionOverrideHtml(forceClear = false) {
|
||||||
setInterval(updateFunction, UPDATE_INTERVAL);
|
setInterval(updateFunction, UPDATE_INTERVAL);
|
||||||
moduleWorker();
|
moduleWorker();
|
||||||
// For setting the talkinghead talking animation on/off quickly enough for realtime use, we need another timer on a shorter schedule.
|
// For setting the talkinghead talking animation on/off quickly enough for realtime use, we need another timer on a shorter schedule.
|
||||||
const wrapper_talkingstate = new ModuleWorkerWrapper(updateTalkingState);
|
const wrapperTalkingState = new ModuleWorkerWrapper(updateTalkingState);
|
||||||
const updateTalkingStateFunction = wrapper_talkingstate.update.bind(wrapper_talkingstate);
|
const updateTalkingStateFunction = wrapperTalkingState.update.bind(wrapperTalkingState);
|
||||||
setInterval(updateTalkingStateFunction, TALKINGCHECK_UPDATE_INTERVAL);
|
setInterval(updateTalkingStateFunction, TALKINGCHECK_UPDATE_INTERVAL);
|
||||||
updateTalkingState();
|
updateTalkingState();
|
||||||
dragElement($('#expression-holder'));
|
dragElement($('#expression-holder'));
|
||||||
|
|
Loading…
Reference in New Issue