runningTree在直接execute某个action时,简化了原先的行为
This commit is contained in:
parent
91bf1da808
commit
ea01036c5a
|
|
@ -233,7 +233,7 @@ declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof
|
|||
saveRefreshResult(data: Record<string, any>): void;
|
||||
refresh(): Promise<void>;
|
||||
clean(lsn?: number, dontPublish?: true): void;
|
||||
private getFilter;
|
||||
getFilter(ignoreNew?: true, onlyHot?: true): ED[T]['Filter'] | undefined;
|
||||
getIntrinsticFilters(): ED[T]["Filter"] | undefined;
|
||||
/**
|
||||
* getParentFilter不能假设一定已经有数据,只能根据当前filter的条件去构造
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import { createOperationsFromModies } from 'oak-domain/lib/store/modi';
|
|||
import { judgeRelation } from "oak-domain/lib/store/relation";
|
||||
import { CreateAtAttribute, UpdateAtAttribute, DeleteAtAttribute } from "oak-domain/lib/types";
|
||||
import { Feature } from '../types/Feature';
|
||||
import { generateNewId } from 'oak-domain/lib/utils/uuid';
|
||||
import { generateNewId, generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
||||
export const MODI_NEXT_PATH_SUFFIX = ':next';
|
||||
const START_LSN = 100;
|
||||
function mergeOperation(schema, entity, oper1, oper2) {
|
||||
|
|
@ -2413,7 +2413,7 @@ export class RunningTree extends Feature {
|
|||
const node = path && this.findNode(path);
|
||||
// assert(node.isDirty());
|
||||
node && node.setExecuting(true);
|
||||
let pollute = false;
|
||||
// let pollute = false;
|
||||
try {
|
||||
let operations = path && this.getOperations(path) || [];
|
||||
if (opers) {
|
||||
|
|
@ -2432,15 +2432,30 @@ export class RunningTree extends Feature {
|
|||
else if (node) {
|
||||
// 老的写法,直接对一个非脏的结点execute某个action,也可以支持
|
||||
assert(node instanceof SingleNode);
|
||||
node.update(this.logSerailNumber, {}, action);
|
||||
pollute = true;
|
||||
operations = node.composeOperations() || [];
|
||||
assert(operations.length === 1);
|
||||
const [operation1] = operations;
|
||||
if (action !== operation1.operation.action) {
|
||||
assert(operation1.operation.action === 'update'); // 如果execute时传action,前面update动作应该只可能是update
|
||||
operation1.operation.action = action;
|
||||
}
|
||||
// node.update(this.logSerailNumber, {}, action);
|
||||
// pollute = true;
|
||||
// operations = node.composeOperations() || [];
|
||||
// assert(operations.length === 1);
|
||||
// const [operation1] = operations;
|
||||
// if (action !== operation1.operation.action) {
|
||||
// assert(operation1.operation.action === 'update'); // 如果execute时传action,前面update动作应该只可能是update
|
||||
// operation1.operation.action = action;
|
||||
// }
|
||||
/**
|
||||
* 上述写法会触发publish行为,如:一个close动作会导致页面像下面这样渲染:
|
||||
* opened --> closed(上面的node.update) --> opened(执行成功回来setExecuting时) --> closed(执行成功回来再sync cache后)
|
||||
*/
|
||||
operations.push({
|
||||
entity: node.getEntity(),
|
||||
operation: {
|
||||
id: await generateNewIdAsync(),
|
||||
action,
|
||||
data: {
|
||||
$$updateAt$$: Date.now(),
|
||||
},
|
||||
filter: node.getFilter(true),
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (operations.length > 0) {
|
||||
|
|
@ -2470,9 +2485,9 @@ export class RunningTree extends Feature {
|
|||
}
|
||||
catch (err) {
|
||||
node && node.setExecuting(false);
|
||||
if (pollute) {
|
||||
/* if (pollute) {
|
||||
path && this.clean(path);
|
||||
}
|
||||
} */
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ declare class SingleNode<ED extends EntityDict & BaseEntityDict, T extends keyof
|
|||
saveRefreshResult(data: Record<string, any>): void;
|
||||
refresh(): Promise<void>;
|
||||
clean(lsn?: number, dontPublish?: true): void;
|
||||
private getFilter;
|
||||
getFilter(ignoreNew?: true, onlyHot?: true): ED[T]['Filter'] | undefined;
|
||||
getIntrinsticFilters(): ED[T]["Filter"] | undefined;
|
||||
/**
|
||||
* getParentFilter不能假设一定已经有数据,只能根据当前filter的条件去构造
|
||||
|
|
|
|||
|
|
@ -2416,7 +2416,7 @@ class RunningTree extends Feature_1.Feature {
|
|||
const node = path && this.findNode(path);
|
||||
// assert(node.isDirty());
|
||||
node && node.setExecuting(true);
|
||||
let pollute = false;
|
||||
// let pollute = false;
|
||||
try {
|
||||
let operations = path && this.getOperations(path) || [];
|
||||
if (opers) {
|
||||
|
|
@ -2435,15 +2435,30 @@ class RunningTree extends Feature_1.Feature {
|
|||
else if (node) {
|
||||
// 老的写法,直接对一个非脏的结点execute某个action,也可以支持
|
||||
(0, assert_1.assert)(node instanceof SingleNode);
|
||||
node.update(this.logSerailNumber, {}, action);
|
||||
pollute = true;
|
||||
operations = node.composeOperations() || [];
|
||||
(0, assert_1.assert)(operations.length === 1);
|
||||
const [operation1] = operations;
|
||||
if (action !== operation1.operation.action) {
|
||||
(0, assert_1.assert)(operation1.operation.action === 'update'); // 如果execute时传action,前面update动作应该只可能是update
|
||||
operation1.operation.action = action;
|
||||
}
|
||||
// node.update(this.logSerailNumber, {}, action);
|
||||
// pollute = true;
|
||||
// operations = node.composeOperations() || [];
|
||||
// assert(operations.length === 1);
|
||||
// const [operation1] = operations;
|
||||
// if (action !== operation1.operation.action) {
|
||||
// assert(operation1.operation.action === 'update'); // 如果execute时传action,前面update动作应该只可能是update
|
||||
// operation1.operation.action = action;
|
||||
// }
|
||||
/**
|
||||
* 上述写法会触发publish行为,如:一个close动作会导致页面像下面这样渲染:
|
||||
* opened --> closed(上面的node.update) --> opened(执行成功回来setExecuting时) --> closed(执行成功回来再sync cache后)
|
||||
*/
|
||||
operations.push({
|
||||
entity: node.getEntity(),
|
||||
operation: {
|
||||
id: await (0, uuid_1.generateNewIdAsync)(),
|
||||
action,
|
||||
data: {
|
||||
$$updateAt$$: Date.now(),
|
||||
},
|
||||
filter: node.getFilter(true),
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (operations.length > 0) {
|
||||
|
|
@ -2473,9 +2488,9 @@ class RunningTree extends Feature_1.Feature {
|
|||
}
|
||||
catch (err) {
|
||||
node && node.setExecuting(false);
|
||||
if (pollute) {
|
||||
/* if (pollute) {
|
||||
path && this.clean(path);
|
||||
}
|
||||
} */
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@
|
|||
"@types/node": "^20.7.0",
|
||||
"@types/node-schedule": "^2.1.0",
|
||||
"@types/nprogress": "^0.2.3",
|
||||
"@types/react": "^18.3.26",
|
||||
"@types/react": "^18.3.27",
|
||||
"@types/react-dom": "^18.2.14",
|
||||
"@types/react-native": "^0.72.8",
|
||||
"@types/uuid": "^9.0.6",
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { Cache } from './cache';
|
|||
import { Pagination } from '../types/Pagination';
|
||||
import { Feature } from '../types/Feature';
|
||||
import { ActionDef, CreateDataDef } from '../types/Page';
|
||||
import { generateNewId } from 'oak-domain/lib/utils/uuid';
|
||||
import { generateNewId, generateNewIdAsync } from 'oak-domain/lib/utils/uuid';
|
||||
|
||||
export const MODI_NEXT_PATH_SUFFIX = ':next';
|
||||
const START_LSN = 100;
|
||||
|
|
@ -1965,7 +1965,7 @@ class SingleNode<ED extends EntityDict & BaseEntityDict,
|
|||
}
|
||||
}
|
||||
|
||||
private getFilter(ignoreNew?: true, onlyHot?: true): ED[T]['Filter'] | undefined {
|
||||
getFilter(ignoreNew?: true, onlyHot?: true): ED[T]['Filter'] | undefined {
|
||||
// 如果是新建,等于没有filter
|
||||
const [operation] = this.ulManager.makeOperations();
|
||||
if (operation?.action === 'create') {
|
||||
|
|
@ -2970,7 +2970,7 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
|
||||
node && node.setExecuting(true);
|
||||
|
||||
let pollute = false;
|
||||
// let pollute = false;
|
||||
try {
|
||||
let operations = path && this.getOperations(path) || [];
|
||||
if (opers) {
|
||||
|
|
@ -2990,15 +2990,30 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
else if (node) {
|
||||
// 老的写法,直接对一个非脏的结点execute某个action,也可以支持
|
||||
assert(node instanceof SingleNode);
|
||||
node.update(this.logSerailNumber, {}, action);
|
||||
pollute = true;
|
||||
operations = node.composeOperations() || [];
|
||||
assert(operations.length === 1);
|
||||
const [operation1] = operations;
|
||||
if (action !== operation1.operation.action) {
|
||||
assert(operation1.operation.action === 'update'); // 如果execute时传action,前面update动作应该只可能是update
|
||||
operation1.operation.action = action;
|
||||
}
|
||||
// node.update(this.logSerailNumber, {}, action);
|
||||
// pollute = true;
|
||||
// operations = node.composeOperations() || [];
|
||||
// assert(operations.length === 1);
|
||||
// const [operation1] = operations;
|
||||
// if (action !== operation1.operation.action) {
|
||||
// assert(operation1.operation.action === 'update'); // 如果execute时传action,前面update动作应该只可能是update
|
||||
// operation1.operation.action = action;
|
||||
// }
|
||||
/**
|
||||
* 上述写法会触发publish行为,如:一个close动作会导致页面像下面这样渲染:
|
||||
* opened --> closed(上面的node.update) --> opened(执行成功回来setExecuting时) --> closed(执行成功回来再sync cache后)
|
||||
*/
|
||||
operations.push({
|
||||
entity: node.getEntity(),
|
||||
operation: {
|
||||
id: await generateNewIdAsync(),
|
||||
action,
|
||||
data: {
|
||||
$$updateAt$$: Date.now(),
|
||||
},
|
||||
filter: node.getFilter(true),
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (operations.length > 0) {
|
||||
|
|
@ -3038,9 +3053,9 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
return { message: 'No Operation' };
|
||||
} catch (err) {
|
||||
node && node.setExecuting(false);
|
||||
if (pollute) {
|
||||
/* if (pollute) {
|
||||
path && this.clean(path);
|
||||
}
|
||||
} */
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue