Skip to content

Commit

Permalink
Include Prettier & format everything properly
Browse files Browse the repository at this point in the history
My bad for not including prettier
  • Loading branch information
cheeaun committed Dec 4, 2024
1 parent 4c0bfc3 commit e652ce8
Show file tree
Hide file tree
Showing 16 changed files with 145 additions and 138 deletions.
13 changes: 6 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"postcss": "~8.4.49",
"postcss-dark-theme-class": "~1.3.0",
"postcss-preset-env": "~10.1.1",
"prettier": "3.4.1",
"sonda": "~0.6.1",
"twitter-text": "~3.1.0",
"vite": "~5.4.11",
Expand Down
67 changes: 35 additions & 32 deletions src/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import SearchCommand from './components/search-command';
import Shortcuts from './components/shortcuts';
import NotFound from './pages/404';
import AccountStatuses from './pages/account-statuses';
import AnnualReport from './pages/annual-report';
import Bookmarks from './pages/bookmarks';
import Catchup from './pages/catchup';
import Favourites from './pages/favourites';
Expand All @@ -46,7 +47,6 @@ import Search from './pages/search';
import StatusRoute from './pages/status-route';
import Trending from './pages/trending';
import Welcome from './pages/welcome';
import AnnualReport from './pages/annual-report';
import {
api,
hasInstance,
Expand Down Expand Up @@ -99,39 +99,42 @@ window.__STATES_STATS__ = () => {
// Experimental "garbage collection" for states
// Every 15 minutes
// Only posts for now
setInterval(() => {
if (!window.__IDLE__) return;
const { statuses, unfurledLinks, notifications } = states;
let keysCount = 0;
const { instance } = api();
for (const key in statuses) {
if (!window.__IDLE__) break;
try {
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),
);
if (!$post && !postInNotifications) {
delete states.statuses[key];
delete states.statusQuotes[key];
for (const link in unfurledLinks) {
const unfurled = unfurledLinks[link];
const sKey = statusKey(unfurled.id, unfurled.instance);
if (sKey === key) {
delete states.unfurledLinks[link];
break;
setInterval(
() => {
if (!window.__IDLE__) return;
const { statuses, unfurledLinks, notifications } = states;
let keysCount = 0;
const { instance } = api();
for (const key in statuses) {
if (!window.__IDLE__) break;
try {
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),
);
if (!$post && !postInNotifications) {
delete states.statuses[key];
delete states.statusQuotes[key];
for (const link in unfurledLinks) {
const unfurled = unfurledLinks[link];
const sKey = statusKey(unfurled.id, unfurled.instance);
if (sKey === key) {
delete states.unfurledLinks[link];
break;
}
}
keysCount++;
}
keysCount++;
}
} catch (e) {}
}
if (keysCount) {
console.info(`GC: Removed ${keysCount} keys`);
}
}, 15 * 60 * 1000);
} catch (e) {}
}
if (keysCount) {
console.info(`GC: Removed ${keysCount} keys`);
}
},
15 * 60 * 1000,
);

// Preload icons
// There's probably a better way to do this
Expand Down
46 changes: 23 additions & 23 deletions src/components/compose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1255,8 +1255,8 @@ function Compose({
replyToStatus
? t`Post your reply`
: editStatus
? t`Edit your post`
: t`What are you doing?`
? t`Edit your post`
: t`What are you doing?`
}
required={mediaAttachments?.length === 0}
disabled={uiState === 'loading'}
Expand Down Expand Up @@ -1554,11 +1554,11 @@ function Compose({
{replyToStatus
? t`Reply`
: editStatus
? t`Update`
: t({
message: 'Post',
context: 'Submit button in composer',
})}
? t`Update`
: t({
message: 'Post',
context: 'Submit button in composer',
})}
</button>
</div>
</form>
Expand Down Expand Up @@ -2214,10 +2214,10 @@ function CharCountMeter({ maxCharacters = 500, hidden }) {
leftChars <= -10
? 'explode'
: leftChars <= 0
? 'danger'
: leftChars <= 20
? 'warning'
: ''
? 'danger'
: leftChars <= 20
? 'warning'
: ''
}`}
value={charCount}
max={maxCharacters}
Expand Down Expand Up @@ -2846,16 +2846,16 @@ function filterShortcodes(emojis, searchTerm) {
return bothStartWith
? a.length - b.length
: aStartsWith
? -1
: bStartsWith
? 1
: bothContain
? a.length - b.length
: aContains
? -1
: bContains
? 1
: 0;
? -1
: bStartsWith
? 1
: bothContain
? a.length - b.length
: aContains
? -1
: bContains
? 1
: 0;
})
.slice(0, 5);
}
Expand Down Expand Up @@ -3516,8 +3516,8 @@ function GIFPickerModal({ onClose = () => {}, onSelect = () => {} }) {
const theImage = fixed_height_small?.url
? fixed_height_small
: fixed_height_downsampled?.url
? fixed_height_downsampled
: fixed_height;
? fixed_height_downsampled
: fixed_height;
let { url, webp, width, height } = theImage;
if (+height > 100) {
width = (width / height) * 100;
Expand Down
4 changes: 2 additions & 2 deletions src/components/menu2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ function Menu2(props) {
? align === 'end'
? 'start'
: align === 'start'
? 'end'
: align
? 'end'
: align
: align;

return (
Expand Down
16 changes: 8 additions & 8 deletions src/components/notification.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,7 @@ const contentText = {
),
emoji_reaction: emojiText,
'pleroma:emoji_reaction': emojiText,
annual_report: ({ year }) => (
<Trans>Your {year} #Wrapstodon is here!</Trans>
),
annual_report: ({ year }) => <Trans>Your {year} #Wrapstodon is here!</Trans>,
};

// account_suspension, domain_block, user_domain_block
Expand Down Expand Up @@ -537,7 +535,9 @@ function Notification({
)}
{type === 'annual_report' && (
<div>
<Link to={`/annual_report/${annualReport?.year}`}><Trans>View #Wrapstodon</Trans></Link>
<Link to={`/annual_report/${annualReport?.year}`}>
<Trans>View #Wrapstodon</Trans>
</Link>
</div>
)}
</>
Expand All @@ -562,8 +562,8 @@ function Notification({
_accounts.length <= 10
? 'xxl'
: _accounts.length < 20
? 'xl'
: 'l'
? 'xl'
: 'l'
}
key={account.id}
alt={`${account.displayName} @${account.acct}`}
Expand Down Expand Up @@ -606,8 +606,8 @@ function Notification({
const type = /^favourite/.test(key)
? 'favourite'
: /^reblog/.test(key)
? 'reblog'
: null;
? 'reblog'
: null;
if (!type) continue;
for (const account of _accounts) {
const theAccount = accounts.find(
Expand Down
24 changes: 12 additions & 12 deletions src/components/status.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -996,8 +996,8 @@ function Status({
{reblogsCount > 0
? shortenNumber(reblogsCount)
: reblogged
? t`Unboost`
: t`Boost…`}
? t`Unboost`
: t`Boost…`}
</span>
</MenuConfirm>
<MenuItem
Expand All @@ -1009,8 +1009,8 @@ function Status({
{favouritesCount > 0
? shortenNumber(favouritesCount)
: favourited
? t`Unlike`
: t`Like`}
? t`Unlike`
: t`Like`}
</span>
</MenuItem>
{supports('@mastodon/post-bookmark') && (
Expand Down Expand Up @@ -3167,8 +3167,8 @@ function generateHTMLCode(post, instance, level = 0) {
} else {
mediaHTML = `
<a href="${sourceMediaURL}">📄 ${
description || sourceMediaURL
}</a>
description || sourceMediaURL
}</a>
`;
}

Expand Down Expand Up @@ -3625,12 +3625,12 @@ function FilteredStatus({
quoted
? ''
: isReblog
? group
? 'status-group'
: 'status-reblog'
: isFollowedTags
? 'status-followed-tags'
: ''
? group
? 'status-group'
: 'status-reblog'
: isFollowedTags
? 'status-followed-tags'
: ''
}
{...containerProps}
// title={statusPeekText}
Expand Down
12 changes: 6 additions & 6 deletions src/components/translation-block.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,10 @@ function TranslationBlock({
{uiState === 'loading'
? t`Translating…`
: sourceLanguage && sourceLangText && !detectedLang
? autoDetected
? t`Translate from ${sourceLangText} (auto-detected)`
: t`Translate from ${sourceLangText}`
: t`Translate`}
? autoDetected
? t`Translate from ${sourceLangText} (auto-detected)`
: t`Translate from ${sourceLangText}`
: t`Translate`}
</span>
</button>
</summary>
Expand Down Expand Up @@ -221,8 +221,8 @@ function TranslationBlock({
{l.code === 'auto'
? t`Auto (${detectedLang ?? '…'})`
: showCommon
? `${native} - ${common}`
: native}
? `${native} - ${common}`
: native}
</option>
);
})}
Expand Down
8 changes: 4 additions & 4 deletions src/compose.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ function App() {
editStatus
? t`Editing source status`
: replyToStatus
? t`Replying to @${
replyToStatus.account?.acct || replyToStatus.account?.username
}`
: t`Compose`,
? t`Replying to @${
replyToStatus.account?.acct || replyToStatus.account?.username
}`
: t`Compose`,
);

useEffect(() => {
Expand Down
Loading

0 comments on commit e652ce8

Please sign in to comment.