mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[REF] component: remove updateProps
it is actually now a private method
This commit is contained in:
+17
-15
@@ -319,14 +319,6 @@ export class Component<
|
||||
}
|
||||
}
|
||||
|
||||
async updateProps(
|
||||
nextProps: Props,
|
||||
forceUpdate: boolean = false,
|
||||
patchQueue: any[],
|
||||
): Promise<void> {
|
||||
const shouldUpdate = forceUpdate || this.shouldUpdate(nextProps);
|
||||
return shouldUpdate ? this._updateProps(nextProps, patchQueue) : Promise.resolve();
|
||||
}
|
||||
|
||||
set(target: any, key: string | number, value: any) {
|
||||
this.__owl__.observer!.set(target, key, value);
|
||||
@@ -336,10 +328,17 @@ export class Component<
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
async _updateProps(nextProps: Props, patchQueue: any[]): Promise<void> {
|
||||
await this.willUpdateProps(nextProps);
|
||||
this.props = nextProps;
|
||||
await this.render(false, patchQueue);
|
||||
async _updateProps(
|
||||
nextProps: Props,
|
||||
forceUpdate: boolean = false,
|
||||
patchQueue: any[]
|
||||
): Promise<void> {
|
||||
const shouldUpdate = forceUpdate || this.shouldUpdate(nextProps);
|
||||
if (shouldUpdate) {
|
||||
await this.willUpdateProps(nextProps);
|
||||
this.props = nextProps;
|
||||
await this.render(false, patchQueue);
|
||||
}
|
||||
}
|
||||
|
||||
_patch(vnode) {
|
||||
@@ -370,9 +369,12 @@ export class Component<
|
||||
return this.__owl__.renderPromise;
|
||||
}
|
||||
|
||||
async _render(force: boolean = false, patchQueue: any[] = []): Promise<VNode> {
|
||||
async _render(
|
||||
force: boolean = false,
|
||||
patchQueue: any[] = []
|
||||
): Promise<VNode> {
|
||||
if (this.__owl__.isMounted) {
|
||||
patchQueue.push(this)
|
||||
patchQueue.push(this);
|
||||
}
|
||||
this.__owl__.renderId++;
|
||||
const promises: Promise<void>[] = [];
|
||||
@@ -384,7 +386,7 @@ export class Component<
|
||||
promises,
|
||||
handlers: this.__owl__.boundHandlers,
|
||||
forceUpdate: force,
|
||||
patchQueue,
|
||||
patchQueue
|
||||
});
|
||||
if (this.__owl__.observer) {
|
||||
this.__owl__.observer.allowMutations = true;
|
||||
|
||||
+2
-2
@@ -1060,7 +1060,7 @@ const widgetDirective: Directive = {
|
||||
ctx.addIf(`w${widgetID} && w${widgetID}.__owl__.renderPromise`);
|
||||
ctx.addIf(`w${widgetID}.__owl__.isStarted`);
|
||||
ctx.addLine(
|
||||
`def${defID} = w${widgetID}.updateProps(props${widgetID}, extra.forceUpdate, extra.patchQueue);`
|
||||
`def${defID} = w${widgetID}._updateProps(props${widgetID}, extra.forceUpdate, extra.patchQueue);`
|
||||
);
|
||||
ctx.addElse();
|
||||
ctx.addLine(`isNew${widgetID} = true`);
|
||||
@@ -1076,7 +1076,7 @@ const widgetDirective: Directive = {
|
||||
ctx.addIf(`!def${defID}`);
|
||||
ctx.addIf(`w${widgetID}`);
|
||||
ctx.addLine(
|
||||
`def${defID} = w${widgetID}.updateProps(props${widgetID}, extra.forceUpdate, extra.patchQueue);`
|
||||
`def${defID} = w${widgetID}._updateProps(props${widgetID}, extra.forceUpdate, extra.patchQueue);`
|
||||
);
|
||||
ctx.addElse();
|
||||
ctx.addLine(
|
||||
|
||||
+3
-3
@@ -189,7 +189,7 @@ export function connect(mapStateToProps, options: any = {}) {
|
||||
}
|
||||
if (didChange) {
|
||||
this.__owl__.currentStoreProps = storeProps;
|
||||
this.updateProps(ownProps, false);
|
||||
this._updateProps(ownProps, false);
|
||||
}
|
||||
});
|
||||
super.mounted();
|
||||
@@ -198,7 +198,7 @@ export function connect(mapStateToProps, options: any = {}) {
|
||||
this.env.store.off("update", this);
|
||||
super.willUnmount();
|
||||
}
|
||||
updateProps(nextProps, forceUpdate) {
|
||||
_updateProps(nextProps, forceUpdate) {
|
||||
if (this.__owl__.ownProps !== nextProps) {
|
||||
this.__owl__.currentStoreProps = mapStateToProps(
|
||||
this.env.store.state,
|
||||
@@ -211,7 +211,7 @@ export function connect(mapStateToProps, options: any = {}) {
|
||||
nextProps,
|
||||
this.__owl__.currentStoreProps
|
||||
);
|
||||
return super.updateProps(mergedProps, forceUpdate);
|
||||
return super._updateProps(mergedProps, forceUpdate);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user