Skip to content

Commit

Permalink
fix: get rid of ctxOwner flag due to it's buggy behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
nd0ut committed May 15, 2023
1 parent 8f5f8b8 commit 6c5f374
Show file tree
Hide file tree
Showing 40 changed files with 43 additions and 52 deletions.
2 changes: 1 addition & 1 deletion abstract/ActivityBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const ACTIVE_PROP = '___ACTIVITY_IS_ACTIVE___';

export class ActivityBlock extends Block {
historyTracked = false;
ctxInit = activityBlockCtx(this);
init$ = activityBlockCtx(this);

_debouncedHistoryFlush = debounce(this._historyFlush.bind(this), 10);

Expand Down
15 changes: 4 additions & 11 deletions abstract/Block.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { BaseComponent, Data } from '@symbiotejs/symbiote';
import { BaseComponent } from '@symbiotejs/symbiote';
import { createWindowHeightTracker, getIsWindowHeightTracked } from '../utils/createWindowHeightTracker.js';
import { applyTemplateData, getPluralObjects } from '../utils/template-utils.js';
import { l10nProcessor } from './l10nProcessor.js';
import { blockCtx } from './CTX.js';
import { createWindowHeightTracker, getIsWindowHeightTracked } from '../utils/createWindowHeightTracker.js';
import { l10nProcessor } from './l10nProcessor.js';

const TAG_PREFIX = 'lr-';

export class Block extends BaseComponent {
static StateConsumerScope = null;
allowCustomTemplate = true;

ctxInit = blockCtx();
init$ = this.ctxInit;
init$ = blockCtx();

/**
* @param {String} str
Expand Down Expand Up @@ -119,12 +118,6 @@ export class Block extends BaseComponent {
this.constructor['template'] = null;
this.processInnerHtml = true;
}
if (this.isConnected && this['__ctxOwner']) {
let data = Data.getCtx(this.ctxName, false);
if (data) {
data.store = { ...this.ctxInit };
}
}
super.connectedCallback();
}

Expand Down
3 changes: 1 addition & 2 deletions abstract/SolutionBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { ShadowWrapper } from '../blocks/ShadowWrapper/ShadowWrapper.js';
import { uploaderBlockCtx } from './CTX.js';

export class SolutionBlock extends ShadowWrapper {
ctxInit = uploaderBlockCtx(this);
ctxOwner = true;
init$ = uploaderBlockCtx(this);
_template = null;

static set template(value) {
Expand Down
2 changes: 1 addition & 1 deletion abstract/UploaderBlock.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Modal } from '../blocks/Modal/Modal.js';
import { stringToArray } from '../utils/stringToArray.js';

export class UploaderBlock extends ActivityBlock {
ctxInit = uploaderBlockCtx(this);
init$ = uploaderBlockCtx(this);
cssInit$ = {
...this.cssInit$,
'--cfg-max-concurrent-requests': 1,
Expand Down
2 changes: 1 addition & 1 deletion blocks/CameraSource/CameraSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class CameraSource extends UploaderBlock {
_unsubPermissions = null;

init$ = {
...this.ctxInit,
...this.init$,
video: null,
videoTransformCss: null,
shotBtnDisabled: true,
Expand Down
2 changes: 1 addition & 1 deletion blocks/CloudImageEditor/CloudImageEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export class CloudImageEditor extends UploaderBlock {
activityType = ActivityBlock.activities.CLOUD_IMG_EDIT;

init$ = {
...this.ctxInit,
...this.init$,
cdnUrl: null,
};

Expand Down
2 changes: 1 addition & 1 deletion blocks/CloudImageEditor/src/CloudEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class CloudEditor extends Block {
}

init$ = {
...this.ctxInit,
...this.init$,
...initState(this),
};

Expand Down
2 changes: 1 addition & 1 deletion blocks/CloudImageEditor/src/CropFrame.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { classNames } from './lib/classNames.js';

export class CropFrame extends Block {
init$ = {
...this.ctxInit,
...this.init$,
dragging: false,
};

Expand Down
2 changes: 1 addition & 1 deletion blocks/CloudImageEditor/src/EditorButtonControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { classNames } from './lib/classNames.js';

export class EditorButtonControl extends Block {
init$ = {
...this.ctxInit,
...this.init$,
active: false,
title: '',
icon: '',
Expand Down
2 changes: 1 addition & 1 deletion blocks/CloudImageEditor/src/EditorFilterControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { preloadImage } from './lib/preloadImage.js';

export class EditorFilterControl extends EditorButtonControl {
init$ = {
...this.ctxInit,
...this.init$,
active: false,
title: '',
icon: '',
Expand Down
2 changes: 1 addition & 1 deletion blocks/CloudImageEditor/src/EditorImageCropper.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function validateCrop(crop) {

export class EditorImageCropper extends Block {
init$ = {
...this.ctxInit,
...this.init$,
image: null,
'*padding': CROP_PADDING,
/** @type {Operations} */
Expand Down
2 changes: 1 addition & 1 deletion blocks/CloudImageEditor/src/EditorSlider.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const FAKE_ORIGINAL_FILTER = 'original';

export class EditorSlider extends Block {
init$ = {
...this.ctxInit,
...this.init$,
disabled: false,
min: 0,
max: 100,
Expand Down
2 changes: 1 addition & 1 deletion blocks/CloudImageEditor/src/EditorToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class EditorToolbar extends Block {
super();

this.init$ = {
...this.ctxInit,
...this.init$,
'*sliderEl': null,
/** @type {import('./types.js').LoadingOperations} */
'*loadingOperations': new Map(),
Expand Down
2 changes: 1 addition & 1 deletion blocks/CloudImageEditor/src/elements/button/LrBtnUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class LrBtnUi extends Block {
this._iconHidden = false;

this.init$ = {
...this.ctxInit,
...this.init$,
text: '',
icon: '',
iconCss: this._iconCss(),
Expand Down
2 changes: 1 addition & 1 deletion blocks/CloudImageEditor/src/elements/slider/SliderUi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Block } from '../../../../../abstract/Block.js';

export class SliderUi extends Block {
init$ = {
...this.ctxInit,
...this.init$,
disabled: false,
min: 0,
max: 100,
Expand Down
2 changes: 1 addition & 1 deletion blocks/CloudImageEditor/src/elements/slider/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { SliderUi } from './SliderUi.js';

class CtxProvider extends Block {
init$ = {
...this.ctxInit,
...this.init$,
min: 0,
max: 100,
defaultValue: 50,
Expand Down
2 changes: 1 addition & 1 deletion blocks/Color/Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Block } from '../../abstract/Block.js';

export class Color extends Block {
init$ = {
...this.ctxInit,
...this.init$,
inputOpacity: 0,
'*selectedColor': '#f00',
onChange: () => {
Expand Down
2 changes: 1 addition & 1 deletion blocks/ConfirmationDialog/ConfirmationDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class ConfirmationDialog extends ActivityBlock {
_defaults = new UiConfirmation();

init$ = {
...this.ctxInit,
...this.init$,
activityCaption: '',
messageTxt: '',
confirmBtnTxt: '',
Expand Down
2 changes: 1 addition & 1 deletion blocks/Copyright/Copyright.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Copyright extends Block {
};

init$ = {
...this.ctxInit,
...this.init$,
removeCopyright: false,
};

Expand Down
2 changes: 1 addition & 1 deletion blocks/DataOutput/DataOutput.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class DataOutput extends UploaderBlock {
processInnerHtml = true;

init$ = {
...this.ctxInit,
...this.init$,
output: null,
filesData: null,
};
Expand Down
3 changes: 1 addition & 2 deletions blocks/DropArea/DropArea.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { stringToArray } from '../../utils/stringToArray.js';

export class DropArea extends UploaderBlock {
init$ = {
...this.ctxInit,
...this.init$,
state: DropzoneState.INACTIVE,
withIcon: false,
isClickable: false,
Expand Down Expand Up @@ -78,7 +78,6 @@ export class DropArea extends UploaderBlock {
},
/** @param {(File | String)[]} items */
onItems: (items) => {
debugger;
if (!items.length) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion blocks/EditableCanvas/EditableCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { checkerboardCssBg } from '../svg-backgrounds/svg-backgrounds.js';

export class EditableCanvas extends Block {
init$ = {
...this.ctxInit,
...this.init$,
refMap: null,
disabled: true,
toolbarHidden: true,
Expand Down
2 changes: 1 addition & 1 deletion blocks/EditableCanvas/EditableCanvasToolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export class EditorToolbar extends Block {
}

init$ = {
...this.ctxInit,
...this.init$,
fsIcon: FS_ICON.FS,
rangeActive: false,
rangeCaption: '',
Expand Down
2 changes: 1 addition & 1 deletion blocks/ExternalSource/ExternalSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ExternalSource extends UploaderBlock {
activityType = ActivityBlock.activities.EXTERNAL;

init$ = {
...this.ctxInit,
...this.init$,
activityIcon: '',
activityCaption: '',
counter: 0,
Expand Down
2 changes: 1 addition & 1 deletion blocks/FileItem/FileItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class FileItem extends UploaderBlock {
};

init$ = {
...this.ctxInit,
...this.init$,
uid: '',
itemName: '',
errorText: '',
Expand Down
2 changes: 1 addition & 1 deletion blocks/FilePreview/FilePreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TRANSPARENT_PIXEL_SRC } from '../../utils/transparentPixelSrc.js';

export class FilePreview extends Block {
init$ = {
...this.ctxInit,
...this.init$,
checkerboard: false,
src: TRANSPARENT_PIXEL_SRC,
};
Expand Down
2 changes: 1 addition & 1 deletion blocks/Icon/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Block } from '../../abstract/Block.js';

export class Icon extends Block {
init$ = {
...this.ctxInit,
...this.init$,
name: '',
path: '',
size: '24',
Expand Down
2 changes: 1 addition & 1 deletion blocks/LiveHtml/LiveHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export class LiveHtml extends Block {
}

init$ = {
...this.ctxInit,
...this.init$,
src: '',
code: INIT_HTML,
spellcheck: false,
Expand Down
2 changes: 1 addition & 1 deletion blocks/MessageBox/MessageBox.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class UiMessage {

export class MessageBox extends Block {
init$ = {
...this.ctxInit,
...this.init$,
iconName: 'info',
captionTxt: 'Message caption',
msgTxt: 'Message...',
Expand Down
2 changes: 1 addition & 1 deletion blocks/Modal/Modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class Modal extends Block {
};

init$ = {
...this.ctxInit,
...this.init$,
'*modalActive': false,
isOpen: false,
closeClicked: this._handleDialogClose,
Expand Down
2 changes: 1 addition & 1 deletion blocks/ProgressBar/ProgressBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class ProgressBar extends Block {
_unknownMode = false;

init$ = {
...this.ctxInit,
...this.init$,
width: 0,
opacity: 0,
};
Expand Down
2 changes: 1 addition & 1 deletion blocks/ProgressBarCommon/ProgressBarCommon.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { UploaderBlock } from '../../abstract/UploaderBlock.js';

export class ProgressBarCommon extends UploaderBlock {
init$ = {
...this.ctxInit,
...this.init$,
visible: false,
unknown: false,
value: 0,
Expand Down
2 changes: 1 addition & 1 deletion blocks/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Block } from '../../abstract/Block.js';

export class Select extends Block {
init$ = {
...this.ctxInit,
...this.init$,
currentText: '',
options: [],
selectHtml: '',
Expand Down
2 changes: 1 addition & 1 deletion blocks/SimpleBtn/SimpleBtn.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { UploaderBlock } from '../../abstract/UploaderBlock.js';

export class SimpleBtn extends UploaderBlock {
init$ = {
...this.ctxInit,
...this.init$,
'*simpleButtonText': '',
onClick: () => {
this.initFlow();
Expand Down
2 changes: 1 addition & 1 deletion blocks/SourceBtn/SourceBtn.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export class SourceBtn extends UploaderBlock {
_registeredTypes = {};

init$ = {
...this.ctxInit,
...this.init$,
iconName: 'default',
};

Expand Down
2 changes: 1 addition & 1 deletion blocks/UploadDetails/UploadDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class UploadDetails extends UploaderBlock {
pauseRender = true;

init$ = {
...this.ctxInit,
...this.init$,
checkerboard: false,
fileSize: null,
fileName: '',
Expand Down
2 changes: 1 addition & 1 deletion blocks/UploadList/UploadList.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class UploadList extends UploaderBlock {
activityType = ActivityBlock.activities.UPLOAD_LIST;

init$ = {
...this.ctxInit,
...this.init$,
doneBtnVisible: false,
doneBtnEnabled: false,
uploadBtnVisible: false,
Expand Down
2 changes: 1 addition & 1 deletion blocks/UrlSource/UrlSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class UrlSource extends UploaderBlock {
activityType = ActivityBlock.activities.URL;

init$ = {
...this.ctxInit,
...this.init$,
importDisabled: true,
onUpload: () => {
let url = this.ref.input['value'];
Expand Down
2 changes: 1 addition & 1 deletion blocks/Video/Video.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class Video extends Block {
}

init$ = {
...this.ctxInit,
...this.init$,
src: '',
ppIcon: ICO_MAP.PLAY,
fsIcon: ICO_MAP.FS_ON,
Expand Down
2 changes: 1 addition & 1 deletion solutions/file-uploader/minimal/FileUploaderMinimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export class FileUploaderMinimal extends SolutionBlock {
pauseRender = true;

init$ = {
...this.ctxInit,
...this.init$,
selectClicked: () => {
this.ref.uBlock.openSystemDialog();
},
Expand Down

0 comments on commit 6c5f374

Please sign in to comment.