Update hide / unhide commands to accept range
This commit is contained in:
parent
c6ac4459a3
commit
abb8b0f0cc
|
@ -4685,7 +4685,7 @@ async function renamePastChats(newAvatar, newValue) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function saveChatDebounced() {
|
export function saveChatDebounced() {
|
||||||
const chid = this_chid;
|
const chid = this_chid;
|
||||||
const selectedGroup = selected_group;
|
const selectedGroup = selected_group;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ import {
|
||||||
chat,
|
chat,
|
||||||
getCurrentChatId,
|
getCurrentChatId,
|
||||||
hideSwipeButtons,
|
hideSwipeButtons,
|
||||||
saveChatConditional,
|
saveChatDebounced,
|
||||||
showSwipeButtons,
|
showSwipeButtons,
|
||||||
} from "../script.js";
|
} from "../script.js";
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@ export async function hideChatMessage(messageId, messageBlock) {
|
||||||
hideSwipeButtons();
|
hideSwipeButtons();
|
||||||
showSwipeButtons();
|
showSwipeButtons();
|
||||||
|
|
||||||
await saveChatConditional();
|
saveChatDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,7 +55,7 @@ export async function unhideChatMessage(messageId, messageBlock) {
|
||||||
hideSwipeButtons();
|
hideSwipeButtons();
|
||||||
showSwipeButtons();
|
showSwipeButtons();
|
||||||
|
|
||||||
await saveChatConditional();
|
saveChatDebounced();
|
||||||
}
|
}
|
||||||
|
|
||||||
jQuery(function() {
|
jQuery(function() {
|
||||||
|
|
|
@ -32,6 +32,7 @@ import { chat_styles, power_user } from "./power-user.js";
|
||||||
import { autoSelectPersona } from "./personas.js";
|
import { autoSelectPersona } from "./personas.js";
|
||||||
import { getContext } from "./extensions.js";
|
import { getContext } from "./extensions.js";
|
||||||
import { hideChatMessage, unhideChatMessage } from "./chats.js";
|
import { hideChatMessage, unhideChatMessage } from "./chats.js";
|
||||||
|
import { stringToRange } from "./utils.js";
|
||||||
export {
|
export {
|
||||||
executeSlashCommands,
|
executeSlashCommands,
|
||||||
registerSlashCommand,
|
registerSlashCommand,
|
||||||
|
@ -145,8 +146,8 @@ parser.addCommand('ask', askCharacter, [], '<span class="monospace">(prompt)</sp
|
||||||
parser.addCommand('delname', deleteMessagesByNameCallback, ['cancel'], '<span class="monospace">(name)</span> – deletes all messages attributed to a specified name', true, true);
|
parser.addCommand('delname', deleteMessagesByNameCallback, ['cancel'], '<span class="monospace">(name)</span> – deletes all messages attributed to a specified name', true, true);
|
||||||
parser.addCommand('send', sendUserMessageCallback, ['add'], '<span class="monospace">(text)</span> – adds a user message to the chat log without triggering a generation', true, true);
|
parser.addCommand('send', sendUserMessageCallback, ['add'], '<span class="monospace">(text)</span> – adds a user message to the chat log without triggering a generation', true, true);
|
||||||
parser.addCommand('trigger', triggerGroupMessageCallback, [], '<span class="monospace">(member index or name)</span> – triggers a message generation for the specified group member', true, true);
|
parser.addCommand('trigger', triggerGroupMessageCallback, [], '<span class="monospace">(member index or name)</span> – triggers a message generation for the specified group member', true, true);
|
||||||
parser.addCommand('hide', hideMessageCallback, [], '<span class="monospace">(message index)</span> – hides a chat message from the prompt', true, true);
|
parser.addCommand('hide', hideMessageCallback, [], '<span class="monospace">(message index or range)</span> – hides a chat message from the prompt', true, true);
|
||||||
parser.addCommand('unhide', unhideMessageCallback, [], '<span class="monospace">(message index)</span> – unhides a message from the prompt', true, true);
|
parser.addCommand('unhide', unhideMessageCallback, [], '<span class="monospace">(message index or range)</span> – unhides a message from the prompt', true, true);
|
||||||
|
|
||||||
const NARRATOR_NAME_KEY = 'narrator_name';
|
const NARRATOR_NAME_KEY = 'narrator_name';
|
||||||
const NARRATOR_NAME_DEFAULT = 'System';
|
const NARRATOR_NAME_DEFAULT = 'System';
|
||||||
|
@ -240,7 +241,14 @@ async function hideMessageCallback(_, arg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageId = Number(arg);
|
const range = stringToRange(arg, 0, chat.length - 1);
|
||||||
|
|
||||||
|
if (!range) {
|
||||||
|
console.warn(`WARN: Invalid range provided for /hide command: ${arg}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let messageId = range.start; messageId <= range.end; messageId++) {
|
||||||
const messageBlock = $(`.mes[mesid="${messageId}"]`);
|
const messageBlock = $(`.mes[mesid="${messageId}"]`);
|
||||||
|
|
||||||
if (!messageBlock.length) {
|
if (!messageBlock.length) {
|
||||||
|
@ -250,6 +258,7 @@ async function hideMessageCallback(_, arg) {
|
||||||
|
|
||||||
await hideChatMessage(messageId, messageBlock);
|
await hideChatMessage(messageId, messageBlock);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function unhideMessageCallback(_, arg) {
|
async function unhideMessageCallback(_, arg) {
|
||||||
if (!arg) {
|
if (!arg) {
|
||||||
|
@ -257,7 +266,14 @@ async function unhideMessageCallback(_, arg) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const messageId = Number(arg);
|
const range = stringToRange(arg, 0, chat.length - 1);
|
||||||
|
|
||||||
|
if (!range) {
|
||||||
|
console.warn(`WARN: Invalid range provided for /unhide command: ${arg}`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let messageId = range.start; messageId <= range.end; messageId++) {
|
||||||
const messageBlock = $(`.mes[mesid="${messageId}"]`);
|
const messageBlock = $(`.mes[mesid="${messageId}"]`);
|
||||||
|
|
||||||
if (!messageBlock.length) {
|
if (!messageBlock.length) {
|
||||||
|
@ -267,6 +283,7 @@ async function unhideMessageCallback(_, arg) {
|
||||||
|
|
||||||
await unhideChatMessage(messageId, messageBlock);
|
await unhideChatMessage(messageId, messageBlock);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function triggerGroupMessageCallback(_, arg) {
|
async function triggerGroupMessageCallback(_, arg) {
|
||||||
if (!selected_group) {
|
if (!selected_group) {
|
||||||
|
|
Loading…
Reference in New Issue