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

fix: server validation error rendering #604

Merged
merged 1 commit into from
Feb 13, 2024
Merged
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
15 changes: 8 additions & 7 deletions abstract/UploaderBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { TypedCollection } from './TypedCollection.js';
import { buildOutputCollectionState } from './buildOutputCollectionState.js';
import { uploadEntrySchema } from './uploadEntrySchema.js';
import { throttle } from '../blocks/utils/throttle.js';

Check warning on line 23 in abstract/UploaderBlock.js

View workflow job for this annotation

GitHub Actions / build

'throttle' is defined but never used

export class UploaderBlock extends ActivityBlock {
couldBeCtxOwner = false;
Expand Down Expand Up @@ -137,7 +137,7 @@
if (!this.$['*uploadCollection']) {
let uploadCollection = new TypedCollection({
typedSchema: uploadEntrySchema,
watchList: ['uploadProgress', 'fileInfo', 'errors', 'cdnUrl', 'isUploading'],
watchList: ['uploadProgress', 'uploadError', 'fileInfo', 'errors', 'cdnUrl', 'isUploading'],
});
this.$['*uploadCollection'] = uploadCollection;
}
Expand Down Expand Up @@ -498,9 +498,6 @@
entry.setValue('errors', errors);
}

/** @private */
_debouncedRunFileValidators = debounce(this._runFileValidators.bind(this), 100);

/**
* @private
* @param {string[]} [entryIds]
Expand Down Expand Up @@ -626,16 +623,20 @@
this._flushOutputItems();

const uploadCollection = this.uploadCollection;
const updatedEntryIds = [
const entriesToRunValidation = [
...new Set(
Object.entries(changeMap)
.filter(([key]) => key !== 'errors')
.filter(([key]) => ['uploadError', 'fileInfo'].includes(key))
.map(([, ids]) => [...ids])
.flat(),
),
];

this._debouncedRunFileValidators(updatedEntryIds);
entriesToRunValidation.length > 0 &&
setTimeout(() => {
// We can't modify entry properties in the same tick, so we need to wait a bit
this._runFileValidators(entriesToRunValidation);
});

if (changeMap.uploadProgress) {
for (const entryId of changeMap.uploadProgress) {
Expand Down
Loading