Files
thelounge/client/js/helpers/inputHistory.ts
Max Leiter eb75c4b77c chore: refactor Mentions, add isIgnoredUser util (#5051)
- 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
2026-04-11 07:59:14 -07:00

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)
);
}