Room FAQs: Fix source code and repeats display

This commit is contained in:
Kris Johnson
2021-09-06 17:01:23 -06:00
parent 055a01ab89
commit 8151ffca2a
2 changed files with 6 additions and 4 deletions

View File

@@ -138,7 +138,8 @@ export const pages: Chat.PageTable = {
for (const repeat of room.settings.repeats) {
const minutes = repeat.interval / (repeat.isByMessages ? 1 : 60 * 1000);
const repeatText = repeat.faq ? roomFaqs[room.roomid][repeat.id].source : repeat.phrase;
const phrase = repeat.isHTML ? repeat.phrase : Chat.formatText(repeatText, true);
const phrase = repeat.faq ? visualizeFaq(roomFaqs[room.roomid][repeat.id]) :
repeat.isHTML ? repeat.phrase : Chat.formatText(repeatText, true);
html += `<tr><td>${repeat.id}</td><td>${phrase}</td><td>${Chat.getReadmoreCodeBlock(repeatText)}</td><td>${repeat.isByMessages ? this.tr`every ${minutes} chat message(s)` : this.tr`every ${minutes} minute(s)`}</td>`;
html += `<td><button class="button" name="send" value="/msgroom ${room.roomid},/removerepeat ${repeat.id}">${this.tr`Remove`}</button></td>`;
}

View File

@@ -164,10 +164,11 @@ export const commands: Chat.ChatCommands = {
topic = getAlias(room.roomid, topic) || topic;
if (!this.runBroadcast()) return;
this.sendReplyBox(visualizeFaq(roomFaqs[room.roomid][topic]));
const rfaq = roomFaqs[room.roomid][topic];
this.sendReplyBox(visualizeFaq(rfaq));
if (!this.broadcasting && user.can('ban', null, room, 'rfaq')) {
const code = Utils.escapeHTML(roomFaqs[room.roomid][topic].source).replace(/\n/g, '<br />');
this.sendReplyBox(`<details><summary>Source</summary><code style="white-space: pre-wrap; display: table; tab-size: 3">/addfaq ${topic}, ${code}</code></details>`);
const code = Utils.escapeHTML(rfaq.source).replace(/\n/g, '<br />');
this.sendReplyBox(`<details><summary>Source</summary><code style="white-space: pre-wrap; display: table; tab-size: 3">/add${rfaq.html ? 'html' : ''}faq ${topic}, ${code}</code></details>`);
}
},
roomfaqhelp: [