phanpy/src/utils/status-peek.jsx

35 lines
703 B
React
Raw Normal View History

2023-03-28 17:12:59 +00:00
import getHTMLText from './getHTMLText';
2023-03-21 16:09:36 +00:00
function statusPeek(status) {
const { spoilerText, content, poll, mediaAttachments } = status;
let text = '';
if (spoilerText?.trim()) {
text += spoilerText;
} else {
text += getHTMLText(content);
}
text = text.trim();
if (poll) {
text += ' 📊';
}
if (mediaAttachments?.length) {
text +=
' ' +
mediaAttachments
.map(
(m) =>
({
image: '🖼️',
gifv: '🎞️',
video: '📹',
audio: '🎵',
unknown: '',
}[m.type] || ''),
)
.join('');
}
return text;
}
export default statusPeek;