Skip to content

Commit

Permalink
Merge pull request #573 from uploadcare/fix/dashboard-related-fixes
Browse files Browse the repository at this point in the history
Fix/dashboard related fixes
  • Loading branch information
nd0ut authored Dec 7, 2023
2 parents 32003cb + 34dd6c6 commit 0757f42
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 14 deletions.
13 changes: 8 additions & 5 deletions abstract/ActivityBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,14 @@ export class ActivityBlock extends Block {
this.$['*history'] = [];
}
});
this.sub('*modalActive', (modalActive) => {
if (!modalActive && this.activityType === this.$['*currentActivity']) {
this.$['*currentActivity'] = null;
}
});

if (this.has('*modalActive')) {
this.sub('*modalActive', (modalActive) => {
if (!modalActive && this.activityType === this.$['*currentActivity']) {
this.$['*currentActivity'] = null;
}
});
}
}
}

Expand Down
12 changes: 10 additions & 2 deletions abstract/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,19 @@ export class Block extends BaseComponent {
Data.deleteCtx(this);

if (blocksRegistry.size === 0) {
// Destroy external context if there is no any blocks left inside it
Data.deleteCtx(this.ctxName);
this.destroyCtxCallback();
}
}

/**
* Called when the last block is removed from the context. Note that inheritors must run their callback before that.
*
* @protected
*/
destroyCtxCallback() {
Data.deleteCtx(this.ctxName);
}

/**
* @param {Number} bytes
* @param {Number} [decimals]
Expand Down
1 change: 1 addition & 0 deletions abstract/CTX.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ export const uploaderBlockCtx = (fnCtx) => ({
'*focusedEntry': null,
'*uploadMetadata': null,
'*uploadQueue': new Queue(1),
'*uploadCollection': null,
});
18 changes: 11 additions & 7 deletions abstract/UploaderBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export class UploaderBlock extends ActivityBlock {
initCallback() {
super.initCallback();

if (!this.has('*uploadCollection')) {
if (!this.$['*uploadCollection']) {
let uploadCollection = new TypedCollection({
typedSchema: uploadEntrySchema,
watchList: [
Expand All @@ -82,7 +82,7 @@ export class UploaderBlock extends ActivityBlock {
'cdnUrlModifiers',
],
});
this.add('*uploadCollection', uploadCollection);
this.$['*uploadCollection'] = uploadCollection;
}

if (!this.hasCtxOwner && this.couldBeCtxOwner) {
Expand All @@ -92,11 +92,15 @@ export class UploaderBlock extends ActivityBlock {

destroyCallback() {
super.destroyCallback();
if (this.isCtxOwner) {
this._unobserveCollectionProperties?.();
this._unobserveCollection?.();
this.uploadCollection.destroy();
}
}

destroyCtxCallback() {
this._unobserveCollectionProperties?.();
this._unobserveCollection?.();
this.uploadCollection.destroy();
this.$['*uploadCollection'] = null;

super.destroyCtxCallback();
}

initCtxOwner() {
Expand Down

0 comments on commit 0757f42

Please sign in to comment.