phanpy/src/utils/status-peek.js

37 lines
827 B
JavaScript
Raw Normal View History

2023-03-28 19:12:59 +02:00
import getHTMLText from './getHTMLText';
2023-03-21 17:09:36 +01: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 05:34:38 +01:00
if (poll?.options?.length) {
text += `\n\n📊:\n${poll.options
.map((o) => `${poll.multiple ? '▪️' : '•'} ${o.title}`)
.join('\n')}`;
2023-03-21 17:09:36 +01:00
}
if (mediaAttachments?.length) {
text +=
' ' +
mediaAttachments
.map(
(m) =>
({
image: '🖼️',
gifv: '🎞️',
video: '📹',
audio: '🎵',
unknown: '',
})[m.type] || '',
2023-03-21 17:09:36 +01:00
)
.join('');
}
return text;
}
export default statusPeek;