Prettier-ify

This commit is contained in:
Lim Chee Aun 2024-10-14 19:38:09 +08:00
parent 5e4300f71d
commit e092e469d1
3 changed files with 107 additions and 102 deletions

View file

@ -228,7 +228,7 @@ function Compose({
const {
statuses: {
maxCharacters,
maxMediaAttachments, // Beware: it can be undefined!
maxMediaAttachments, // Beware: it can be undefined!
charactersReservedPerUrl,
} = {},
mediaAttachments: {
@ -607,7 +607,10 @@ function Compose({
const item = items[i];
if (item.kind === 'file') {
const file = item.getAsFile();
if (supportedMimeTypes !== undefined && !supportedMimeTypes.includes(file.type)) {
if (
supportedMimeTypes !== undefined &&
!supportedMimeTypes.includes(file.type)
) {
unsupportedFiles.push(file);
} else {
files.push(file);
@ -618,7 +621,9 @@ function Compose({
alert(
plural(unsupportedFiles.length, {
one: `File ${unsupportedFiles[0].name} is not supported.`,
other: `Files ${lf.format(unsupportedFiles.map(f => f.name))} are not supported.`,
other: `Files ${lf.format(
unsupportedFiles.map((f) => f.name),
)} are not supported.`,
}),
);
}
@ -637,10 +642,10 @@ function Compose({
e.stopPropagation();
// Auto-cut-off files to avoid exceeding maxMediaAttachments
let allowedFiles = files;
if(maxMediaAttachments !== undefined) {
if (maxMediaAttachments !== undefined) {
const max = maxMediaAttachments - mediaAttachments.length;
allowedFiles = allowedFiles.slice(0, max);
if(allowedFiles.length <= 0) {
if (allowedFiles.length <= 0) {
alert(
plural(maxMediaAttachments, {
one: 'You can only attach up to 1 file.',
@ -1324,7 +1329,10 @@ function Compose({
<input
type="file"
accept={supportedMimeTypes?.join(',')}
multiple={(maxMediaAttachments === undefined) || (maxMediaAttachments - mediaAttachments >= 2)}
multiple={
maxMediaAttachments === undefined ||
maxMediaAttachments - mediaAttachments >= 2
}
disabled={
uiState === 'loading' ||
mediaAttachments.length >= maxMediaAttachments ||
@ -1416,7 +1424,8 @@ function Compose({
class="toolbar-button gif-picker-button"
disabled={
uiState === 'loading' ||
(maxMediaAttachments !== undefined && mediaAttachments.length >= maxMediaAttachments) ||
(maxMediaAttachments !== undefined &&
mediaAttachments.length >= maxMediaAttachments) ||
!!poll
}
onClick={() => {

176
src/locales/en.po generated
View file

@ -105,7 +105,7 @@ msgstr ""
#: src/components/account-info.jsx:427
#: src/components/account-info.jsx:1115
#: src/components/compose.jsx:2479
#: src/components/compose.jsx:2488
#: src/components/media-alt-modal.jsx:45
#: src/components/media-modal.jsx:283
#: src/components/status.jsx:1703
@ -400,11 +400,11 @@ msgstr ""
#: src/components/account-info.jsx:1989
#: src/components/account-info.jsx:2089
#: src/components/account-sheet.jsx:37
#: src/components/compose.jsx:813
#: src/components/compose.jsx:2435
#: src/components/compose.jsx:2908
#: src/components/compose.jsx:3116
#: src/components/compose.jsx:3346
#: src/components/compose.jsx:818
#: src/components/compose.jsx:2444
#: src/components/compose.jsx:2917
#: src/components/compose.jsx:3125
#: src/components/compose.jsx:3355
#: src/components/drafts.jsx:58
#: src/components/embed-modal.jsx:12
#: src/components/generic-accounts.jsx:142
@ -545,135 +545,135 @@ msgstr ""
msgid "You have unsaved changes. Discard this post?"
msgstr ""
#: src/components/compose.jsx:619
#: src/components/compose.jsx:622
msgid "{0, plural, one {File {1} is not supported.} other {Files {2} are not supported.}}"
msgstr "{0, plural, one {File {1} is not supported.} other {Files {2} are not supported.}}"
#: src/components/compose.jsx:627
#: src/components/compose.jsx:645
#: src/components/compose.jsx:1353
#: src/components/compose.jsx:1614
#: src/components/compose.jsx:632
#: src/components/compose.jsx:650
#: src/components/compose.jsx:1361
#: src/components/compose.jsx:1623
msgid "{maxMediaAttachments, plural, one {You can only attach up to 1 file.} other {You can only attach up to # files.}}"
msgstr ""
#: src/components/compose.jsx:794
#: src/components/compose.jsx:799
msgid "Pop out"
msgstr ""
#: src/components/compose.jsx:801
#: src/components/compose.jsx:806
msgid "Minimize"
msgstr ""
#: src/components/compose.jsx:837
#: src/components/compose.jsx:842
msgid "Looks like you closed the parent window."
msgstr ""
#: src/components/compose.jsx:844
#: src/components/compose.jsx:849
msgid "Looks like you already have a compose field open in the parent window and currently publishing. Please wait for it to be done and try again later."
msgstr ""
#: src/components/compose.jsx:849
#: src/components/compose.jsx:854
msgid "Looks like you already have a compose field open in the parent window. Popping in this window will discard the changes you made in the parent window. Continue?"
msgstr ""
#: src/components/compose.jsx:891
#: src/components/compose.jsx:896
msgid "Pop in"
msgstr ""
#: src/components/compose.jsx:901
#: src/components/compose.jsx:906
msgid "Replying to @{0}s post (<0>{1}</0>)"
msgstr ""
#: src/components/compose.jsx:911
#: src/components/compose.jsx:916
msgid "Replying to @{0}s post"
msgstr ""
#: src/components/compose.jsx:924
#: src/components/compose.jsx:929
msgid "Editing source post"
msgstr ""
#: src/components/compose.jsx:971
#: src/components/compose.jsx:976
msgid "Poll must have at least 2 options"
msgstr ""
#: src/components/compose.jsx:975
#: src/components/compose.jsx:980
msgid "Some poll choices are empty"
msgstr ""
#: src/components/compose.jsx:988
#: src/components/compose.jsx:993
msgid "Some media have no descriptions. Continue?"
msgstr ""
#: src/components/compose.jsx:1040
#: src/components/compose.jsx:1045
msgid "Attachment #{i} failed"
msgstr ""
#: src/components/compose.jsx:1134
#: src/components/compose.jsx:1139
#: src/components/status.jsx:2029
#: src/components/timeline.jsx:984
msgid "Content warning"
msgstr ""
#: src/components/compose.jsx:1150
#: src/components/compose.jsx:1155
msgid "Content warning or sensitive media"
msgstr ""
#: src/components/compose.jsx:1186
#: src/components/compose.jsx:1191
#: src/components/status.jsx:93
#: src/pages/settings.jsx:304
msgid "Public"
msgstr ""
#: src/components/compose.jsx:1191
#: src/components/compose.jsx:1196
#: src/components/nav-menu.jsx:386
#: src/components/shortcuts-settings.jsx:162
#: src/components/status.jsx:94
msgid "Local"
msgstr ""
#: src/components/compose.jsx:1195
#: src/components/compose.jsx:1200
#: src/components/status.jsx:95
#: src/pages/settings.jsx:307
msgid "Unlisted"
msgstr ""
#: src/components/compose.jsx:1198
#: src/components/compose.jsx:1203
#: src/components/status.jsx:96
#: src/pages/settings.jsx:310
msgid "Followers only"
msgstr ""
#: src/components/compose.jsx:1201
#: src/components/compose.jsx:1206
#: src/components/status.jsx:97
#: src/components/status.jsx:1907
msgid "Private mention"
msgstr ""
#: src/components/compose.jsx:1210
#: src/components/compose.jsx:1215
msgid "Post your reply"
msgstr ""
#: src/components/compose.jsx:1212
#: src/components/compose.jsx:1217
msgid "Edit your post"
msgstr ""
#: src/components/compose.jsx:1213
#: src/components/compose.jsx:1218
msgid "What are you doing?"
msgstr ""
#: src/components/compose.jsx:1291
#: src/components/compose.jsx:1296
msgid "Mark media as sensitive"
msgstr ""
#: src/components/compose.jsx:1389
#: src/components/compose.jsx:1397
msgid "Add poll"
msgstr ""
#: src/components/compose.jsx:1411
#: src/components/compose.jsx:1419
msgid "Add custom emoji"
msgstr ""
#: src/components/compose.jsx:1495
#: src/components/compose.jsx:1504
#: src/components/keyboard-shortcuts-help.jsx:143
#: src/components/status.jsx:895
#: src/components/status.jsx:1683
@ -682,195 +682,195 @@ msgstr ""
msgid "Reply"
msgstr ""
#: src/components/compose.jsx:1497
#: src/components/compose.jsx:1506
msgid "Update"
msgstr ""
#: src/components/compose.jsx:1498
#: src/components/compose.jsx:1507
msgctxt "Submit button in composer"
msgid "Post"
msgstr ""
#: src/components/compose.jsx:1626
#: src/components/compose.jsx:1635
msgid "Downloading GIF…"
msgstr ""
#: src/components/compose.jsx:1654
#: src/components/compose.jsx:1663
msgid "Failed to download GIF"
msgstr ""
#: src/components/compose.jsx:1766
#: src/components/compose.jsx:1843
#: src/components/compose.jsx:1775
#: src/components/compose.jsx:1852
#: src/components/nav-menu.jsx:287
msgid "More…"
msgstr ""
#: src/components/compose.jsx:2248
#: src/components/compose.jsx:2257
msgid "Uploaded"
msgstr ""
#: src/components/compose.jsx:2261
#: src/components/compose.jsx:2270
msgid "Image description"
msgstr ""
#: src/components/compose.jsx:2262
#: src/components/compose.jsx:2271
msgid "Video description"
msgstr ""
#: src/components/compose.jsx:2263
#: src/components/compose.jsx:2272
msgid "Audio description"
msgstr ""
#: src/components/compose.jsx:2299
#: src/components/compose.jsx:2319
#: src/components/compose.jsx:2308
#: src/components/compose.jsx:2328
msgid "File size too large. Uploading might encounter issues. Try reduce the file size from {0} to {1} or lower."
msgstr ""
#: src/components/compose.jsx:2311
#: src/components/compose.jsx:2331
#: src/components/compose.jsx:2320
#: src/components/compose.jsx:2340
msgid "Dimension too large. Uploading might encounter issues. Try reduce dimension from {0}×{1}px to {2}×{3}px."
msgstr ""
#: src/components/compose.jsx:2339
#: src/components/compose.jsx:2348
msgid "Frame rate too high. Uploading might encounter issues."
msgstr ""
#: src/components/compose.jsx:2399
#: src/components/compose.jsx:2649
#: src/components/compose.jsx:2408
#: src/components/compose.jsx:2658
#: src/components/shortcuts-settings.jsx:723
#: src/pages/catchup.jsx:1074
#: src/pages/filters.jsx:412
msgid "Remove"
msgstr ""
#: src/components/compose.jsx:2416
#: src/components/compose.jsx:2425
#: src/compose.jsx:83
msgid "Error"
msgstr ""
#: src/components/compose.jsx:2441
#: src/components/compose.jsx:2450
msgid "Edit image description"
msgstr ""
#: src/components/compose.jsx:2442
#: src/components/compose.jsx:2451
msgid "Edit video description"
msgstr ""
#: src/components/compose.jsx:2443
#: src/components/compose.jsx:2452
msgid "Edit audio description"
msgstr ""
#: src/components/compose.jsx:2488
#: src/components/compose.jsx:2537
#: src/components/compose.jsx:2497
#: src/components/compose.jsx:2546
msgid "Generating description. Please wait…"
msgstr ""
#: src/components/compose.jsx:2508
#: src/components/compose.jsx:2517
msgid "Failed to generate description: {0}"
msgstr ""
#: src/components/compose.jsx:2509
#: src/components/compose.jsx:2518
msgid "Failed to generate description"
msgstr ""
#: src/components/compose.jsx:2521
#: src/components/compose.jsx:2527
#: src/components/compose.jsx:2573
#: src/components/compose.jsx:2530
#: src/components/compose.jsx:2536
#: src/components/compose.jsx:2582
msgid "Generate description…"
msgstr ""
#: src/components/compose.jsx:2560
#: src/components/compose.jsx:2569
msgid "Failed to generate description{0}"
msgstr ""
#: src/components/compose.jsx:2575
#: src/components/compose.jsx:2584
msgid "({0}) <0>— experimental</0>"
msgstr ""
#: src/components/compose.jsx:2594
#: src/components/compose.jsx:2603
msgid "Done"
msgstr ""
#: src/components/compose.jsx:2630
#: src/components/compose.jsx:2639
msgid "Choice {0}"
msgstr ""
#: src/components/compose.jsx:2677
#: src/components/compose.jsx:2686
msgid "Multiple choices"
msgstr ""
#: src/components/compose.jsx:2680
#: src/components/compose.jsx:2689
msgid "Duration"
msgstr ""
#: src/components/compose.jsx:2711
#: src/components/compose.jsx:2720
msgid "Remove poll"
msgstr ""
#: src/components/compose.jsx:2925
#: src/components/compose.jsx:2934
msgid "Search accounts"
msgstr ""
#: src/components/compose.jsx:2966
#: src/components/compose.jsx:2975
#: src/components/shortcuts-settings.jsx:712
#: src/pages/list.jsx:359
msgid "Add"
msgstr ""
#: src/components/compose.jsx:2979
#: src/components/compose.jsx:2988
#: src/components/generic-accounts.jsx:227
msgid "Error loading accounts"
msgstr ""
#: src/components/compose.jsx:3122
#: src/components/compose.jsx:3131
msgid "Custom emojis"
msgstr ""
#: src/components/compose.jsx:3142
#: src/components/compose.jsx:3151
msgid "Search emoji"
msgstr ""
#: src/components/compose.jsx:3173
#: src/components/compose.jsx:3182
msgid "Error loading custom emojis"
msgstr ""
#: src/components/compose.jsx:3184
#: src/components/compose.jsx:3193
msgid "Recently used"
msgstr ""
#: src/components/compose.jsx:3185
#: src/components/compose.jsx:3194
msgid "Others"
msgstr ""
#: src/components/compose.jsx:3223
#: src/components/compose.jsx:3232
msgid "{0} more…"
msgstr ""
#: src/components/compose.jsx:3361
#: src/components/compose.jsx:3370
msgid "Search GIFs"
msgstr ""
#: src/components/compose.jsx:3376
#: src/components/compose.jsx:3385
msgid "Powered by GIPHY"
msgstr ""
#: src/components/compose.jsx:3384
#: src/components/compose.jsx:3393
msgid "Type to search GIFs"
msgstr ""
#: src/components/compose.jsx:3482
#: src/components/compose.jsx:3491
#: src/components/media-modal.jsx:387
#: src/components/timeline.jsx:889
msgid "Previous"
msgstr ""
#: src/components/compose.jsx:3500
#: src/components/compose.jsx:3509
#: src/components/media-modal.jsx:406
#: src/components/timeline.jsx:906
msgid "Next"
msgstr ""
#: src/components/compose.jsx:3517
#: src/components/compose.jsx:3526
msgid "Error loading GIFs"
msgstr ""

View file

@ -118,18 +118,14 @@ export function getCurrentInstance() {
// Massage these instance configurations to match the Mastodon API
// - Pleroma
function getInstanceConfiguration(instance) {
const {
configuration,
maxMediaAttachments,
maxTootChars,
pollLimits,
} = instance;
const { configuration, maxMediaAttachments, maxTootChars, pollLimits } =
instance;
const statuses = configuration?.statuses || {};
if (maxMediaAttachments) {
statuses.maxMediaAttachments ??= maxMediaAttachments;
}
if (maxTootChars) {
statuses.maxCharacters ??= maxTootChars;
}