!1052 fix watch callback do not trigger at storagelink

Merge pull request !1052 from yfwang6/cherry-pick-1662035396
This commit is contained in:
openharmony_ci
2022-09-05 08:58:04 +00:00
committed by Gitee
3 changed files with 6 additions and 10 deletions
+2 -3
View File
@@ -68,9 +68,8 @@ export const INITIALIZE_CONSUME_FUNCTION: string = 'initializeConsume';
export const ADD_PROVIDED_VAR: string = 'addProvidedVar';
export const APP_STORAGE: string = 'AppStorage';
export const APP_STORAGE_SET_AND_PROP: string = 'setAndProp';
export const APP_STORAGE_SET_AND_LINK: string = 'setAndLink';
export const APP_STORAGE_GET_OR_SET: string = 'GetOrCreate';
export const APP_STORAGE_SET_AND_PROP: string = 'SetAndProp';
export const APP_STORAGE_SET_AND_LINK: string = 'SetAndLink';
export const PAGE_ENTRY_FUNCTION_NAME: string = 'loadDocument';
export const STORE_PREVIEW_COMPONENTS: string = 'storePreviewComponents';
@@ -168,5 +168,5 @@ export function addConstructor(ctorNode: any, watchMap: Map<string, ts.Node>,
ts.factory.createThis(), ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_UPDATE_PARAMS)),
undefined, [ts.factory.createIdentifier(COMPONENT_CONSTRUCTOR_PARAMS)]));
return updateConstructor(updateConstructor(ctorNode, [], [callSuperStatement], true), [],
[updateWithValueParamsStatement, ...watchStatements], false, true, parentComponentName);
[...watchStatements, updateWithValueParamsStatement], false, true, parentComponentName);
}
+3 -6
View File
@@ -44,7 +44,6 @@ import {
APP_STORAGE,
APP_STORAGE_SET_AND_PROP,
APP_STORAGE_SET_AND_LINK,
APP_STORAGE_GET_OR_SET,
COMPONENT_CONSTRUCTOR_UNDEFINED,
SET_CONTROLLER_METHOD,
SET_CONTROLLER_CTR,
@@ -509,11 +508,9 @@ function updateStoragePropAndLinkProperty(node: ts.PropertyDeclaration, name: ts
return ts.factory.createExpressionStatement(ts.factory.createBinaryExpression(
createPropertyAccessExpressionWithThis(`__${name.getText()}`),
ts.factory.createToken(ts.SyntaxKind.EqualsToken), ts.factory.createCallExpression(
ts.factory.createPropertyAccessExpression(ts.factory.createCallExpression(
ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(APP_STORAGE),
ts.factory.createIdentifier(APP_STORAGE_GET_OR_SET)), undefined, []),
ts.factory.createIdentifier(setFuncName)), undefined, [node.decorators[0].expression.arguments[0],
node.initializer, ts.factory.createThis()])));
ts.factory.createPropertyAccessExpression(ts.factory.createIdentifier(APP_STORAGE),
ts.factory.createIdentifier(setFuncName)), undefined, [node.decorators[0].expression.arguments[0],
node.initializer, ts.factory.createThis(), ts.factory.createStringLiteral(name.getText())])));
} else {
validateAppStorageDecoractorsNonSingleKey(node, log);
}