phanpy/src/utils/status-peek.jsx

35 lines
703 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();
if (poll) {
text += ' 📊';
}
if (mediaAttachments?.length) {
text +=
' ' +
mediaAttachments
.map(
(m) =>
({
image: '🖼️',
gifv: '🎞️',
video: '📹',
audio: '🎵',
unknown: '',
}[m.type] || ''),
)
.join('');
}
return text;
}
export default statusPeek;