phanpy/src/utils/status-peek.jsx

37 lines
827 B
React
Raw Normal View History

2023-03-28 20:12:59 +03:00
import getHTMLText from './getHTMLText';
2023-03-21 19:09:36 +03:00
function statusPeek(status) {
const { spoilerText, content, poll, mediaAttachments } = status;
let text = '';
if (spoilerText?.trim()) {
text += spoilerText;
} else {
text += getHTMLText(content);
}
text = text.trim();
2024-03-07 07:34:38 +03:00
if (poll?.options?.length) {
text += `\n\n📊:\n${poll.options
.map((o) => `${poll.multiple ? '▪️' : '•'} ${o.title}`)
.join('\n')}`;
2023-03-21 19:09:36 +03:00
}
if (mediaAttachments?.length) {
text +=
' ' +
mediaAttachments
.map(
(m) =>
({
image: '🖼️',
gifv: '🎞️',
video: '📹',
audio: '🎵',
unknown: '',
}[m.type] || ''),
)
.join('');
}
return text;
}
export default statusPeek;