mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
code clean up, change fav to use bool, use template instead of dynamic html, etc
This commit is contained in:
@ -211,11 +211,11 @@ async function getGroups() {
|
||||
|
||||
function printGroups() {
|
||||
for (let group of groups) {
|
||||
const renderStar = group.fav === "1" ? "<i class='fa-solid fa-star fa-2xs'></i>" : ""
|
||||
const template = $("#group_list_template .group_select").clone();
|
||||
template.data("id", group.id);
|
||||
template.attr("grid", group.id);
|
||||
template.find(".ch_name").html(group.name + " " + renderStar);
|
||||
template.find(".ch_name").html(group.name);
|
||||
group.fav ? template.find(".group_fav_icon").show() : template.find(".group_fav_icon").hide();
|
||||
template.find(".ch_fav").val(group.fav);
|
||||
$("#rm_print_characters_block").prepend(template);
|
||||
updateGroupAvatar(group);
|
||||
@ -754,7 +754,7 @@ function select_group_chats(chat_id, skipAnimation) {
|
||||
const groupHasMembers = !!$("#rm_group_members").children().length;
|
||||
$("#rm_group_submit").prop("disabled", !groupHasMembers);
|
||||
$("#rm_group_allow_self_responses").prop("checked", group && group.allow_self_responses);
|
||||
$("#rm_group_fav").prop("checked", group && group.fav === "1");
|
||||
$("#rm_group_fav").prop("checked", group && group.fav);
|
||||
|
||||
// bottom buttons
|
||||
if (chat_id) {
|
||||
@ -780,11 +780,7 @@ function select_group_chats(chat_id, skipAnimation) {
|
||||
$("#rm_group_fav").on("input", async function(){
|
||||
if (group) {
|
||||
const value = $(this).prop("checked");
|
||||
if(value === true){
|
||||
group.fav = "1";
|
||||
}else{
|
||||
group.fav = "0";
|
||||
}
|
||||
group.fav = value;
|
||||
await editGroup(chat_id);
|
||||
}
|
||||
});
|
||||
@ -845,7 +841,8 @@ $(document).ready(() => {
|
||||
chat.length = 0;
|
||||
await getGroupChat(id);
|
||||
//to avoid the filter being lit up yellow and left at true while the list of character and group reseted.
|
||||
$("#filter_by_fav").css("color","#ffffff");
|
||||
$("#filter_by_fav").removeClass("fav_on");
|
||||
$("#filter_by_fav").addClass("fav_off");
|
||||
filterByFav = false;
|
||||
}
|
||||
|
||||
@ -870,8 +867,7 @@ $(document).ready(() => {
|
||||
$("#rm_group_submit").click(async function () {
|
||||
let name = $("#rm_group_chat_name").val();
|
||||
let allow_self_responses = !!$("#rm_group_allow_self_responses").prop("checked");
|
||||
let fav = !!$("#rm_group_fav").prop("checked");
|
||||
fav === true ? fav ="1" : fav = "0"
|
||||
let fav = $("#rm_group_fav").prop("checked");
|
||||
let activation_strategy = $('input[name="rm_group_activation_strategy"]:checked').val() ?? group_activation_strategy.NATURAL;
|
||||
const members = $("#rm_group_members .group_member")
|
||||
.map((_, x) => $(x).data("id"))
|
||||
|
Reference in New Issue
Block a user