Skip to content

Commit 545dc61

Browse files
committed
feat:Dim Quote Headers and Add Author Metadata
1 parent 063d6b2 commit 545dc61

1 file changed

Lines changed: 23 additions & 8 deletions

File tree

src/ps/commands/quotes.tsx

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type { PSMessage } from '@/types/ps';
2020
import type { CSSProperties, ReactElement, ReactNode } from 'react';
2121

2222
type IndexedQuoteModel = [index: number, quote: QuoteModel];
23-
type QuoteCollection = [index: number, quote: string, addedBy?: string, dateAdded?: string][];
23+
type QuoteCollection = {index: number, quote: string, addedBy?: string, dateAdded?: string}[];
2424

2525
const PAGE_SIZE = 50;
2626
const MAX_QUOTE_LENGTH = (MAX_CHAT_HTML_LENGTH / PAGE_SIZE) * 2; // Leniency margin of 2x
@@ -170,7 +170,7 @@ function FormatQuote({
170170
const quoteLines = quote.split('\n');
171171
return (
172172
<>
173-
<div style={{ opacity: 0.6 }}>{header}</div>
173+
<div style={{ opacity: 0.78 }}>{header}</div>
174174
<div style={{ marginLeft: 12 }}>
175175
{quoteLines.length > 5 ? (
176176
<details className="readmore">
@@ -192,7 +192,7 @@ function FormatQuote({
192192
quoteLines.map(line => <FormatQuoteLine line={line} psUsernameTag={psUsernameTag} />)
193193
)}
194194
</div>
195-
<div style={{ fontSize: 10, opacity: 0.8, marginTop: 6 }}>
195+
<div style={{ fontSize: 10, opacity: 0.6, marginTop: 6 }}>
196196
Added by {addedBy} on {dateAdded}
197197
</div>
198198
</>
@@ -235,8 +235,8 @@ function MultiQuotes({
235235
})}${total > list.length ? ` of ${total} total` : ''})`;
236236
const title = baseTitle ? `${baseTitle} ${suffix}` : pageNum ? `Page ${pageNum} of ${pageCount} ${suffix}` : `All Quotes`;
237237
const quotes = list
238-
.map(([header, quote, addedBy, dateAdded]) => (
239-
<FormatQuote quote={quote} header={`#${header}`} addedBy={addedBy ?? ''} dateAdded={dateAdded ?? ''} />
238+
.map( quote => (
239+
<FormatQuote quote={quote.quote} header={`#${quote.index}`} addedBy={quote.addedBy ?? ''} dateAdded={quote.dateAdded ?? ''} />
240240
))
241241
.space(<hr />, !useDropdown);
242242

@@ -399,7 +399,12 @@ export const command: PSCommand = {
399399
const foundQuotes: QuoteCollection = searchQuotes(
400400
quotes.map<IndexedQuoteModel>((quote, index) => [index + 1, quote]),
401401
arg
402-
).map(([index, quote]) => [index, quote.quote, quote.addedBy, new Date(quote.at).toDateString()]);
402+
).map(([index, quote]) => ({
403+
index,
404+
quote: quote.quote,
405+
addedBy: quote.addedBy,
406+
dateAdded: new Date(quote.at).toDateString(),
407+
}));
403408

404409
if (!foundQuotes.length) return broadcast($T('COMMANDS.QUOTES.NO_QUOTES_FOUND'));
405410

@@ -457,7 +462,12 @@ export const command: PSCommand = {
457462
const endIndex = startIndex + PAGE_SIZE;
458463
const pagedQuotes: QuoteCollection = quotes
459464
.slice(startIndex, endIndex)
460-
.map((quote, index) => [startIndex + index + 1, quote.quote, quote.addedBy, new Date(quote.at).toDateString()]);
465+
.map((quote, index) => ({
466+
index: startIndex + index + 1,
467+
quote: quote.quote,
468+
addedBy: quote.addedBy,
469+
dateAdded: new Date(quote.at).toDateString()
470+
}));
461471

462472
if (!pagedQuotes.length) throw new ChatError('Invalid page number.' as ToTranslate);
463473

@@ -488,7 +498,12 @@ export const command: PSCommand = {
488498
const endIndex = startIndex + PAGE_SIZE;
489499
const pageQuotes: QuoteCollection = quotes
490500
.slice(startIndex, endIndex)
491-
.map((quote, index) => [startIndex + index + 1, quote.quote, quote.addedBy, new Date(quote.at).toDateString()]);
501+
.map((quote, index) => ({
502+
index: startIndex + index + 1,
503+
quote: quote.quote,
504+
addedBy: quote.addedBy,
505+
dateAdded: new Date(quote.at).toDateString()
506+
}));
492507

493508
if (!pageQuotes.length) throw new ChatError('Invalid page number.' as ToTranslate);
494509

0 commit comments

Comments
 (0)