Skip to content
This repository has been archived by the owner on Oct 23, 2023. It is now read-only.

Commit

Permalink
fix(preview): preview performance (introduced in #274)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheReincarnator authored and lkuechler committed Apr 4, 2018
1 parent d6cd791 commit 81338ad
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 27 deletions.
24 changes: 8 additions & 16 deletions src/store/page/page-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -443,22 +443,14 @@ export class PageElement {
}
}

(async () => {
const coercedValue = property ? await property.coerceValue(value) : value;
if (path) {
const rootPropertyValue = this.propertyValues.get(id) || {};
ObjectPath.set<{}, PropertyValue>(rootPropertyValue, path, coercedValue);
this.propertyValues.set(id, deepAssign({}, rootPropertyValue));
} else {
this.propertyValues.set(id, coercedValue);
}
})().catch(reason => {
console.log(
`Failed to coerce property value of property '${id}' of pattern '${
this.patternId
}': ${reason}`
);
});
const coercedValue = property ? property.coerceValue(value) : value;
if (path) {
const rootPropertyValue = this.propertyValues.get(id) || {};
ObjectPath.set<{}, PropertyValue>(rootPropertyValue, path, coercedValue);
this.propertyValues.set(id, deepAssign({}, rootPropertyValue));
} else {
this.propertyValues.set(id, coercedValue);
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/store/styleguide/property/asset-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class AssetProperty extends Property {
* @inheritdoc
*/
// tslint:disable-next-line:no-any
public async coerceValue(value: any): Promise<any> {
public coerceValue(value: any): any {
if (typeof value === 'string') {
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/styleguide/property/boolean-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class BooleanProperty extends Property {
* @inheritdoc
*/
// tslint:disable-next-line:no-any
public async coerceValue(value: any): Promise<any> {
public coerceValue(value: any): any {
return value === true || value === 'true' || value === 1;
}

Expand Down
2 changes: 1 addition & 1 deletion src/store/styleguide/property/enum-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class EnumProperty extends Property {
* @inheritdoc
*/
// tslint:disable-next-line:no-any
public async coerceValue(value: any): Promise<any> {
public coerceValue(value: any): any {
if (value === null || value === undefined || value === '') {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/styleguide/property/number-array-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class NumberArrayProperty extends Property {
* @inheritdoc
*/
// tslint:disable-next-line:no-any
public async coerceValue(value: any): Promise<any> {
public coerceValue(value: any): any {
// tslint:disable-next-line:no-any
return this.coerceArrayValue(value, (element: any) => parseFloat(value));
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/styleguide/property/number-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class NumberProperty extends Property {
* @inheritdoc
*/
// tslint:disable-next-line:no-any
public async coerceValue(value: any): Promise<any> {
public coerceValue(value: any): any {
const result: number = parseFloat(value);
return isNaN(result) ? undefined : result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/styleguide/property/object-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ObjectProperty extends Property {
* @inheritdoc
*/
// tslint:disable-next-line:no-any
public async coerceValue(value: any): Promise<any> {
public coerceValue(value: any): any {
if (value === null || value === undefined || value === '') {
return undefined;
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/styleguide/property/pattern-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class PatternProperty extends Property {
* @inheritdoc
*/
// tslint:disable-next-line:no-any
public async coerceValue(value: any): Promise<any> {
public coerceValue(value: any): any {
// Page elements coerce their properties themselves
return value;
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/styleguide/property/property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export abstract class Property {
* @param callback A callback to be called with the resulting, property-compatible value.
*/
// tslint:disable-next-line:no-any
public abstract coerceValue(value: any): Promise<any>;
public abstract coerceValue(value: any): any;

/**
* Converts a given value into the form required by the component's props' property.
Expand Down
2 changes: 1 addition & 1 deletion src/store/styleguide/property/string-array-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class StringArrayProperty extends Property {
* @inheritdoc
*/
// tslint:disable-next-line:no-any
public async coerceValue(value: any): Promise<any> {
public coerceValue(value: any): any {
// tslint:disable-next-line:no-any
return this.coerceArrayValue(value, (element: any) => String(value));
}
Expand Down
2 changes: 1 addition & 1 deletion src/store/styleguide/property/string-property.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class StringProperty extends Property {
* @inheritdoc
*/
// tslint:disable-next-line:no-any
public async coerceValue(value: any): Promise<any> {
public coerceValue(value: any): any {
if (value === null || value === undefined || value === '') {
return '';
} else {
Expand Down
1 change: 0 additions & 1 deletion src/styleguide/renderer/highlight-area.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export class HighlightArea {
width: clientRect.width
};

console.log('Scrolled into view');
element.scrollIntoView({
behavior: 'smooth',
block: 'center',
Expand Down

0 comments on commit 81338ad

Please sign in to comment.