mirror of
https://github.com/CompeyDev/fxtwitter-docker.git
synced 2025-05-04 10:43:49 +01:00
Run prettier
This commit is contained in:
parent
8a8bf14a16
commit
54507d077c
5 changed files with 46 additions and 29 deletions
|
@ -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 => {
|
||||
|
|
|
@ -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
|
||||
});
|
||||
|
||||
|
@ -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);
|
||||
|
@ -300,8 +305,8 @@ 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({
|
||||
${!isQuote && status.quote ? generateStatus(status.quote, author, language, true, null) : notApplicableComment}`.format(
|
||||
{
|
||||
quoteHeader: isQuote
|
||||
? '<h4>' +
|
||||
i18next.t('ivQuoteHeader').format({
|
||||
|
@ -312,7 +317,8 @@ const generateStatus = (
|
|||
}) +
|
||||
'</h4>'
|
||||
: ''
|
||||
});
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
export const renderInstantView = (properties: RenderProperties): ResponseInstructions => {
|
||||
|
@ -323,7 +329,7 @@ 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')}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Add table
Reference in a new issue