Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release - 2021-12-09 #1823

Merged
merged 4 commits into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
closes #

---

Submission checklist:

<!-- Remove anything below that is not applicable -->

#### Layout
- [] Change looks good in the desktop web ui
- - [] Change looks good in the mobile web ui
- [ ] Change looks good in the desktop web ui
- [ ] Change looks good in the mobile web ui

#### Theme
- [] Components / elements inspected in light mode
- [] Components / elements inspected in dark mode
- [ ] Components / elements inspected in light mode
- [ ] Components / elements inspected in dark mode
17 changes: 12 additions & 5 deletions packages/files-ui/src/Contexts/FilesContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -497,17 +497,20 @@ const FilesProvider = ({ children }: FilesContextProps) => {
): Promise<FileSystemItemPath[]> => {
return await itemsToDownload.reduce(
async (acc: Promise<FileSystemItemPath[]>, item: FileSystemItem): Promise<FileSystemItemPath[]> => {
// this is needed to make sure the reduce is sequential
const accP = await acc

if (item.isFolder) {
const folderPath = getPathWithFile(currentPath, item.name)
const newList = await filesApiClient.getBucketObjectChildrenList(bucketId, { path: folderPath })

const childFolderItems = newList.map(parseFileContentResponse)
return childFolderItems.length
? [...await acc, ...await getFileList(childFolderItems, folderPath, bucketId)]
? [...accP, ...await getFileList(childFolderItems, folderPath, bucketId)]
: Promise.resolve(acc)
}

return [...await acc, { ...item, path: currentPath }]
return [...accP, { ...item, path: currentPath }]
}, Promise.resolve([] as FileSystemItemPath[]))
}, [filesApiClient])

Expand Down Expand Up @@ -549,6 +552,9 @@ const FilesProvider = ({ children }: FilesContextProps) => {
// Idea for parallel download https://glebbahmutov.com/blog/run-n-promises-in-parallel/
// we need to use a reduce here because forEach doesn't wait for the Promise to resolve
await fullStructure.reduce(async (totalDownloaded: Promise<number>, item: FileSystemItemPath, index: number): Promise<number> => {
// this is needed to make sure the reduce is sequential
const totalP = await totalDownloaded

const file = await getFileContent(bucketId, {
cid: item.cid,
file: item,
Expand All @@ -561,7 +567,7 @@ const FilesProvider = ({ children }: FilesContextProps) => {
...toastParams,
title: t`Downloading ${fileProgress} - ${item.name}`,
progress: Math.ceil(
((await totalDownloaded + progressEvent.loaded) / totalFileSize) * 100
((totalP + progressEvent.loaded) / totalFileSize) * 100
)
})
}
Expand All @@ -573,8 +579,7 @@ const FilesProvider = ({ children }: FilesContextProps) => {
const relativeFilePath = getRelativePath(fullPath, currentPath)
zipList[relativeFilePath] = new Uint8Array(fileArrayBuffer)
}

return await totalDownloaded + item.size
return totalP + item.size
}, Promise.resolve(0))

// level 0 means without compression
Expand Down Expand Up @@ -789,8 +794,10 @@ const FilesProvider = ({ children }: FilesContextProps) => {

try {
await allItems.reduce(async (totalProgress: Promise<number>, item, i) => {
// this is needed to make sure the reduce is sequential
const previousProgress = await totalProgress
const fileProgress = `${i + 1}/${totalFileNumber}`

try {
const file = await getFileContent(sourceBucket.id, {
cid: item.cid,
Expand Down
2 changes: 1 addition & 1 deletion packages/files-ui/src/locales/fr/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ msgstr ""
"Mime-Version: 1.0\n"

msgid "({0}) items selected"
msgstr ""
msgstr "({0}) éléments sélectionnés"

msgid "A backup secret phrase will be generated and used for your account.<0/>We do not store it and <1>it can only be displayed once</1>. Save it somewhere safe!"
msgstr "Une phrase secrète de sauvegarde sera générée et utilisé pour ce compte.<0/>Nous ne la sauvergardons pas <1>elle ne peut être affichée qu’une seule fois</1>. Gardez-la dans un endroit sûr !"
Expand Down