Fix abort group generation
This commit is contained in:
parent
0302686a96
commit
d38a4dc6c1
|
@ -609,6 +609,12 @@ function getGroupChatNames(groupId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
||||||
|
function throwIfAborted() {
|
||||||
|
if (params.signal instanceof AbortSignal && params.signal.aborted) {
|
||||||
|
throw new Error('AbortSignal was fired. Group generation stopped');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (online_status === 'no_connection') {
|
if (online_status === 'no_connection') {
|
||||||
is_group_generating = false;
|
is_group_generating = false;
|
||||||
setSendButtonState(false);
|
setSendButtonState(false);
|
||||||
|
@ -635,6 +641,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
throwIfAborted();
|
||||||
hideSwipeButtons();
|
hideSwipeButtons();
|
||||||
is_group_generating = true;
|
is_group_generating = true;
|
||||||
setCharacterName('');
|
setCharacterName('');
|
||||||
|
@ -664,10 +671,6 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (params.signal instanceof AbortSignal && params.signal.aborted) {
|
|
||||||
throw new Error('Already aborted signal passed. Group generation stopped');
|
|
||||||
}
|
|
||||||
|
|
||||||
const activationStrategy = Number(group.activation_strategy ?? group_activation_strategy.NATURAL);
|
const activationStrategy = Number(group.activation_strategy ?? group_activation_strategy.NATURAL);
|
||||||
const enabledMembers = group.members.filter(x => !group.disabled_members.includes(x));
|
const enabledMembers = group.members.filter(x => !group.disabled_members.includes(x));
|
||||||
let activatedMembers = [];
|
let activatedMembers = [];
|
||||||
|
@ -712,6 +715,7 @@ async function generateGroupWrapper(by_auto_mode, type = null, params = {}) {
|
||||||
|
|
||||||
// now the real generation begins: cycle through every activated character
|
// now the real generation begins: cycle through every activated character
|
||||||
for (const chId of activatedMembers) {
|
for (const chId of activatedMembers) {
|
||||||
|
throwIfAborted();
|
||||||
deactivateSendButtons();
|
deactivateSendButtons();
|
||||||
const generateType = type == 'swipe' || type == 'impersonate' || type == 'quiet' || type == 'continue' ? type : 'group_chat';
|
const generateType = type == 'swipe' || type == 'impersonate' || type == 'quiet' || type == 'continue' ? type : 'group_chat';
|
||||||
setCharacterId(chId);
|
setCharacterId(chId);
|
||||||
|
|
Loading…
Reference in New Issue