BangSo/apps/mobile/lib/inbox.ts

24 lines
589 B
TypeScript
Raw Permalink Normal View History

2026-09-01 16:51:19 +00:00
export { botTag, formatThreadTime } from "@rakazo/core";
export function filterBots<T extends { name: string; title: string; preview: string }>(
bots: T[],
query: string,
): T[] {
const needle = query.trim().toLowerCase();
if (!needle) return bots;
return bots.filter((bot) =>
`${bot.name} ${bot.title} ${bot.preview}`.toLowerCase().includes(needle),
);
}
export function userInitials(name: string) {
const initials = name
.split(/\s+/)
.filter(Boolean)
.map((part) => part[0])
.join("")
.slice(0, 2)
.toUpperCase();
return initials || "?";
}