Skip to content

Commit d2057bd

Browse files
Merge pull request #51419 from nextcloud/backport/51031/stable31
[stable31] fix(singularandpluralfiles):implemented ternary operator to handle si…
2 parents b95d300 + 0314ccd commit d2057bd

File tree

3 files changed

+11
-18
lines changed

3 files changed

+11
-18
lines changed

apps/files/src/actions/convertUtils.ts

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { OCSResponse } from '@nextcloud/typings/ocs'
88
import { emit } from '@nextcloud/event-bus'
99
import { generateOcsUrl } from '@nextcloud/router'
1010
import { showError, showLoading, showSuccess } from '@nextcloud/dialogs'
11-
import { t } from '@nextcloud/l10n'
11+
import { n, t } from '@nextcloud/l10n'
1212
import axios, { isAxiosError } from '@nextcloud/axios'
1313
import PQueue from 'p-queue'
1414

@@ -21,8 +21,8 @@ type ConversionResponse = {
2121
}
2222

2323
interface PromiseRejectedResult<T> {
24-
status: 'rejected'
25-
reason: T
24+
status: 'rejected'
25+
reason: T
2626
}
2727

2828
type PromiseSettledResult<T, E> = PromiseFulfilledResult<T> | PromiseRejectedResult<E>;
@@ -62,23 +62,16 @@ export const convertFiles = async function(fileIds: number[], targetMimeType: st
6262
return
6363
}
6464

65-
// A single file failed
66-
if (failed.length === 1) {
67-
// If we have a message for the failed file, show it
68-
if (messages[0]) {
69-
showError(t('files', 'One file could not be converted: {message}', { message: messages[0] }))
70-
return
71-
}
72-
73-
// Otherwise, show a generic error
74-
showError(t('files', 'One file could not be converted'))
65+
// A single file failed and if we have a message for the failed file, show it
66+
if (failed.length === 1 && messages[0]) {
67+
showError(t('files', 'One file could not be converted: {message}', { message: messages[0] }))
7568
return
7669
}
7770

7871
// We already check above when all files failed
7972
// if we're here, we have a mix of failed and successful files
80-
showError(t('files', '{count} files could not be converted', { count: failed.length }))
81-
showSuccess(t('files', '{count} files successfully converted', { count: fileIds.length - failed.length }))
73+
showError(n('files', 'One file could not be converted', '%n files could not be converted', failed.length))
74+
showSuccess(n('files', 'One file successfully converted', '%n files successfully converted', fileIds.length - failed.length))
8275
return
8376
}
8477

dist/files-init.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/files-init.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)