Add group scenario override

This commit is contained in:
SillyLossy
2023-05-05 19:45:59 +03:00
parent 99b2f499d3
commit cae2a6ed71
4 changed files with 48 additions and 4 deletions

View File

@@ -449,11 +449,11 @@ async function generateGroupWrapper(by_auto_mode, type = null, force_chid = null
const resolveOriginal = params.resolve;
const rejectOriginal = params.reject;
params.resolve = function() {
params.resolve = function () {
isQuietGenDone = true;
resolveOriginal.apply(this, arguments);
};
params.reject = function() {
params.reject = function () {
isQuietGenDone = true;
rejectOriginal.apply(this, arguments);
}
@@ -909,9 +909,11 @@ function select_group_chats(groupId, skipAnimation) {
if (groupId) {
$("#rm_group_submit").hide();
$("#rm_group_delete").show();
$("#rm_group_scenario").show();
} else {
$("#rm_group_submit").show();
$("#rm_group_delete").hide();
$("#rm_group_scenario").hide();
}
$("#rm_group_delete").off();
@@ -1264,11 +1266,35 @@ export async function saveGroupBookmarkChat(groupId, name, metadata) {
});
}
function setGroupScenario() {
if (!selected_group) {
return;
}
const template = $('#group_scenario_template .group_scenario').clone();
const metadataValue = chat_metadata['scenario'] || '';
template.find('.group_chat_scenario').text(metadataValue);
callPopup(template.get(0).outerHTML, 'text');
}
function onGroupScenarioInput() {
const value = $(this).val();
const metadata = { scenario: value, };
updateChatMetadata(metadata, false);
}
function onGroupScenarioRemoveClick() {
$(this).closest('.group_scenario').find('.group_chat_scenario').val('').trigger('input');
}
jQuery(() => {
$(document).on("click", ".group_select", selectGroup);
$(document).on("input", ".group_chat_scenario", onGroupScenarioInput);
$(document).on("click", ".remove_scenario_override", onGroupScenarioRemoveClick);
$("#rm_group_filter").on("input", filterGroupMembers);
$("#group_fav_filter").on("click", toggleFilterByFavorites);
$("#rm_group_submit").on("click", createGroup);
$("#rm_group_scenario").on("click", setGroupScenario);
$("#rm_group_automode").on("input", function () {
const value = $(this).prop("checked");
is_group_automode_enabled = value;