修正了刷新时的必要性判断
This commit is contained in:
parent
0ba311b66e
commit
89a30cd291
|
|
@ -286,7 +286,6 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict> extends
|
|||
private root;
|
||||
constructor(cache: Cache<ED>, schema: StorageSchema<ED>);
|
||||
createNode<T extends keyof ED>(options: CreateNodeOptions<ED, T>, isPage: boolean): ListNode<ED, T> | SingleNode<ED, T> | VirtualNode<ED>;
|
||||
checkIsInModiNextBranch(path: string): boolean;
|
||||
private findNode;
|
||||
destroyNode(path: string, isPage: boolean): void;
|
||||
begin(): () => void;
|
||||
|
|
@ -311,7 +310,8 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict> extends
|
|||
isLoading(path: string): boolean | undefined;
|
||||
isLoadingMore(path: string): boolean | undefined;
|
||||
isExecuting(path: string): boolean;
|
||||
isListDescandent(path: string): boolean;
|
||||
private isListDescandent;
|
||||
private isInModiNextBranch;
|
||||
refresh(path: string, pageNumber?: number): Promise<void>;
|
||||
loadMore(path: string): Promise<void>;
|
||||
getPagination(path: string): Pagination;
|
||||
|
|
|
|||
|
|
@ -1886,31 +1886,6 @@ export class RunningTree extends Feature {
|
|||
}
|
||||
return node;
|
||||
}
|
||||
// 判断当前结点是否在:next的路径上(且有前项结点,两者同时满足就不用refresh了)
|
||||
checkIsInModiNextBranch(path) {
|
||||
if (!path.includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
return false;
|
||||
}
|
||||
const paths = path.split('.');
|
||||
if (paths[0].includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
// 根结点就是:next,这时候还是要取的
|
||||
return false;
|
||||
}
|
||||
let iter = 1;
|
||||
while (iter < paths.length) {
|
||||
if (paths[iter].includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
const path2 = paths.slice(0, iter) + paths[iter].replace(MODI_NEXT_PATH_SUFFIX, '');
|
||||
const node = this.findNode(path2);
|
||||
if (node) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
findNode(path) {
|
||||
if (this.root[path]) {
|
||||
return this.root[path];
|
||||
|
|
@ -2054,10 +2029,57 @@ export class RunningTree extends Feature {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
// 判断当前结点是否在:next的路径上
|
||||
// 当前判断规则是:在:next的分岔结点上,如果有前项结点,或者:next结点本身是一个create,则不再刷新
|
||||
isInModiNextBranch(path) {
|
||||
if (!path.includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
return false;
|
||||
}
|
||||
const paths = path.split('.');
|
||||
if (paths[0].includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
// 根结点就是:next,这时候还是要取的
|
||||
return false;
|
||||
}
|
||||
let iter = 1;
|
||||
while (iter < paths.length) {
|
||||
if (paths[iter].includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
const pathPrev = paths.slice(0, iter).join('.') + paths[iter].replace(MODI_NEXT_PATH_SUFFIX, '');
|
||||
const node = this.findNode(pathPrev);
|
||||
if (node) {
|
||||
return true;
|
||||
}
|
||||
// 还有一种情况,这个:next结点是创建出来的
|
||||
const pathNext = paths.slice(0, iter + 1).join('.');
|
||||
const nodeNext = this.findNode(pathNext);
|
||||
if (nodeNext instanceof SingleNode) {
|
||||
const id = nodeNext.getId();
|
||||
const [modi] = this.cache.get('modi', {
|
||||
data: {
|
||||
id: 1,
|
||||
},
|
||||
filter: {
|
||||
action: 'create',
|
||||
targetEntity: nodeNext.getEntity(),
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
}
|
||||
});
|
||||
if (modi) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
async refresh(path, pageNumber) {
|
||||
/* if (path.includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
if (this.isInModiNextBranch(path) || this.isListDescandent(path)) {
|
||||
return;
|
||||
} */
|
||||
}
|
||||
const node = this.findNode(path);
|
||||
if (!node?.isLoading()) {
|
||||
if (node instanceof ListNode) {
|
||||
|
|
|
|||
|
|
@ -485,9 +485,7 @@ const oakBehavior = Behavior({
|
|||
this.oakOption.lifetimes?.ready &&
|
||||
this.oakOption.lifetimes?.ready.call(this);
|
||||
const { oakFullpath } = this.state;
|
||||
if (oakFullpath && !this.oakOption.stale &&
|
||||
!this.features.runningTree.checkIsInModiNextBranch(oakFullpath) &&
|
||||
!this.features.runningTree.isListDescandent(oakFullpath)) {
|
||||
if (oakFullpath && !this.oakOption.stale) {
|
||||
this.refresh();
|
||||
}
|
||||
else {
|
||||
|
|
@ -790,9 +788,7 @@ export function createComponent(option, features) {
|
|||
return;
|
||||
}
|
||||
const { oakFullpath } = this.state;
|
||||
if (oakFullpath && !option.stale &&
|
||||
!features.runningTree.checkIsInModiNextBranch(oakFullpath) &&
|
||||
!features.runningTree.isListDescandent(oakFullpath)) {
|
||||
if (oakFullpath && !option.stale) {
|
||||
try {
|
||||
await this.refresh();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -646,9 +646,7 @@ export function createComponent(option, features) {
|
|||
}
|
||||
try {
|
||||
const { oakFullpath } = this.state;
|
||||
if (oakFullpath && !option.stale &&
|
||||
!features.runningTree.checkIsInModiNextBranch(oakFullpath) &&
|
||||
!features.runningTree.isListDescandent(oakFullpath)) {
|
||||
if (oakFullpath && !option.stale) {
|
||||
await this.refresh();
|
||||
}
|
||||
else {
|
||||
|
|
@ -706,9 +704,7 @@ export function createComponent(option, features) {
|
|||
lifetimes?.show && lifetimes.show.call(this);
|
||||
}
|
||||
const { oakFullpath } = this.state;
|
||||
if (oakFullpath && !option.stale &&
|
||||
!features.runningTree.checkIsInModiNextBranch(oakFullpath) &&
|
||||
!features.runningTree.isListDescandent(oakFullpath)) {
|
||||
if (oakFullpath && !option.stale) {
|
||||
this.refresh();
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -286,7 +286,6 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict> extends
|
|||
private root;
|
||||
constructor(cache: Cache<ED>, schema: StorageSchema<ED>);
|
||||
createNode<T extends keyof ED>(options: CreateNodeOptions<ED, T>, isPage: boolean): ListNode<ED, T> | SingleNode<ED, T> | VirtualNode<ED>;
|
||||
checkIsInModiNextBranch(path: string): boolean;
|
||||
private findNode;
|
||||
destroyNode(path: string, isPage: boolean): void;
|
||||
begin(): () => void;
|
||||
|
|
@ -311,7 +310,8 @@ export declare class RunningTree<ED extends EntityDict & BaseEntityDict> extends
|
|||
isLoading(path: string): boolean | undefined;
|
||||
isLoadingMore(path: string): boolean | undefined;
|
||||
isExecuting(path: string): boolean;
|
||||
isListDescandent(path: string): boolean;
|
||||
private isListDescandent;
|
||||
private isInModiNextBranch;
|
||||
refresh(path: string, pageNumber?: number): Promise<void>;
|
||||
loadMore(path: string): Promise<void>;
|
||||
getPagination(path: string): Pagination;
|
||||
|
|
|
|||
|
|
@ -1889,31 +1889,6 @@ class RunningTree extends Feature_1.Feature {
|
|||
}
|
||||
return node;
|
||||
}
|
||||
// 判断当前结点是否在:next的路径上(且有前项结点,两者同时满足就不用refresh了)
|
||||
checkIsInModiNextBranch(path) {
|
||||
if (!path.includes(exports.MODI_NEXT_PATH_SUFFIX)) {
|
||||
return false;
|
||||
}
|
||||
const paths = path.split('.');
|
||||
if (paths[0].includes(exports.MODI_NEXT_PATH_SUFFIX)) {
|
||||
// 根结点就是:next,这时候还是要取的
|
||||
return false;
|
||||
}
|
||||
let iter = 1;
|
||||
while (iter < paths.length) {
|
||||
if (paths[iter].includes(exports.MODI_NEXT_PATH_SUFFIX)) {
|
||||
const path2 = paths.slice(0, iter) + paths[iter].replace(exports.MODI_NEXT_PATH_SUFFIX, '');
|
||||
const node = this.findNode(path2);
|
||||
if (node) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
(0, assert_1.assert)(false);
|
||||
return false;
|
||||
}
|
||||
findNode(path) {
|
||||
if (this.root[path]) {
|
||||
return this.root[path];
|
||||
|
|
@ -2057,10 +2032,57 @@ class RunningTree extends Feature_1.Feature {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
// 判断当前结点是否在:next的路径上
|
||||
// 当前判断规则是:在:next的分岔结点上,如果有前项结点,或者:next结点本身是一个create,则不再刷新
|
||||
isInModiNextBranch(path) {
|
||||
if (!path.includes(exports.MODI_NEXT_PATH_SUFFIX)) {
|
||||
return false;
|
||||
}
|
||||
const paths = path.split('.');
|
||||
if (paths[0].includes(exports.MODI_NEXT_PATH_SUFFIX)) {
|
||||
// 根结点就是:next,这时候还是要取的
|
||||
return false;
|
||||
}
|
||||
let iter = 1;
|
||||
while (iter < paths.length) {
|
||||
if (paths[iter].includes(exports.MODI_NEXT_PATH_SUFFIX)) {
|
||||
const pathPrev = paths.slice(0, iter).join('.') + paths[iter].replace(exports.MODI_NEXT_PATH_SUFFIX, '');
|
||||
const node = this.findNode(pathPrev);
|
||||
if (node) {
|
||||
return true;
|
||||
}
|
||||
// 还有一种情况,这个:next结点是创建出来的
|
||||
const pathNext = paths.slice(0, iter + 1).join('.');
|
||||
const nodeNext = this.findNode(pathNext);
|
||||
if (nodeNext instanceof SingleNode) {
|
||||
const id = nodeNext.getId();
|
||||
const [modi] = this.cache.get('modi', {
|
||||
data: {
|
||||
id: 1,
|
||||
},
|
||||
filter: {
|
||||
action: 'create',
|
||||
targetEntity: nodeNext.getEntity(),
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
}
|
||||
});
|
||||
if (modi) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
iter++;
|
||||
}
|
||||
(0, assert_1.assert)(false);
|
||||
return false;
|
||||
}
|
||||
async refresh(path, pageNumber) {
|
||||
/* if (path.includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
if (this.isInModiNextBranch(path) || this.isListDescandent(path)) {
|
||||
return;
|
||||
} */
|
||||
}
|
||||
const node = this.findNode(path);
|
||||
if (!node?.isLoading()) {
|
||||
if (node instanceof ListNode) {
|
||||
|
|
|
|||
|
|
@ -488,9 +488,7 @@ const oakBehavior = Behavior({
|
|||
this.oakOption.lifetimes?.ready &&
|
||||
this.oakOption.lifetimes?.ready.call(this);
|
||||
const { oakFullpath } = this.state;
|
||||
if (oakFullpath && !this.oakOption.stale &&
|
||||
!this.features.runningTree.checkIsInModiNextBranch(oakFullpath) &&
|
||||
!this.features.runningTree.isListDescandent(oakFullpath)) {
|
||||
if (oakFullpath && !this.oakOption.stale) {
|
||||
this.refresh();
|
||||
}
|
||||
else {
|
||||
|
|
@ -793,9 +791,7 @@ function createComponent(option, features) {
|
|||
return;
|
||||
}
|
||||
const { oakFullpath } = this.state;
|
||||
if (oakFullpath && !option.stale &&
|
||||
!features.runningTree.checkIsInModiNextBranch(oakFullpath) &&
|
||||
!features.runningTree.isListDescandent(oakFullpath)) {
|
||||
if (oakFullpath && !option.stale) {
|
||||
try {
|
||||
await this.refresh();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -651,9 +651,7 @@ function createComponent(option, features) {
|
|||
}
|
||||
try {
|
||||
const { oakFullpath } = this.state;
|
||||
if (oakFullpath && !option.stale &&
|
||||
!features.runningTree.checkIsInModiNextBranch(oakFullpath) &&
|
||||
!features.runningTree.isListDescandent(oakFullpath)) {
|
||||
if (oakFullpath && !option.stale) {
|
||||
await this.refresh();
|
||||
}
|
||||
else {
|
||||
|
|
@ -711,9 +709,7 @@ function createComponent(option, features) {
|
|||
lifetimes?.show && lifetimes.show.call(this);
|
||||
}
|
||||
const { oakFullpath } = this.state;
|
||||
if (oakFullpath && !option.stale &&
|
||||
!features.runningTree.checkIsInModiNextBranch(oakFullpath) &&
|
||||
!features.runningTree.isListDescandent(oakFullpath)) {
|
||||
if (oakFullpath && !option.stale) {
|
||||
this.refresh();
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
|
|
@ -2291,35 +2291,6 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
return node;
|
||||
}
|
||||
|
||||
// 判断当前结点是否在:next的路径上(且有前项结点,两者同时满足就不用refresh了)
|
||||
checkIsInModiNextBranch(path: string) {
|
||||
if (!path.includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
return false;
|
||||
}
|
||||
const paths = path.split('.');
|
||||
|
||||
if (paths[0].includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
// 根结点就是:next,这时候还是要取的
|
||||
return false;
|
||||
}
|
||||
let iter = 1;
|
||||
while(iter < paths.length) {
|
||||
if (paths[iter].includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
const path2 = paths.slice(0, iter) + paths[iter].replace(MODI_NEXT_PATH_SUFFIX, '');
|
||||
|
||||
const node = this.findNode(path2);
|
||||
if (node) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
iter ++;
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
private findNode(path: string) {
|
||||
if (this.root[path]) {
|
||||
return this.root[path];
|
||||
|
|
@ -2495,7 +2466,7 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
return node ? node.isExecuting() : false;
|
||||
}
|
||||
|
||||
isListDescandent(path: string) {
|
||||
private isListDescandent(path: string) {
|
||||
const node = this.findNode(path);
|
||||
let parent = node?.getParent();
|
||||
while (parent) {
|
||||
|
|
@ -2507,10 +2478,63 @@ export class RunningTree<ED extends EntityDict & BaseEntityDict> extends Feature
|
|||
return false;
|
||||
}
|
||||
|
||||
// 判断当前结点是否在:next的路径上
|
||||
// 当前判断规则是:在:next的分岔结点上,如果有前项结点,或者:next结点本身是一个create,则不再刷新
|
||||
private isInModiNextBranch(path: string) {
|
||||
if (!path.includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
return false;
|
||||
}
|
||||
const paths = path.split('.');
|
||||
|
||||
if (paths[0].includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
// 根结点就是:next,这时候还是要取的
|
||||
return false;
|
||||
}
|
||||
let iter = 1;
|
||||
while(iter < paths.length) {
|
||||
if (paths[iter].includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
const pathPrev = paths.slice(0, iter).join('.') + paths[iter].replace(MODI_NEXT_PATH_SUFFIX, '');
|
||||
|
||||
const node = this.findNode(pathPrev);
|
||||
if (node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// 还有一种情况,这个:next结点是创建出来的
|
||||
const pathNext = paths.slice(0, iter + 1).join('.')
|
||||
const nodeNext = this.findNode(pathNext);
|
||||
if (nodeNext instanceof SingleNode) {
|
||||
const id = nodeNext.getId();
|
||||
const [modi] = this.cache.get('modi', {
|
||||
data: {
|
||||
id: 1,
|
||||
},
|
||||
filter: {
|
||||
action: 'create',
|
||||
targetEntity: nodeNext.getEntity() as string,
|
||||
filter: {
|
||||
id,
|
||||
},
|
||||
}
|
||||
});
|
||||
if (modi) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
iter ++;
|
||||
}
|
||||
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
async refresh(path: string, pageNumber?: number) {
|
||||
/* if (path.includes(MODI_NEXT_PATH_SUFFIX)) {
|
||||
if (this.isInModiNextBranch(path) || this.isListDescandent(path)) {
|
||||
return;
|
||||
} */
|
||||
}
|
||||
const node = this.findNode(path);
|
||||
if (!node?.isLoading()) {
|
||||
if (node instanceof ListNode) {
|
||||
|
|
|
|||
|
|
@ -709,15 +709,7 @@ const oakBehavior = Behavior<
|
|||
this.oakOption.lifetimes?.ready.call(this);
|
||||
|
||||
const { oakFullpath } = this.state;
|
||||
if (
|
||||
oakFullpath && !this.oakOption.stale &&
|
||||
!this.features.runningTree.checkIsInModiNextBranch(
|
||||
oakFullpath
|
||||
) &&
|
||||
!this.features.runningTree.isListDescandent(
|
||||
oakFullpath
|
||||
)
|
||||
) {
|
||||
if (oakFullpath && !this.oakOption.stale) {
|
||||
this.refresh();
|
||||
} else {
|
||||
this.reRender();
|
||||
|
|
@ -1121,9 +1113,7 @@ export function createComponent<
|
|||
return;
|
||||
}
|
||||
const { oakFullpath } = this.state;
|
||||
if (oakFullpath && !option.stale &&
|
||||
!features.runningTree.checkIsInModiNextBranch(oakFullpath) &&
|
||||
!features.runningTree.isListDescandent(oakFullpath)) {
|
||||
if (oakFullpath && !option.stale) {
|
||||
try {
|
||||
await this.refresh();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -979,9 +979,7 @@ export function createComponent<
|
|||
|
||||
try {
|
||||
const { oakFullpath } = this.state;
|
||||
if (oakFullpath && !option.stale &&
|
||||
!features.runningTree.checkIsInModiNextBranch(oakFullpath) &&
|
||||
!features.runningTree.isListDescandent(oakFullpath)) {
|
||||
if (oakFullpath && !option.stale) {
|
||||
await this.refresh();
|
||||
}
|
||||
else {
|
||||
|
|
@ -1049,9 +1047,7 @@ export function createComponent<
|
|||
lifetimes?.show && lifetimes.show.call(this);
|
||||
}
|
||||
const { oakFullpath } = this.state;
|
||||
if (oakFullpath && !option.stale &&
|
||||
!features.runningTree.checkIsInModiNextBranch(oakFullpath) &&
|
||||
!features.runningTree.isListDescandent(oakFullpath)) {
|
||||
if (oakFullpath && !option.stale) {
|
||||
this.refresh();
|
||||
}
|
||||
else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue