Skip to content

Commit a267f6e

Browse files
authored
🔍 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
1 parent f742b99 commit a267f6e

File tree

6 files changed

+52
-20
lines changed

6 files changed

+52
-20
lines changed

api/cache/clearPendingReq.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const clearPendingReq = async ({ userId, cache: _cache }) => {
3535
return;
3636
}
3737

38-
const key = `${USE_REDIS ? namespace : ''}:${userId ?? ''}`;
38+
const key = `${isEnabled(USE_REDIS) ? namespace : ''}:${userId ?? ''}`;
3939
const currentReq = +((await cache.get(key)) ?? 0);
4040

4141
if (currentReq && currentReq >= 1) {

api/server/socialLogins.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const {
99
discordLogin,
1010
facebookLogin,
1111
} = require('~/strategies');
12+
const { isEnabled } = require('~/server/utils');
1213
const { logger } = require('~/config');
1314

1415
/**
@@ -40,7 +41,7 @@ const configureSocialLogins = (app) => {
4041
resave: false,
4142
saveUninitialized: false,
4243
};
43-
if (process.env.USE_REDIS) {
44+
if (isEnabled(process.env.USE_REDIS)) {
4445
const client = new Redis(process.env.REDIS_URI);
4546
client
4647
.on('error', (err) => logger.error('ioredis error:', err))

client/src/components/Chat/Messages/Content/Markdown.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,11 @@ const cursor = ' ';
109109

110110
type TContentProps = {
111111
content: string;
112-
isEdited?: boolean;
113112
showCursor?: boolean;
114113
isLatestMessage: boolean;
115114
};
116115

117-
const Markdown = memo(({ content = '', isEdited, showCursor, isLatestMessage }: TContentProps) => {
116+
const Markdown = memo(({ content = '', showCursor, isLatestMessage }: TContentProps) => {
118117
const LaTeXParsing = useRecoilValue<boolean>(store.LaTeXParsing);
119118

120119
const isInitializing = content === '';
@@ -147,10 +146,6 @@ const Markdown = memo(({ content = '', isEdited, showCursor, isLatestMessage }:
147146
);
148147
}
149148

150-
if (isEdited === true || !isLatestMessage) {
151-
rehypePlugins.pop();
152-
}
153-
154149
return (
155150
<ReactMarkdown
156151
remarkPlugins={[supersub, remarkGfm, [remarkMath, { singleDollarTextMath: true }]]}

client/src/components/Chat/Messages/Content/MessageContent.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,7 @@ const DisplayMessage = ({ text, isCreatedByUser, message, showCursor }: TDisplay
8484
)}
8585
>
8686
{!isCreatedByUser ? (
87-
<Markdown
88-
content={text}
89-
isEdited={message.isEdited}
90-
showCursor={showCursorState}
91-
isLatestMessage={isLatestMessage}
92-
/>
87+
<Markdown content={text} showCursor={showCursorState} isLatestMessage={isLatestMessage} />
9388
) : (
9489
<>{text}</>
9590
)}

client/src/components/Chat/Messages/Content/Part.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,7 @@ const DisplayMessage = ({ text, isCreatedByUser = false, message, showCursor }:
4141
)}
4242
>
4343
{!isCreatedByUser ? (
44-
<Markdown
45-
content={text}
46-
isEdited={message.isEdited}
47-
showCursor={showCursorState}
48-
isLatestMessage={isLatestMessage}
49-
/>
44+
<Markdown content={text} showCursor={showCursorState} isLatestMessage={isLatestMessage} />
5045
) : (
5146
<>{text}</>
5247
)}

client/src/style.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1945,10 +1945,12 @@ button.scroll-convo {
19451945
.markdown ol > li {
19461946
position: relative;
19471947
padding-left: 0.375em;
1948+
counter-increment: list-counter;
19481949
}
19491950

19501951
.prose ol > li::marker,
19511952
.markdown ol > li::marker {
1953+
content: counter(list-counter) ". ";
19521954
color: var(--tw-prose-counters);
19531955
font-weight: 400;
19541956
}
@@ -1957,11 +1959,33 @@ button.scroll-convo {
19571959
.prose ol ol,
19581960
.markdown ol ol {
19591961
list-style-type: lower-alpha;
1962+
counter-reset: list-counter-alpha;
1963+
}
1964+
1965+
.prose ol ol > li,
1966+
.markdown ol ol > li {
1967+
counter-increment: list-counter-alpha;
1968+
}
1969+
1970+
.prose ol ol > li::marker,
1971+
.markdown ol ol > li::marker {
1972+
content: counter(list-counter-alpha, lower-alpha) ". ";
19601973
}
19611974

19621975
.prose ol ol ol,
19631976
.markdown ol ol ol {
19641977
list-style-type: lower-roman;
1978+
counter-reset: list-counter-roman;
1979+
}
1980+
1981+
.prose ol ol ol > li,
1982+
.markdown ol ol ol > li {
1983+
counter-increment: list-counter-roman;
1984+
}
1985+
1986+
.prose ol ol ol > li::marker,
1987+
.markdown ol ol ol > li::marker {
1988+
content: counter(list-counter-roman, lower-roman) ". ";
19651989
}
19661990

19671991
/* Unordered lists */
@@ -2025,6 +2049,28 @@ button.scroll-convo {
20252049
color: currentColor;
20262050
}
20272051

2052+
/* Reset counter for new sections */
2053+
.prose h1 + ol,
2054+
.prose h2 + ol,
2055+
.prose h3 + ol,
2056+
.prose h4 + ol,
2057+
.prose h5 + ol,
2058+
.prose h6 + ol,
2059+
.markdown h1 + ol,
2060+
.markdown h2 + ol,
2061+
.markdown h3 + ol,
2062+
.markdown h4 + ol,
2063+
.markdown h5 + ol,
2064+
.markdown h6 + ol {
2065+
counter-reset: list-counter;
2066+
}
2067+
2068+
/* Reset counter after unordered lists */
2069+
.prose ul + ol,
2070+
.markdown ul + ol {
2071+
counter-reset: list-counter;
2072+
}
2073+
20282074
/* Keyframes */
20292075

20302076
@keyframes slideFromLeftToRightAndFade {

0 commit comments

Comments
 (0)