Include Prettier & format everything properly

My bad for not including prettier
This commit is contained in:
Lim Chee Aun 2024-12-04 14:47:15 +08:00
parent 4c0bfc332c
commit e652ce8d9b
16 changed files with 145 additions and 138 deletions

13
package-lock.json generated
View file

@ -58,6 +58,7 @@
"postcss": "~8.4.49", "postcss": "~8.4.49",
"postcss-dark-theme-class": "~1.3.0", "postcss-dark-theme-class": "~1.3.0",
"postcss-preset-env": "~10.1.1", "postcss-preset-env": "~10.1.1",
"prettier": "3.4.1",
"sonda": "~0.6.1", "sonda": "~0.6.1",
"twitter-text": "~3.1.0", "twitter-text": "~3.1.0",
"vite": "~5.4.11", "vite": "~5.4.11",
@ -8406,17 +8407,15 @@
} }
}, },
"node_modules/prettier": { "node_modules/prettier": {
"version": "2.8.0", "version": "3.4.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.0.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.4.1.tgz",
"integrity": "sha512-9Lmg8hTFZKG0Asr/kW9Bp8tJjRVluO8EJQVfY2T7FMw9T5jy4I/Uvx0Rca/XWf50QQ1/SS48+6IJWnrb+2yemA==", "integrity": "sha512-G+YdqtITVZmOJje6QkXQWzl3fSfMxFwm1tjTyo9exhkmWSqC4Yhd1+lug++IlR2mvRVAxEDDWYkQdeSztajqgg==",
"dev": true, "dev": true,
"license": "MIT",
"peer": true,
"bin": { "bin": {
"prettier": "bin-prettier.js" "prettier": "bin/prettier.cjs"
}, },
"engines": { "engines": {
"node": ">=10.13.0" "node": ">=14"
}, },
"funding": { "funding": {
"url": "https://github.com/prettier/prettier?sponsor=1" "url": "https://github.com/prettier/prettier?sponsor=1"

View file

@ -66,6 +66,7 @@
"postcss": "~8.4.49", "postcss": "~8.4.49",
"postcss-dark-theme-class": "~1.3.0", "postcss-dark-theme-class": "~1.3.0",
"postcss-preset-env": "~10.1.1", "postcss-preset-env": "~10.1.1",
"prettier": "3.4.1",
"sonda": "~0.6.1", "sonda": "~0.6.1",
"twitter-text": "~3.1.0", "twitter-text": "~3.1.0",
"vite": "~5.4.11", "vite": "~5.4.11",

View file

@ -27,6 +27,7 @@ import SearchCommand from './components/search-command';
import Shortcuts from './components/shortcuts'; import Shortcuts from './components/shortcuts';
import NotFound from './pages/404'; import NotFound from './pages/404';
import AccountStatuses from './pages/account-statuses'; import AccountStatuses from './pages/account-statuses';
import AnnualReport from './pages/annual-report';
import Bookmarks from './pages/bookmarks'; import Bookmarks from './pages/bookmarks';
import Catchup from './pages/catchup'; import Catchup from './pages/catchup';
import Favourites from './pages/favourites'; import Favourites from './pages/favourites';
@ -46,7 +47,6 @@ import Search from './pages/search';
import StatusRoute from './pages/status-route'; import StatusRoute from './pages/status-route';
import Trending from './pages/trending'; import Trending from './pages/trending';
import Welcome from './pages/welcome'; import Welcome from './pages/welcome';
import AnnualReport from './pages/annual-report';
import { import {
api, api,
hasInstance, hasInstance,
@ -99,39 +99,42 @@ window.__STATES_STATS__ = () => {
// Experimental "garbage collection" for states // Experimental "garbage collection" for states
// Every 15 minutes // Every 15 minutes
// Only posts for now // Only posts for now
setInterval(() => { setInterval(
if (!window.__IDLE__) return; () => {
const { statuses, unfurledLinks, notifications } = states; if (!window.__IDLE__) return;
let keysCount = 0; const { statuses, unfurledLinks, notifications } = states;
const { instance } = api(); let keysCount = 0;
for (const key in statuses) { const { instance } = api();
if (!window.__IDLE__) break; for (const key in statuses) {
try { if (!window.__IDLE__) break;
const $post = document.querySelector( try {
`[data-state-post-id~="${key}"], [data-state-post-ids~="${key}"]`, const $post = document.querySelector(
); `[data-state-post-id~="${key}"], [data-state-post-ids~="${key}"]`,
const postInNotifications = notifications.some( );
(n) => key === statusKey(n.status?.id, instance), const postInNotifications = notifications.some(
); (n) => key === statusKey(n.status?.id, instance),
if (!$post && !postInNotifications) { );
delete states.statuses[key]; if (!$post && !postInNotifications) {
delete states.statusQuotes[key]; delete states.statuses[key];
for (const link in unfurledLinks) { delete states.statusQuotes[key];
const unfurled = unfurledLinks[link]; for (const link in unfurledLinks) {
const sKey = statusKey(unfurled.id, unfurled.instance); const unfurled = unfurledLinks[link];
if (sKey === key) { const sKey = statusKey(unfurled.id, unfurled.instance);
delete states.unfurledLinks[link]; if (sKey === key) {
break; delete states.unfurledLinks[link];
break;
}
} }
keysCount++;
} }
keysCount++; } catch (e) {}
} }
} catch (e) {} if (keysCount) {
} console.info(`GC: Removed ${keysCount} keys`);
if (keysCount) { }
console.info(`GC: Removed ${keysCount} keys`); },
} 15 * 60 * 1000,
}, 15 * 60 * 1000); );
// Preload icons // Preload icons
// There's probably a better way to do this // There's probably a better way to do this

View file

@ -1255,8 +1255,8 @@ function Compose({
replyToStatus replyToStatus
? t`Post your reply` ? t`Post your reply`
: editStatus : editStatus
? t`Edit your post` ? t`Edit your post`
: t`What are you doing?` : t`What are you doing?`
} }
required={mediaAttachments?.length === 0} required={mediaAttachments?.length === 0}
disabled={uiState === 'loading'} disabled={uiState === 'loading'}
@ -1554,11 +1554,11 @@ function Compose({
{replyToStatus {replyToStatus
? t`Reply` ? t`Reply`
: editStatus : editStatus
? t`Update` ? t`Update`
: t({ : t({
message: 'Post', message: 'Post',
context: 'Submit button in composer', context: 'Submit button in composer',
})} })}
</button> </button>
</div> </div>
</form> </form>
@ -2214,10 +2214,10 @@ function CharCountMeter({ maxCharacters = 500, hidden }) {
leftChars <= -10 leftChars <= -10
? 'explode' ? 'explode'
: leftChars <= 0 : leftChars <= 0
? 'danger' ? 'danger'
: leftChars <= 20 : leftChars <= 20
? 'warning' ? 'warning'
: '' : ''
}`} }`}
value={charCount} value={charCount}
max={maxCharacters} max={maxCharacters}
@ -2846,16 +2846,16 @@ function filterShortcodes(emojis, searchTerm) {
return bothStartWith return bothStartWith
? a.length - b.length ? a.length - b.length
: aStartsWith : aStartsWith
? -1 ? -1
: bStartsWith : bStartsWith
? 1 ? 1
: bothContain : bothContain
? a.length - b.length ? a.length - b.length
: aContains : aContains
? -1 ? -1
: bContains : bContains
? 1 ? 1
: 0; : 0;
}) })
.slice(0, 5); .slice(0, 5);
} }
@ -3516,8 +3516,8 @@ function GIFPickerModal({ onClose = () => {}, onSelect = () => {} }) {
const theImage = fixed_height_small?.url const theImage = fixed_height_small?.url
? fixed_height_small ? fixed_height_small
: fixed_height_downsampled?.url : fixed_height_downsampled?.url
? fixed_height_downsampled ? fixed_height_downsampled
: fixed_height; : fixed_height;
let { url, webp, width, height } = theImage; let { url, webp, width, height } = theImage;
if (+height > 100) { if (+height > 100) {
width = (width / height) * 100; width = (width / height) * 100;

View file

@ -17,8 +17,8 @@ function Menu2(props) {
? align === 'end' ? align === 'end'
? 'start' ? 'start'
: align === 'start' : align === 'start'
? 'end' ? 'end'
: align : align
: align; : align;
return ( return (

View file

@ -261,9 +261,7 @@ const contentText = {
), ),
emoji_reaction: emojiText, emoji_reaction: emojiText,
'pleroma:emoji_reaction': emojiText, 'pleroma:emoji_reaction': emojiText,
annual_report: ({ year }) => ( annual_report: ({ year }) => <Trans>Your {year} #Wrapstodon is here!</Trans>,
<Trans>Your {year} #Wrapstodon is here!</Trans>
),
}; };
// account_suspension, domain_block, user_domain_block // account_suspension, domain_block, user_domain_block
@ -537,7 +535,9 @@ function Notification({
)} )}
{type === 'annual_report' && ( {type === 'annual_report' && (
<div> <div>
<Link to={`/annual_report/${annualReport?.year}`}><Trans>View #Wrapstodon</Trans></Link> <Link to={`/annual_report/${annualReport?.year}`}>
<Trans>View #Wrapstodon</Trans>
</Link>
</div> </div>
)} )}
</> </>
@ -562,8 +562,8 @@ function Notification({
_accounts.length <= 10 _accounts.length <= 10
? 'xxl' ? 'xxl'
: _accounts.length < 20 : _accounts.length < 20
? 'xl' ? 'xl'
: 'l' : 'l'
} }
key={account.id} key={account.id}
alt={`${account.displayName} @${account.acct}`} alt={`${account.displayName} @${account.acct}`}
@ -606,8 +606,8 @@ function Notification({
const type = /^favourite/.test(key) const type = /^favourite/.test(key)
? 'favourite' ? 'favourite'
: /^reblog/.test(key) : /^reblog/.test(key)
? 'reblog' ? 'reblog'
: null; : null;
if (!type) continue; if (!type) continue;
for (const account of _accounts) { for (const account of _accounts) {
const theAccount = accounts.find( const theAccount = accounts.find(

View file

@ -996,8 +996,8 @@ function Status({
{reblogsCount > 0 {reblogsCount > 0
? shortenNumber(reblogsCount) ? shortenNumber(reblogsCount)
: reblogged : reblogged
? t`Unboost` ? t`Unboost`
: t`Boost…`} : t`Boost…`}
</span> </span>
</MenuConfirm> </MenuConfirm>
<MenuItem <MenuItem
@ -1009,8 +1009,8 @@ function Status({
{favouritesCount > 0 {favouritesCount > 0
? shortenNumber(favouritesCount) ? shortenNumber(favouritesCount)
: favourited : favourited
? t`Unlike` ? t`Unlike`
: t`Like`} : t`Like`}
</span> </span>
</MenuItem> </MenuItem>
{supports('@mastodon/post-bookmark') && ( {supports('@mastodon/post-bookmark') && (
@ -3167,8 +3167,8 @@ function generateHTMLCode(post, instance, level = 0) {
} else { } else {
mediaHTML = ` mediaHTML = `
<a href="${sourceMediaURL}">📄 ${ <a href="${sourceMediaURL}">📄 ${
description || sourceMediaURL description || sourceMediaURL
}</a> }</a>
`; `;
} }
@ -3625,12 +3625,12 @@ function FilteredStatus({
quoted quoted
? '' ? ''
: isReblog : isReblog
? group ? group
? 'status-group' ? 'status-group'
: 'status-reblog' : 'status-reblog'
: isFollowedTags : isFollowedTags
? 'status-followed-tags' ? 'status-followed-tags'
: '' : ''
} }
{...containerProps} {...containerProps}
// title={statusPeekText} // title={statusPeekText}

View file

@ -189,10 +189,10 @@ function TranslationBlock({
{uiState === 'loading' {uiState === 'loading'
? t`Translating…` ? t`Translating…`
: sourceLanguage && sourceLangText && !detectedLang : sourceLanguage && sourceLangText && !detectedLang
? autoDetected ? autoDetected
? t`Translate from ${sourceLangText} (auto-detected)` ? t`Translate from ${sourceLangText} (auto-detected)`
: t`Translate from ${sourceLangText}` : t`Translate from ${sourceLangText}`
: t`Translate`} : t`Translate`}
</span> </span>
</button> </button>
</summary> </summary>
@ -221,8 +221,8 @@ function TranslationBlock({
{l.code === 'auto' {l.code === 'auto'
? t`Auto (${detectedLang ?? '…'})` ? t`Auto (${detectedLang ?? '…'})`
: showCommon : showCommon
? `${native} - ${common}` ? `${native} - ${common}`
: native} : native}
</option> </option>
); );
})} })}

View file

@ -31,10 +31,10 @@ function App() {
editStatus editStatus
? t`Editing source status` ? t`Editing source status`
: replyToStatus : replyToStatus
? t`Replying to @${ ? t`Replying to @${
replyToStatus.account?.acct || replyToStatus.account?.username replyToStatus.account?.acct || replyToStatus.account?.username
}` }`
: t`Compose`, : t`Compose`,
); );
useEffect(() => { useEffect(() => {

42
src/locales/en.po generated
View file

@ -963,7 +963,7 @@ msgid "Nothing to show"
msgstr "" msgstr ""
#: src/components/generic-accounts.jsx:145 #: src/components/generic-accounts.jsx:145
#: src/components/notification.jsx:446 #: src/components/notification.jsx:444
#: src/pages/accounts.jsx:41 #: src/pages/accounts.jsx:41
#: src/pages/search.jsx:317 #: src/pages/search.jsx:317
#: src/pages/search.jsx:350 #: src/pages/search.jsx:350
@ -1472,78 +1472,78 @@ msgstr ""
msgid "Moderation warning" msgid "Moderation warning"
msgstr "" msgstr ""
#: src/components/notification.jsx:265 #: src/components/notification.jsx:264
msgid "Your {year} #Wrapstodon is here!" msgid "Your {year} #Wrapstodon is here!"
msgstr "Your {year} #Wrapstodon is here!" msgstr "Your {year} #Wrapstodon is here!"
#: src/components/notification.jsx:272 #: src/components/notification.jsx:270
msgid "An admin from <0>{from}</0> has suspended <1>{targetName}</1>, which means you can no longer receive updates from them or interact with them." msgid "An admin from <0>{from}</0> has suspended <1>{targetName}</1>, which means you can no longer receive updates from them or interact with them."
msgstr "" msgstr ""
#: src/components/notification.jsx:278 #: src/components/notification.jsx:276
msgid "An admin from <0>{from}</0> has blocked <1>{targetName}</1>. Affected followers: {followersCount}, followings: {followingCount}." msgid "An admin from <0>{from}</0> has blocked <1>{targetName}</1>. Affected followers: {followersCount}, followings: {followingCount}."
msgstr "" msgstr ""
#: src/components/notification.jsx:284 #: src/components/notification.jsx:282
msgid "You have blocked <0>{targetName}</0>. Removed followers: {followersCount}, followings: {followingCount}." msgid "You have blocked <0>{targetName}</0>. Removed followers: {followersCount}, followings: {followingCount}."
msgstr "" msgstr ""
#: src/components/notification.jsx:292 #: src/components/notification.jsx:290
msgid "Your account has received a moderation warning." msgid "Your account has received a moderation warning."
msgstr "" msgstr ""
#: src/components/notification.jsx:293 #: src/components/notification.jsx:291
msgid "Your account has been disabled." msgid "Your account has been disabled."
msgstr "" msgstr ""
#: src/components/notification.jsx:294 #: src/components/notification.jsx:292
msgid "Some of your posts have been marked as sensitive." msgid "Some of your posts have been marked as sensitive."
msgstr "" msgstr ""
#: src/components/notification.jsx:295 #: src/components/notification.jsx:293
msgid "Some of your posts have been deleted." msgid "Some of your posts have been deleted."
msgstr "" msgstr ""
#: src/components/notification.jsx:296 #: src/components/notification.jsx:294
msgid "Your posts will be marked as sensitive from now on." msgid "Your posts will be marked as sensitive from now on."
msgstr "" msgstr ""
#: src/components/notification.jsx:297 #: src/components/notification.jsx:295
msgid "Your account has been limited." msgid "Your account has been limited."
msgstr "" msgstr ""
#: src/components/notification.jsx:298 #: src/components/notification.jsx:296
msgid "Your account has been suspended." msgid "Your account has been suspended."
msgstr "" msgstr ""
#: src/components/notification.jsx:373 #: src/components/notification.jsx:371
msgid "[Unknown notification type: {type}]" msgid "[Unknown notification type: {type}]"
msgstr "" msgstr ""
#: src/components/notification.jsx:442 #: src/components/notification.jsx:440
#: src/components/status.jsx:1036 #: src/components/status.jsx:1036
#: src/components/status.jsx:1046 #: src/components/status.jsx:1046
msgid "Boosted/Liked by…" msgid "Boosted/Liked by…"
msgstr "" msgstr ""
#: src/components/notification.jsx:443 #: src/components/notification.jsx:441
msgid "Liked by…" msgid "Liked by…"
msgstr "" msgstr ""
#: src/components/notification.jsx:444 #: src/components/notification.jsx:442
msgid "Boosted by…" msgid "Boosted by…"
msgstr "" msgstr ""
#: src/components/notification.jsx:445 #: src/components/notification.jsx:443
msgid "Followed by…" msgid "Followed by…"
msgstr "" msgstr ""
#: src/components/notification.jsx:516 #: src/components/notification.jsx:514
#: src/components/notification.jsx:532 #: src/components/notification.jsx:530
msgid "Learn more <0/>" msgid "Learn more <0/>"
msgstr "" msgstr ""
#: src/components/notification.jsx:540 #: src/components/notification.jsx:539
msgid "View #Wrapstodon" msgid "View #Wrapstodon"
msgstr "View #Wrapstodon" msgstr "View #Wrapstodon"
@ -2410,7 +2410,7 @@ msgid "Login required."
msgstr "Login required." msgstr "Login required."
#: src/compose.jsx:90 #: src/compose.jsx:90
#: src/pages/annual-report.jsx:132 #: src/pages/annual-report.jsx:136
#: src/pages/http-route.jsx:91 #: src/pages/http-route.jsx:91
#: src/pages/login.jsx:270 #: src/pages/login.jsx:270
msgid "Go home" msgid "Go home"

View file

@ -64,7 +64,8 @@ export default function AnnualReport() {
<tr> <tr>
{Object.entries(item).map(([k, value]) => ( {Object.entries(item).map(([k, value]) => (
<td> <td>
{value && /(accountId)/i.test(k) && {value &&
/(accountId)/i.test(k) &&
/^(mostRebloggedAccounts|commonlyInteractedWithAccounts)$/i.test( /^(mostRebloggedAccounts|commonlyInteractedWithAccounts)$/i.test(
key, key,
) ? ( ) ? (
@ -90,14 +91,17 @@ export default function AnnualReport() {
<> <>
<dt>{k}</dt> <dt>{k}</dt>
<dd> <dd>
{value && {value && (
<Link to={`/${instance}/s/${value}`}> <Link to={`/${instance}/s/${value}`}>
<Status <Status
status={statuses?.find((s) => s.id === value)} status={statuses?.find(
size="s" (s) => s.id === value,
readOnly )}
/> size="s"
</Link>} readOnly
/>
</Link>
)}
</dd> </dd>
</> </>
))} ))}

View file

@ -1730,10 +1730,10 @@ const PostLine = memo(
group group
? 'group' ? 'group'
: reblog : reblog
? 'reblog' ? 'reblog'
: isFollowedTags?.length : isFollowedTags?.length
? 'followed-tags' ? 'followed-tags'
: '' : ''
} ${isReplyTo ? 'reply-to' : ''} ${ } ${isReplyTo ? 'reply-to' : ''} ${
isFiltered ? 'filtered' : '' isFiltered ? 'filtered' : ''
} visibility-${visibility}`} } visibility-${visibility}`}
@ -1826,8 +1826,8 @@ function postDensity(post) {
(mediaAttachments?.length (mediaAttachments?.length
? MEDIA_DENSITY * mediaAttachments.length ? MEDIA_DENSITY * mediaAttachments.length
: card?.image : card?.image
? CARD_DENSITY ? CARD_DENSITY
: 0); : 0);
return density; return density;
} }

View file

@ -55,8 +55,8 @@ function Hashtags({ media: mediaView, columnMode, ...props }) {
? t`${hashtagTitle} (Media only) on ${instance}` ? t`${hashtagTitle} (Media only) on ${instance}`
: t`${hashtagTitle} on ${instance}` : t`${hashtagTitle} on ${instance}`
: media : media
? t`${hashtagTitle} (Media only)` ? t`${hashtagTitle} (Media only)`
: t`${hashtagTitle}`; : t`${hashtagTitle}`;
useTitle(title, `/:instance?/t/:hashtag`); useTitle(title, `/:instance?/t/:hashtag`);
const latestItem = useRef(); const latestItem = useRef();

View file

@ -152,10 +152,10 @@ function Login() {
const selectedInstanceText = instanceTextLooksLikeDomain const selectedInstanceText = instanceTextLooksLikeDomain
? cleanInstanceText ? cleanInstanceText
: instancesSuggestions?.length : instancesSuggestions?.length
? instancesSuggestions[0] ? instancesSuggestions[0]
: instanceText : instanceText
? instancesList.find((instance) => instance.includes(instanceText)) ? instancesList.find((instance) => instance.includes(instanceText))
: null; : null;
const onSubmit = (e) => { const onSubmit = (e) => {
e.preventDefault(); e.preventDefault();

View file

@ -13,7 +13,7 @@ function escapeHTML(html) {
'&': '&amp;', '&': '&amp;',
'<': '&lt;', '<': '&lt;',
'>': '&gt;', '>': '&gt;',
}[c]), })[c],
); );
} }

View file

@ -26,7 +26,7 @@ function statusPeek(status) {
video: '📹', video: '📹',
audio: '🎵', audio: '🎵',
unknown: '', unknown: '',
}[m.type] || ''), })[m.type] || '',
) )
.join(''); .join('');
} }