Run prettier

This commit is contained in:
dangered wolf 2024-05-01 00:33:02 -04:00
parent 8a8bf14a16
commit 54507d077c
No known key found for this signature in database
GPG key ID: 41E4D37680ED8B58
5 changed files with 46 additions and 29 deletions

View file

@ -5,12 +5,12 @@
"quotedFrom": "Quoting {name} (@{screen_name})",
"replyingTo": "Replying to @{screen_name}",
"threadPartHeader": "A part of @${screen_name}'s thread",
"ivAuthorActionReply": "<a href=\"{statusUrl}\">Reply</a> from <b>{authorName}</b> (<a href=\"{authorUrl}\">@{authorScreenName}</a>):",
"ivAuthorActionOriginal": "<a href=\"{statusUrl}\">Original</a> from <b>{authorName}</b> (<a href=\"{authorUrl}\">@{authorScreenName}</a>):",
"ivAuthorActionFollowUp": "<a href=\"{statusUrl}\">Follow-up</a> from <b>{authorName}</b> (<a href=\"{authorUrl}\">@{authorScreenName}</a>):",
"ivQuoteHeader": "<a href=\"{url}\">Quoting</a> {authorName} (<a href=\"{authorURL}\">@{authorHandle}</a>)",
"photoCount": "Photo {number} / {total}",
"videoCount": "Video {number} / {total}",
"mediaCount": "Media {number} / {total}",

View file

@ -10,7 +10,7 @@ import { renderInstantView } from '../render/instantview';
import { constructTwitterThread } from '../providers/twitter/conversation';
import { Experiment, experimentCheck } from '../experiments';
import i18next from 'i18next';
import icu from "i18next-icu";
import icu from 'i18next-icu';
import translationResources from '../../i18n/resources.json';
export const returnError = (c: Context, error: string): Response => {
@ -488,7 +488,7 @@ export const handleStatus = async (
const mediaType = overrideMedia ?? status.media.videos?.[0]?.type;
if (mediaType === 'gif') {
provider = i18next.t('gifIndicator', {brandingName: Constants.BRANDING_NAME});
provider = i18next.t('gifIndicator', { brandingName: Constants.BRANDING_NAME });
} else if (
status.embed_card === 'player' &&
providerEngagementText !== Strings.DEFAULT_AUTHOR_TEXT

View file

@ -115,8 +115,8 @@ const notApplicableComment = '<!-- N/A -->';
const truncateSocialCount = (count: number, locale = 'en-US') => {
const formatter = new Intl.NumberFormat(locale, {
notation: "compact",
compactDisplay: "short",
notation: 'compact',
compactDisplay: 'short',
maximumFractionDigits: 1
});
@ -143,7 +143,7 @@ const generateInlineAuthorHeader = (
authorScreenName: author.screen_name
})}</i></h4>`;
}
// Reply / unknown
// Reply / unknown
return `<h4><i>${i18next.t('ivAuthorActionReply', {
statusUrl: status.url,
authorName: author.name,
@ -170,7 +170,12 @@ const wrapForeignLinks = (url: string) => {
: url;
};
const generateStatusFooter = (status: APIStatus, isQuote = false, author: APIUser, language: string): string => {
const generateStatusFooter = (
status: APIStatus,
isQuote = false,
author: APIUser,
language: string
): string => {
let description = author.description;
description = htmlifyLinks(description);
description = htmlifyHashtags(description);
@ -221,10 +226,10 @@ const generatePoll = (poll: APIPoll, language: string): string => {
poll.choices.forEach(choice => {
const bar = '█'.repeat((choice.percentage / 100) * barLength);
// eslint-disable-next-line no-irregular-whitespace
str += `${bar}<br>${choice.label}<br>${i18next.t('ivPollChoice', { voteCount: intlFormat.format(choice.count), percentage: intlFormat.format(choice.percentage)})}<br>`;
str += `${bar}<br>${choice.label}<br>${i18next.t('ivPollChoice', { voteCount: intlFormat.format(choice.count), percentage: intlFormat.format(choice.percentage) })}<br>`;
});
/* Finally, add the footer of the poll with # of votes and time left */
str += `<br>${i18next.t('pollVotes', { voteCount: intlFormat.format(poll.total_votes), timeLeft: poll.time_left_en})}`;
str += `<br>${i18next.t('pollVotes', { voteCount: intlFormat.format(poll.total_votes), timeLeft: poll.time_left_en })}`;
return str;
};
@ -300,19 +305,20 @@ const generateStatus = (
<!-- Embed poll -->
${status.poll ? generatePoll(status.poll, status.lang ?? 'en') : notApplicableComment}
<!-- Embedded quote status -->
${!isQuote && status.quote ? generateStatus(status.quote, author, language, true, null) : notApplicableComment}`
.format({
quoteHeader: isQuote
? '<h4>' +
i18next.t('ivQuoteHeader').format({
url: status.url,
authorName: status.author.name,
authorHandle: status.author.screen_name,
authorURL: `${Constants.TWITTER_ROOT}/${status.author.screen_name}`
}) +
'</h4>'
: ''
});
${!isQuote && status.quote ? generateStatus(status.quote, author, language, true, null) : notApplicableComment}`.format(
{
quoteHeader: isQuote
? '<h4>' +
i18next.t('ivQuoteHeader').format({
url: status.url,
authorName: status.author.name,
authorHandle: status.author.screen_name,
authorURL: `${Constants.TWITTER_ROOT}/${status.author.screen_name}`
}) +
'</h4>'
: ''
}
);
};
export const renderInstantView = (properties: RenderProperties): ResponseInstructions => {
@ -322,8 +328,8 @@ export const renderInstantView = (properties: RenderProperties): ResponseInstruc
let previousThreadPieceAuthor: string | null = null;
let originalAuthor: string | null = null;
const useThread = thread?.thread ?? [ thread?.status ]
const useThread = thread?.thread ?? [thread?.status];
if (!status) {
throw new Error('Status is undefined');
@ -359,7 +365,8 @@ export const renderInstantView = (properties: RenderProperties): ResponseInstruc
<sub><a href="${status.url}">${i18next.t('ivViewOriginal')}</a></sub>
<h1>${status.author.name} (@${status.author.screen_name})</h1>
${useThread.map(status => {
${useThread
.map(status => {
console.log('previousThreadPieceAuthor', previousThreadPieceAuthor);
if (!status) {
return '';
@ -395,7 +402,13 @@ export const renderInstantView = (properties: RenderProperties): ResponseInstruc
previousThreadPieceAuthor = status.author?.id;
return generateStatus(status, status.author ?? thread?.author, properties?.targetLanguage ?? 'en', false, authorAction,);
return generateStatus(
status,
status.author ?? thread?.author,
properties?.targetLanguage ?? 'en',
false,
authorAction
);
})
.join('')}
${generateStatusFooter(status, false, thread?.author ?? status.author, properties?.targetLanguage ?? 'en')}

View file

@ -14,7 +14,9 @@ export const renderPhoto = (
const all = status.media?.all as APIMedia[];
const baseString =
all.length === status.media?.photos?.length ? i18next.t('photoCount') : i18next.t('mediaCount');
all.length === status.media?.photos?.length
? i18next.t('photoCount')
: i18next.t('mediaCount');
const photoCounter = baseString.format({
number: String(all.indexOf(photo) + 1),

View file

@ -33,7 +33,9 @@ export const renderVideo = (
we'll put an indicator if there are more than one video */
if (all && all.length > 1 && (userAgent?.indexOf('Telegram') ?? 0) > -1) {
const baseString =
all.length === status.media?.videos?.length ? i18next.t('videoCount') : i18next.t('mediaCount');
all.length === status.media?.videos?.length
? i18next.t('videoCount')
: i18next.t('mediaCount');
const videoCounter = baseString.format({
number: String(all.indexOf(video) + 1),
total: String(all.length)