mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-04-08 20:10:54 +01:00
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { formatNumber } from './utils';
|
|
|
|
/* The embed "author" text we populate with replies, retweets, and likes unless it's a video */
|
|
export const getAuthorText = (tweet: APITweet): string | null => {
|
|
/* Build out reply, retweet, like counts */
|
|
if (tweet.likes > 0 || tweet.retweets > 0 || tweet.replies > 0) {
|
|
let authorText = '';
|
|
if (tweet.replies > 0) {
|
|
authorText += `${formatNumber(tweet.replies)} 💬 `;
|
|
}
|
|
if (tweet.retweets > 0) {
|
|
authorText += `${formatNumber(tweet.retweets)} 🔁 `;
|
|
}
|
|
if (tweet.likes > 0) {
|
|
authorText += `${formatNumber(tweet.likes)} ❤️ `;
|
|
}
|
|
if (tweet.views && tweet.views > 0) {
|
|
authorText += `${formatNumber(tweet.views)} 👁️ `;
|
|
}
|
|
authorText = authorText.trim();
|
|
|
|
return authorText;
|
|
}
|
|
|
|
return null;
|
|
};
|
|
|
|
/* The embed "author" text we populate with replies, retweets, and likes unless it's a video */
|
|
export const getSocialTextIV = (tweet: APITweet): string | null => {
|
|
/* Build out reply, retweet, like counts */
|
|
if (tweet.likes > 0 || tweet.retweets > 0 || tweet.replies > 0) {
|
|
let authorText = '';
|
|
if (tweet.replies > 0) {
|
|
authorText += `💬 ${formatNumber(tweet.replies)} `;
|
|
}
|
|
if (tweet.retweets > 0) {
|
|
authorText += `🔁 ${formatNumber(tweet.retweets)} `;
|
|
}
|
|
if (tweet.likes > 0) {
|
|
authorText += `❤️ ${formatNumber(tweet.likes)} `;
|
|
}
|
|
if (tweet.views && tweet.views > 0) {
|
|
authorText += `👁️ ${formatNumber(tweet.views)} `;
|
|
}
|
|
authorText = authorText.trim();
|
|
|
|
return authorText;
|
|
}
|
|
|
|
return null;
|
|
};
|