mirror of
https://github.com/thelounge/thelounge.git
synced 2026-04-17 20:38:35 -04:00
- Mentions were doing a bunch of mutations; not just uses derived state - no need for a separate `ClientMention` - added `extractInputHistory` for shared logic - tests made by claude
14 lines
413 B
TypeScript
14 lines
413 B
TypeScript
import {MessageType, SharedMsg} from "../../../shared/types/msg";
|
|
|
|
export function extractInputHistory(messages: SharedMsg[], limit: number): string[] {
|
|
return (
|
|
messages
|
|
.filter((m) => m.self && m.text && m.type === MessageType.MESSAGE)
|
|
// TS is too stupid to see the guard in .filter(), so we monkey patch it
|
|
// to please the compiler
|
|
.map((m) => m.text!)
|
|
.reverse()
|
|
.slice(0, limit)
|
|
);
|
|
}
|