Skip to content

Commit

Permalink
feat: remove deprecated setUploadMetadata method
Browse files Browse the repository at this point in the history
  • Loading branch information
nd0ut committed Jun 17, 2024
1 parent 18aac85 commit 2ed5781
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 33 deletions.
1 change: 0 additions & 1 deletion abstract/CTX.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ export const uploaderBlockCtx = (fnCtx) => ({
'*commonProgress': 0,
'*uploadList': [],
'*focusedEntry': null,
'*uploadMetadata': null,
'*uploadQueue': new Queue(1),
'*uploadCollection': null,
/** @type {ReturnType<import('../types').OutputErrorCollection>[]} */
Expand Down
33 changes: 1 addition & 32 deletions abstract/UploaderBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { customUserAgent } from '../blocks/utils/userAgent.js';
import { createCdnUrl, createCdnUrlModifiers } from '../utils/cdn-utils.js';
import { IMAGE_ACCEPT_LIST, fileIsImage, mergeFileTypes } from '../utils/fileTypes.js';
import { stringToArray } from '../utils/stringToArray.js';
import { warnOnce } from '../utils/warnOnce.js';
import { uploaderBlockCtx } from './CTX.js';
import { TypedCollection } from './TypedCollection.js';
import { buildOutputCollectionState } from './buildOutputCollectionState.js';
Expand All @@ -28,32 +27,6 @@ export class UploaderBlock extends ActivityBlock {

init$ = uploaderBlockCtx(this);

/** @private */
__initialUploadMetadata = null;

/**
* This is Public JS API method. Could be called before block initialization, so we need to delay state interactions
* until block init.
*
* TODO: If we add more public methods, it is better to use the single queue instead of tons of private fields per
* each method. See https://github.com/uploadcare/blocks/pull/162/
*
* @deprecated Use `metadata` instance property on `lr-config` block instead.
* @param {import('@uploadcare/upload-client').Metadata} metadata
* @public
*/
setUploadMetadata(metadata) {
warnOnce(
'setUploadMetadata is deprecated. Use `metadata` instance property on `lr-config` block instead. See migration guide: https://uploadcare.com/docs/file-uploader/migration-to-0.25.0/',
);
if (!this.connectedOnce) {
// @ts-ignore TODO: fix this
this.__initialUploadMetadata = metadata;
} else {
this.$['*uploadMetadata'] = metadata;
}
}

get hasCtxOwner() {
return this.hasBlockInCtx((block) => {
if (block instanceof UploaderBlock) {
Expand Down Expand Up @@ -112,10 +85,6 @@ export class UploaderBlock extends ActivityBlock {
this.$['*uploadQueue'].concurrency = Number(value) || 1;
});

if (this.__initialUploadMetadata) {
this.$['*uploadMetadata'] = this.__initialUploadMetadata;
}

if (!this.$['*secureUploadsManager']) {
this.$['*secureUploadsManager'] = new SecureUploadsManager(this);
}
Expand Down Expand Up @@ -584,7 +553,7 @@ export class UploaderBlock extends ActivityBlock {
* @protected
*/
async getMetadataFor(entryId) {
const configValue = this.cfg.metadata ?? /** @type {import('../types').Metadata} */ (this.$['*uploadMetadata']);
const configValue = this.cfg.metadata || undefined;
if (typeof configValue === 'function') {
const outputFileEntry = this.getOutputItem(entryId);
const metadata = await configValue(outputFileEntry);
Expand Down

0 comments on commit 2ed5781

Please sign in to comment.