26 lines
542 B
TypeScript
26 lines
542 B
TypeScript
import { isArray } from '@sniptt/guards';
|
|
|
|
export const getActivitySummary = (activityBody: string) => {
|
|
const noteBody = activityBody ? JSON.parse(activityBody) : [];
|
|
|
|
if (!noteBody.length) {
|
|
return '';
|
|
}
|
|
|
|
const firstNoteBlockContent = noteBody[0].content;
|
|
|
|
if (!firstNoteBlockContent) {
|
|
return '';
|
|
}
|
|
|
|
if (firstNoteBlockContent.text) {
|
|
return noteBody[0].content.text;
|
|
}
|
|
|
|
if (isArray(firstNoteBlockContent)) {
|
|
return firstNoteBlockContent.map((content: any) => content.text).join(' ');
|
|
}
|
|
|
|
return '';
|
|
};
|