refactor: chat list item data

This commit is contained in:
Shibo Lyu 2024-09-04 03:02:14 +08:00
parent 5954928834
commit c65ff6c892
3 changed files with 34 additions and 18 deletions

View file

@ -45,7 +45,7 @@ function deltaAttributesToBlahRichTextSpanAttributes(
return isObjectEmpty(blahRichTextSpanAttributes) ? null : blahRichTextSpanAttributes;
}
export function deltaToBlahRichText(delta: Delta, trim?: boolean = true): BlahRichText {
export function deltaToBlahRichText(delta: Delta, trim: boolean = true): BlahRichText {
const spans: BlahRichText = [];
let lastText = '';
@ -97,3 +97,7 @@ export function deltaToBlahRichText(delta: Delta, trim?: boolean = true): BlahRi
return spans;
}
export function blahRichTextToPlainText(richText: BlahRichText): string {
return richText.map((span) => (typeof span === 'string' ? span : span[0])).join('');
}

View file

@ -1,6 +1,11 @@
import type { Message } from './message';
export type Chat = {
server: string;
id: string;
name: string;
profilePictureUrl?: string;
type: 'group' | 'peer' | 'channel';
lastMessage?: Message;
unreadCount?: number;
};