Rewritten minLogLevel feature

This commit is contained in:
Eradev
2025-01-15 10:02:32 -05:00
parent 78e67080c9
commit 1f9fa74786
44 changed files with 580 additions and 561 deletions

View File

@ -1,15 +1,13 @@
import { getRequestHeaders, substituteParams } from '../../../../script.js';
import { Popup, POPUP_RESULT, POPUP_TYPE } from '../../../popup.js';
import { executeSlashCommands, executeSlashCommandsOnChatInput, executeSlashCommandsWithOptions } from '../../../slash-commands.js';
import { executeSlashCommandsOnChatInput, executeSlashCommandsWithOptions } from '../../../slash-commands.js';
import { SlashCommandParser } from '../../../slash-commands/SlashCommandParser.js';
import { SlashCommandScope } from '../../../slash-commands/SlashCommandScope.js';
import { debounceAsync, log, warn } from '../index.js';
import { debounceAsync, warn } from '../index.js';
import { QuickReply } from './QuickReply.js';
export class QuickReplySet {
/**@type {QuickReplySet[]}*/ static list = [];
static from(props) {
props.qrList = []; //props.qrList?.map(it=>QuickReply.from(it));
const instance = Object.assign(new this(), props);
@ -24,9 +22,6 @@ export class QuickReplySet {
return this.list.find(it=>it.name == name);
}
/**@type {string}*/ name;
/**@type {boolean}*/ disableSend = false;
/**@type {boolean}*/ placeBeforeInput = false;
@ -34,19 +29,12 @@ export class QuickReplySet {
/**@type {string}*/ color = 'transparent';
/**@type {boolean}*/ onlyBorderColor = false;
/**@type {QuickReply[]}*/ qrList = [];
/**@type {number}*/ idIndex = 0;
/**@type {boolean}*/ isDeleted = false;
/**@type {function}*/ save;
/**@type {HTMLElement}*/ dom;
/**@type {HTMLElement}*/ settingsDom;
constructor() {
this.save = debounceAsync(()=>this.performSave(), 200);
}
@ -55,9 +43,6 @@ export class QuickReplySet {
this.qrList.forEach(qr=>this.hookQuickReply(qr));
}
unrender() {
this.dom?.remove();
this.dom = null;
@ -100,9 +85,6 @@ export class QuickReplySet {
}
}
renderSettings() {
if (!this.settingsDom) {
this.settingsDom = document.createElement('div'); {
@ -123,9 +105,6 @@ export class QuickReplySet {
this.settingsDom.append(qr.renderSettings(idx));
}
/**
*
* @param {QuickReply} qr
@ -138,6 +117,7 @@ export class QuickReplySet {
closure.scope.setMacro('arg::*', '');
return (await closure.execute())?.pipe;
}
/**
*
* @param {QuickReply} qr The QR to execute.
@ -207,6 +187,7 @@ export class QuickReplySet {
document.querySelector('#send_but').click();
}
}
/**
* @param {QuickReply} qr
* @param {string} [message] - optional altered message to be used
@ -220,9 +201,6 @@ export class QuickReplySet {
});
}
addQuickReply(data = {}) {
const id = Math.max(this.idIndex, this.qrList.reduce((max,qr)=>Math.max(max,qr.id),0)) + 1;
data.id =
@ -239,6 +217,7 @@ export class QuickReplySet {
this.save();
return qr;
}
addQuickReplyFromText(qrJson) {
let data;
if (qrJson) {
@ -371,7 +350,6 @@ export class QuickReplySet {
this.save();
}
toJSON() {
return {
version: 2,
@ -386,7 +364,6 @@ export class QuickReplySet {
};
}
async performSave() {
const response = await fetch('/api/quick-replies/save', {
method: 'POST',