mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) Fix reporting of errors when saving cells by clicking away, and deduplicate memos.
Test Plan: Enhanced the test case for memos to check these cases too (fails without this fix). Reviewers: paulfitz Reviewed By: paulfitz Differential Revision: https://phab.getgrist.com/D2876
This commit is contained in:
@@ -25,11 +25,17 @@ export type PermissionSetWithContext = PermissionSetWithContextOf<PermissionSet<
|
||||
// Accumulator for memos of relevant rules.
|
||||
export type MemoSet = PermissionSet<string[]>;
|
||||
|
||||
// Merge MemoSets straightforwardly, by concatenation.
|
||||
// Merge MemoSets by collecting all memos with de-duplication.
|
||||
export function mergeMemoSets(psets: MemoSet[]): MemoSet {
|
||||
const result: Partial<MemoSet> = {};
|
||||
for (const prop of ALL_PERMISSION_PROPS) {
|
||||
result[prop] = ([] as string[]).concat(...psets.map(p => p[prop]));
|
||||
const merged = new Set<string>();
|
||||
for (const p of psets) {
|
||||
for (const memo of p[prop]) {
|
||||
merged.add(memo);
|
||||
}
|
||||
}
|
||||
result[prop] = [...merged];
|
||||
}
|
||||
return result as MemoSet;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user