Merge branch 'dev' of codeup.aliyun.com:61c14a7efa282c88e103c23f/oak-frontend-base into dev

This commit is contained in:
Xu Chang 2022-05-24 20:11:56 +08:00
commit 2774d39961
1 changed files with 17 additions and 5 deletions

View File

@ -1,6 +1,6 @@
import assert from "assert"; import assert from "assert";
import { assign, cloneDeep, keys, omit, pick, pull, set, unset } from "lodash"; import { assign, cloneDeep, keys, omit, pick, pull, set, unset } from "lodash";
import { combineFilters, contains } from "oak-domain/lib/store/filter"; import { combineFilters, contains, repel } from "oak-domain/lib/store/filter";
import { judgeRelation } from "oak-domain/lib/store/relation"; import { judgeRelation } from "oak-domain/lib/store/relation";
import { EntityDict, Aspect, Context, DeduceUpdateOperation, StorageSchema, OpRecord, SelectRowShape, DeduceCreateOperation, DeduceOperation, UpdateOpResult, SelectOpResult } from "oak-domain/lib/types"; import { EntityDict, Aspect, Context, DeduceUpdateOperation, StorageSchema, OpRecord, SelectRowShape, DeduceCreateOperation, DeduceOperation, UpdateOpResult, SelectOpResult } from "oak-domain/lib/types";
import { Action, Feature, Pagination } from "../initialize"; import { Action, Feature, Pagination } from "../initialize";
@ -110,6 +110,10 @@ abstract class Node<ED extends EntityDict, T extends keyof ED, Cxt extends Conte
protected contains(filter: ED[T]['Selection']['filter'], conditionalFilter: ED[T]['Selection']['filter']) { protected contains(filter: ED[T]['Selection']['filter'], conditionalFilter: ED[T]['Selection']['filter']) {
return contains(this.entity, this.schema, filter, conditionalFilter); return contains(this.entity, this.schema, filter, conditionalFilter);
} }
protected repel(filter1: ED[T]['Selection']['filter'], filter2: ED[T]['Selection']['filter']) {
return repel(this.entity, this.schema, filter1, filter2);
}
} }
const DEFAULT_PAGINATION: Pagination = { const DEFAULT_PAGINATION: Pagination = {
@ -382,7 +386,7 @@ class SingleNode<ED extends EntityDict,
async onCachSync(records: OpRecord<ED>[]): Promise<void> { async onCachSync(records: OpRecord<ED>[]): Promise<void> {
let needReGetValue = false; let needReGetValue = false;
if (this.refreshing) { if (this.refreshing || !this.id) {
return; return;
} }
for (const record of records) { for (const record of records) {
@ -398,8 +402,11 @@ class SingleNode<ED extends EntityDict,
const { e, f } = record as UpdateOpResult<ED, T>; const { e, f } = record as UpdateOpResult<ED, T>;
if (e === this.entity) { if (e === this.entity) {
// todo 这里更严格应该考虑f对当前filter有无影响同上面一样这里可能没有完整的供f用的cache数据 // todo 这里更严格应该考虑f对当前filter有无影响同上面一样这里可能没有完整的供f用的cache数据
if (f && typeof f.id === ) if (!this.repel(f || {}, {
needReGetValue = true; id: this.id,
})) {
needReGetValue = true;
}
} }
break; break;
} }
@ -423,7 +430,12 @@ class SingleNode<ED extends EntityDict,
} }
} }
if (needReGetValue) { if (needReGetValue) {
await this.reGetValue(); const value = await this.cache.get(this.entity, {
data: this.projection,
filter: {
id: this.id,
}
} as any, 'onCacheSync');
} }
} }