mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
🔍 fix: USE_REDIS condition, Markdown list counter, code highlights (#3806)
* fix: markdown rehype highlight accidental removal * fix: USE_REDIS condition check * fix: markdown list counter
This commit is contained in:
parent
f742b9972e
commit
a267f6e0da
6 changed files with 52 additions and 20 deletions
2
api/cache/clearPendingReq.js
vendored
2
api/cache/clearPendingReq.js
vendored
|
|
@ -35,7 +35,7 @@ const clearPendingReq = async ({ userId, cache: _cache }) => {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const key = `${USE_REDIS ? namespace : ''}:${userId ?? ''}`;
|
const key = `${isEnabled(USE_REDIS) ? namespace : ''}:${userId ?? ''}`;
|
||||||
const currentReq = +((await cache.get(key)) ?? 0);
|
const currentReq = +((await cache.get(key)) ?? 0);
|
||||||
|
|
||||||
if (currentReq && currentReq >= 1) {
|
if (currentReq && currentReq >= 1) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ const {
|
||||||
discordLogin,
|
discordLogin,
|
||||||
facebookLogin,
|
facebookLogin,
|
||||||
} = require('~/strategies');
|
} = require('~/strategies');
|
||||||
|
const { isEnabled } = require('~/server/utils');
|
||||||
const { logger } = require('~/config');
|
const { logger } = require('~/config');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -40,7 +41,7 @@ const configureSocialLogins = (app) => {
|
||||||
resave: false,
|
resave: false,
|
||||||
saveUninitialized: false,
|
saveUninitialized: false,
|
||||||
};
|
};
|
||||||
if (process.env.USE_REDIS) {
|
if (isEnabled(process.env.USE_REDIS)) {
|
||||||
const client = new Redis(process.env.REDIS_URI);
|
const client = new Redis(process.env.REDIS_URI);
|
||||||
client
|
client
|
||||||
.on('error', (err) => logger.error('ioredis error:', err))
|
.on('error', (err) => logger.error('ioredis error:', err))
|
||||||
|
|
|
||||||
|
|
@ -109,12 +109,11 @@ const cursor = ' ';
|
||||||
|
|
||||||
type TContentProps = {
|
type TContentProps = {
|
||||||
content: string;
|
content: string;
|
||||||
isEdited?: boolean;
|
|
||||||
showCursor?: boolean;
|
showCursor?: boolean;
|
||||||
isLatestMessage: boolean;
|
isLatestMessage: boolean;
|
||||||
};
|
};
|
||||||
|
|
||||||
const Markdown = memo(({ content = '', isEdited, showCursor, isLatestMessage }: TContentProps) => {
|
const Markdown = memo(({ content = '', showCursor, isLatestMessage }: TContentProps) => {
|
||||||
const LaTeXParsing = useRecoilValue<boolean>(store.LaTeXParsing);
|
const LaTeXParsing = useRecoilValue<boolean>(store.LaTeXParsing);
|
||||||
|
|
||||||
const isInitializing = content === '';
|
const isInitializing = content === '';
|
||||||
|
|
@ -147,10 +146,6 @@ const Markdown = memo(({ content = '', isEdited, showCursor, isLatestMessage }:
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEdited === true || !isLatestMessage) {
|
|
||||||
rehypePlugins.pop();
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ReactMarkdown
|
<ReactMarkdown
|
||||||
remarkPlugins={[supersub, remarkGfm, [remarkMath, { singleDollarTextMath: true }]]}
|
remarkPlugins={[supersub, remarkGfm, [remarkMath, { singleDollarTextMath: true }]]}
|
||||||
|
|
|
||||||
|
|
@ -84,12 +84,7 @@ const DisplayMessage = ({ text, isCreatedByUser, message, showCursor }: TDisplay
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{!isCreatedByUser ? (
|
{!isCreatedByUser ? (
|
||||||
<Markdown
|
<Markdown content={text} showCursor={showCursorState} isLatestMessage={isLatestMessage} />
|
||||||
content={text}
|
|
||||||
isEdited={message.isEdited}
|
|
||||||
showCursor={showCursorState}
|
|
||||||
isLatestMessage={isLatestMessage}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<>{text}</>
|
<>{text}</>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -41,12 +41,7 @@ const DisplayMessage = ({ text, isCreatedByUser = false, message, showCursor }:
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
{!isCreatedByUser ? (
|
{!isCreatedByUser ? (
|
||||||
<Markdown
|
<Markdown content={text} showCursor={showCursorState} isLatestMessage={isLatestMessage} />
|
||||||
content={text}
|
|
||||||
isEdited={message.isEdited}
|
|
||||||
showCursor={showCursorState}
|
|
||||||
isLatestMessage={isLatestMessage}
|
|
||||||
/>
|
|
||||||
) : (
|
) : (
|
||||||
<>{text}</>
|
<>{text}</>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -1945,10 +1945,12 @@ button.scroll-convo {
|
||||||
.markdown ol > li {
|
.markdown ol > li {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-left: 0.375em;
|
padding-left: 0.375em;
|
||||||
|
counter-increment: list-counter;
|
||||||
}
|
}
|
||||||
|
|
||||||
.prose ol > li::marker,
|
.prose ol > li::marker,
|
||||||
.markdown ol > li::marker {
|
.markdown ol > li::marker {
|
||||||
|
content: counter(list-counter) ". ";
|
||||||
color: var(--tw-prose-counters);
|
color: var(--tw-prose-counters);
|
||||||
font-weight: 400;
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
|
|
@ -1957,11 +1959,33 @@ button.scroll-convo {
|
||||||
.prose ol ol,
|
.prose ol ol,
|
||||||
.markdown ol ol {
|
.markdown ol ol {
|
||||||
list-style-type: lower-alpha;
|
list-style-type: lower-alpha;
|
||||||
|
counter-reset: list-counter-alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose ol ol > li,
|
||||||
|
.markdown ol ol > li {
|
||||||
|
counter-increment: list-counter-alpha;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose ol ol > li::marker,
|
||||||
|
.markdown ol ol > li::marker {
|
||||||
|
content: counter(list-counter-alpha, lower-alpha) ". ";
|
||||||
}
|
}
|
||||||
|
|
||||||
.prose ol ol ol,
|
.prose ol ol ol,
|
||||||
.markdown ol ol ol {
|
.markdown ol ol ol {
|
||||||
list-style-type: lower-roman;
|
list-style-type: lower-roman;
|
||||||
|
counter-reset: list-counter-roman;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose ol ol ol > li,
|
||||||
|
.markdown ol ol ol > li {
|
||||||
|
counter-increment: list-counter-roman;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prose ol ol ol > li::marker,
|
||||||
|
.markdown ol ol ol > li::marker {
|
||||||
|
content: counter(list-counter-roman, lower-roman) ". ";
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unordered lists */
|
/* Unordered lists */
|
||||||
|
|
@ -2025,6 +2049,28 @@ button.scroll-convo {
|
||||||
color: currentColor;
|
color: currentColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reset counter for new sections */
|
||||||
|
.prose h1 + ol,
|
||||||
|
.prose h2 + ol,
|
||||||
|
.prose h3 + ol,
|
||||||
|
.prose h4 + ol,
|
||||||
|
.prose h5 + ol,
|
||||||
|
.prose h6 + ol,
|
||||||
|
.markdown h1 + ol,
|
||||||
|
.markdown h2 + ol,
|
||||||
|
.markdown h3 + ol,
|
||||||
|
.markdown h4 + ol,
|
||||||
|
.markdown h5 + ol,
|
||||||
|
.markdown h6 + ol {
|
||||||
|
counter-reset: list-counter;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Reset counter after unordered lists */
|
||||||
|
.prose ul + ol,
|
||||||
|
.markdown ul + ol {
|
||||||
|
counter-reset: list-counter;
|
||||||
|
}
|
||||||
|
|
||||||
/* Keyframes */
|
/* Keyframes */
|
||||||
|
|
||||||
@keyframes slideFromLeftToRightAndFade {
|
@keyframes slideFromLeftToRightAndFade {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue