#224 Add a button to force a one-character next reply in groups

This commit is contained in:
SillyLossy
2023-05-04 14:43:05 +03:00
parent ed11a39eb2
commit e4db21ccc9
4 changed files with 37 additions and 16 deletions

View File

@@ -375,7 +375,7 @@ function getGroupAvatar(group) {
}
async function generateGroupWrapper(by_auto_mode, type = null) {
async function generateGroupWrapper(by_auto_mode, type = null, force_chid = null) {
if (online_status === "no_connection") {
is_group_generating = false;
setSendButtonState(false);
@@ -437,7 +437,10 @@ async function generateGroupWrapper(by_auto_mode, type = null) {
const activationStrategy = Number(group.activation_strategy ?? group_activation_strategy.NATURAL);
let activatedMembers = [];
if (type === "swipe") {
if (typeof force_chid == 'number') {
activatedMembers = [force_chid];
}
else if (type === "swipe") {
activatedMembers = activateSwipe(group.members);
if (activatedMembers.length === 0) {
@@ -854,6 +857,10 @@ function select_group_chats(groupId, skipAnimation) {
template.attr("chid", characters.indexOf(character));
template.addClass(character.fav == 'true' ? 'is_fav' : '');
if (!group) {
template.find('[data-action="speak"]').hide();
}
if (
group &&
Array.isArray(group.members) &&
@@ -931,22 +938,29 @@ function select_group_chats(groupId, skipAnimation) {
const action = $(this).data('action');
const member = $(this).closest('.group_member');
if (action == 'remove') {
if (action === 'remove') {
await modifyGroupMember(groupId, member, true);
}
if (action == 'add') {
if (action === 'add') {
await modifyGroupMember(groupId, member, false);
}
if (action == 'up' || action == 'down') {
if (action === 'up' || action === 'down') {
await reorderGroupMember(groupId, member, action);
}
if (action == 'view') {
if (action === 'view') {
openCharacterDefinition(member);
}
if (action === 'speak') {
const chid = Number(member.attr('chid'));
if (Number.isInteger(chid)) {
generateGroupWrapper(false, null, chid);
}
}
sortCharactersList("#rm_group_add_members .group_member");
});
}
@@ -1225,7 +1239,7 @@ export async function saveGroupBookmarkChat(groupId, name, metadata) {
});
}
$(document).ready(() => {
jQuery(() => {
$(document).on("click", ".group_select", selectGroup);
$("#rm_group_filter").on("input", filterGroupMembers);
$("#group_fav_filter").on("click", toggleFilterByFavorites);