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: pass file to events consistently #5136
Open
Murderlon
wants to merge
6
commits into
4.x
Choose a base branch
from
consistent-event-file-args
base: 4.x
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+33
−33
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/companion-client/lib/RequestClient.js b/packages/@uppy/companion-client/lib/RequestClient.js
index a7ef904..6dbea5e 100644
--- a/packages/@uppy/companion-client/lib/RequestClient.js
+++ b/packages/@uppy/companion-client/lib/RequestClient.js
@@ -466,8 +466,8 @@ async function _awaitRemoteFileUpload2(_ref4) {
this.uppy.log(`upload ${file.id} was canceled`, "info");
resolve();
};
- const onFilePausedChange = (targetFileId, newPausedState) => {
- if (targetFileId !== file.id) return;
+ const onFilePausedChange = (targetFile, newPausedState) => {
+ if ((targetFile == null ? void 0 : targetFile.id) !== file.id) return;
pause(newPausedState);
};
const onPauseAll = () => pause(true);
diff --git a/packages/@uppy/core/lib/EventManager.js b/packages/@uppy/core/lib/EventManager.js
index 05ee7f4..54d8574 100644
--- a/packages/@uppy/core/lib/EventManager.js
+++ b/packages/@uppy/core/lib/EventManager.js
@@ -32,8 +32,8 @@ export default class EventManager {
}
}
onFilePause(fileID, cb) {
- this.on("upload-pause", (targetFileID, isPaused) => {
- if (fileID === targetFileID) {
+ this.on("upload-pause", (file, isPaused) => {
+ if (fileID === (file == null ? void 0 : file.id)) {
cb(isPaused);
}
});
@@ -44,15 +44,15 @@ export default class EventManager {
});
}
onPause(fileID, cb) {
- this.on("upload-pause", (targetFileID, isPaused) => {
- if (fileID === targetFileID) {
+ this.on("upload-pause", (file, isPaused) => {
+ if (fileID === (file == null ? void 0 : file.id)) {
cb(isPaused);
}
});
}
onRetry(fileID, cb) {
- this.on("upload-retry", targetFileID => {
- if (fileID === targetFileID) {
+ this.on("upload-retry", file => {
+ if (fileID === (file == null ? void 0 : file.id)) {
cb();
}
});
diff --git a/packages/@uppy/core/lib/Uppy.js b/packages/@uppy/core/lib/Uppy.js
index 3b2edee..8bbd650 100644
--- a/packages/@uppy/core/lib/Uppy.js
+++ b/packages/@uppy/core/lib/Uppy.js
@@ -632,12 +632,13 @@ export class Uppy {
if (!this.getState().capabilities.resumableUploads || this.getFile(fileID).progress.uploadComplete) {
return undefined;
}
- const wasPaused = this.getFile(fileID).isPaused || false;
+ const file = this.getFile(fileID);
+ const wasPaused = file.isPaused || false;
const isPaused = !wasPaused;
this.setFileState(fileID, {
isPaused,
});
- this.emit("upload-pause", fileID, isPaused);
+ this.emit("upload-pause", file, isPaused);
return isPaused;
}
pauseAll() {
@@ -698,7 +699,7 @@ export class Uppy {
files: updatedFiles,
error: null,
});
- this.emit("retry-all", filesToRetry);
+ this.emit("retry-all", Object.values(updatedFiles));
if (filesToRetry.length === 0) {
return Promise.resolve({
successful: [],
@@ -733,7 +734,7 @@ export class Uppy {
error: null,
isPaused: false,
});
- this.emit("upload-retry", fileID);
+ this.emit("upload-retry", this.getFile(fileID));
const uploadID = _classPrivateFieldLooseBase(this, _createUpload)[_createUpload]([fileID], {
forceAllowNewUpload: true,
});
@@ -1444,10 +1445,7 @@ function _createUpload2(fileIDs, opts) {
throw new Error("Cannot create a new upload: already uploading.");
}
const uploadID = nanoid();
- this.emit("upload", {
- id: uploadID,
- fileIDs,
- });
+ this.emit("upload", uploadID, this.getFilesByIds(fileIDs));
this.setState({
allowNewUpload: this.opts.allowMultipleUploadBatches !== false && this.opts.allowMultipleUploads !== false,
currentUploads: { |
did we agree to also convert these for consistency? |
Done |
mifi
reviewed
May 9, 2024
mifi
reviewed
May 9, 2024
Co-authored-by: Mikael Finstad <finstaden@gmail.com>
aduh95
added
the
notable change
Changes that deserve a mention in a migration guide
label
May 13, 2024
aduh95
reviewed
May 13, 2024
* 4.x: (24 commits) @uppy/companion: encode `uploadId` (#5168) @uppy/companion: bump `express-session` (#5177) @uppy/companion: remove dependency on `express-request-id` (#5176) @uppy/companion: bump prom to v15 (#5175) docs: fix linter meta: remove `nodemon` from the deps (#5172) docs: update `@uppy/aws-s3` docs (#5093) meta: update more dependencies (#5171) @uppy/companion: upgrade deps (#5119) Release: uppy@4.0.0-beta.7 (#5162) @uppy/companion: switch from `node-redis` to `ioredis` (#4623) Fix headings in xhr.mdx @uppy/xhr-upload: introduce hooks similar to tus (#5094) @uppy/core: close->destroy, clearUploadedFiles->clear (#5154) Use `title` consistently from locales (#5134) Release: uppy@4.0.0-beta.6 (#5152) Release: uppy@4.0.0-beta.5 (#5141) meta: run Prettier in the release workflow Release: uppy@3.25.1 (#5139) Bump ejs from 3.1.9 to 3.1.10 (#5135) ...
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.
Closes #3938