-
Notifications
You must be signed in to change notification settings - Fork 2k
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
@uppy/core: make getObjectOfFilesPerState more efficient #5155
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Diff output filesdiff --git a/packages/@uppy/core/lib/Uppy.js b/packages/@uppy/core/lib/Uppy.js
index 7ec8f0f..83a1b27 100644
--- a/packages/@uppy/core/lib/Uppy.js
+++ b/packages/@uppy/core/lib/Uppy.js
@@ -417,22 +417,47 @@ export class Uppy {
error,
} = this.getState();
const files = Object.values(filesObject);
- const inProgressFiles = files.filter(_ref2 => {
- let {
+ const inProgressFiles = [];
+ const newFiles = [];
+ const startedFiles = [];
+ const uploadStartedFiles = [];
+ const pausedFiles = [];
+ const completeFiles = [];
+ const erroredFiles = [];
+ const inProgressNotPausedFiles = [];
+ const processingFiles = [];
+ for (const file of files) {
+ const {
progress,
- } = _ref2;
- return !progress.uploadComplete && progress.uploadStarted;
- });
- const newFiles = files.filter(file => !file.progress.uploadStarted);
- const startedFiles = files.filter(file =>
- file.progress.uploadStarted || file.progress.preprocess || file.progress.postprocess
- );
- const uploadStartedFiles = files.filter(file => file.progress.uploadStarted);
- const pausedFiles = files.filter(file => file.isPaused);
- const completeFiles = files.filter(file => file.progress.uploadComplete);
- const erroredFiles = files.filter(file => file.error);
- const inProgressNotPausedFiles = inProgressFiles.filter(file => !file.isPaused);
- const processingFiles = files.filter(file => file.progress.preprocess || file.progress.postprocess);
+ } = file;
+ if (!progress.uploadComplete && progress.uploadStarted) {
+ inProgressFiles.push(file);
+ if (!file.isPaused) {
+ inProgressNotPausedFiles.push(file);
+ }
+ }
+ if (!progress.uploadStarted) {
+ newFiles.push(file);
+ }
+ if (progress.uploadStarted || progress.preprocess || progress.postprocess) {
+ startedFiles.push(file);
+ }
+ if (progress.uploadStarted) {
+ uploadStartedFiles.push(file);
+ }
+ if (file.isPaused) {
+ pausedFiles.push(file);
+ }
+ if (progress.uploadComplete) {
+ completeFiles.push(file);
+ }
+ if (file.error) {
+ erroredFiles.push(file);
+ }
+ if (progress.preprocess || progress.postprocess) {
+ processingFiles.push(file);
+ }
+ }
return {
newFiles,
startedFiles,
@@ -1030,11 +1055,11 @@ function _informAndEmit2(errors) {
const maxNumToShow = 4;
const firstErrors = userFacingErrors.slice(0, maxNumToShow);
const additionalErrors = userFacingErrors.slice(maxNumToShow);
- firstErrors.forEach(_ref3 => {
+ firstErrors.forEach(_ref2 => {
let {
message,
details = "",
- } = _ref3;
+ } = _ref2;
this.info(
{
message, |
aduh95
approved these changes
May 8, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Too bad for readability, but I get why we'd want to do that
github-actions bot
added a commit
that referenced
this pull request
May 14, 2024
| Package | Version | Package | Version | | ------------------ | ------- | ------------------ | ------- | | @uppy/core | 3.11.3 | uppy | 3.25.3 | | @uppy/image-editor | 2.4.6 | | | - @uppy/image-editor: fix tooltips (Avneet Singh Malhotra / #5156) - meta: Remove redundant `plugins` prop from examples (Merlijn Vos / #5145) - @uppy/image-editor: Remove `target` option from examples and document consistently (Merlijn Vos / #5146) - @uppy/core: make getObjectOfFilesPerState more efficient (Merlijn Vos / #5155)
Murderlon
added a commit
that referenced
this pull request
May 14, 2024
* commit '86e2e6750192055bfba24abf62e227976be5e085': Release: [email protected] (#5161) @uppy/image-editor: fix tooltips (#5156) Remove redundant `plugins` prop from examples (#5145) Remove `target` option from examples and document consistently (#5146) @uppy/core: make getObjectOfFilesPerState more efficient (#5155) Release: [email protected] (#5151) Upgrade @transloadit/prettier-bytes (#5150)
github-actions bot
added a commit
that referenced
this pull request
May 14, 2024
| Package | Version | Package | Version | | ---------------------- | ------------ | ---------------------- | ------------ | | @uppy/companion | 5.0.0-beta.6 | @uppy/status-bar | 4.0.0-beta.7 | | @uppy/companion-client | 4.0.0-beta.6 | @uppy/unsplash | 4.0.0-beta.6 | | @uppy/compressor | 2.0.0-beta.7 | @uppy/url | 4.0.0-beta.6 | | @uppy/core | 4.0.0-beta.7 | @uppy/utils | 6.0.0-beta.6 | | @uppy/dashboard | 4.0.0-beta.7 | @uppy/webcam | 4.0.0-beta.6 | | @uppy/dropbox | 4.0.0-beta.6 | @uppy/xhr-upload | 4.0.0-beta.4 | | @uppy/image-editor | 3.0.0-beta.4 | uppy | 4.0.0-beta.7 | | @uppy/screen-capture | 4.0.0-beta.5 | | | - @uppy/companion: switch from `node-redis` to `ioredis` (Dominik Schmidt / #4623) - meta: Fix headings in xhr.mdx (Merlijn Vos) - @uppy/xhr-upload: introduce hooks similar to tus (Merlijn Vos / #5094) - @uppy/core: close->destroy, clearUploadedFiles->clear (Merlijn Vos / #5154) - @uppy/companion-client,@uppy/dropbox,@uppy/screen-capture,@uppy/unsplash,@uppy/url,@uppy/webcam: Use `title` consistently from locales (Merlijn Vos / #5134) | Package | Version | Package | Version | | ------------------ | ------- | ------------------ | ------- | | @uppy/core | 3.11.3 | uppy | 3.25.3 | | @uppy/image-editor | 2.4.6 | | | - @uppy/image-editor: fix tooltips (Avneet Singh Malhotra / #5156) - meta: Remove redundant `plugins` prop from examples (Merlijn Vos / #5145) - @uppy/image-editor: Remove `target` option from examples and document consistently (Merlijn Vos / #5146) - @uppy/core: make getObjectOfFilesPerState more efficient (Merlijn Vos / #5155)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Only one loop instead of many. Ideally we'd have better state management in general, but that's a bigger thing. Tiny improvement for now.