mirror of
https://github.com/bulwarkmail/native.git
synced 2026-10-31 16:06:32 +00:00
fix: stop a settings search for "recover" from offering Reading
This commit is contained in:
@@ -22,4 +22,14 @@ describe('settings search for Delegates and Recover deleted items', () => {
|
||||
expect(finds('recovery', 'Recover deleted items', 'emptied')).toBe(true);
|
||||
expect(finds('recovery', 'Recover deleted items', 'colleague')).toBe(false);
|
||||
});
|
||||
|
||||
// The delete action's warning ("... cannot be recovered") put Reading in
|
||||
// the results, and it has nothing about recovering.
|
||||
it('finds "recover" in Recover deleted items only, not in Reading', () => {
|
||||
const q = normalizeSettingsQuery('recover');
|
||||
expect(tabMatchesQuery(index, 'recovery', 'Recover deleted items', q)).toBe(true);
|
||||
expect(tabMatchesQuery(index, 'reading', 'Reading', q)).toBe(false);
|
||||
// Reading is still found by the delete action itself.
|
||||
expect(tabMatchesQuery(index, 'reading', 'Reading', normalizeSettingsQuery('delete action'))).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -323,6 +323,12 @@ export function getByPath(obj: unknown, path: string): unknown {
|
||||
return cur;
|
||||
}
|
||||
|
||||
// Leaves that say what a setting does once picked, not what it is: the
|
||||
// delete action's warning ("... cannot be recovered") made a search for
|
||||
// "recover" offer Reading, which has nothing about recovering. The webmail
|
||||
// indexes labels only.
|
||||
const UNSEARCHED_LEAVES = new Set(['warning']);
|
||||
|
||||
// Every string leaf key below `path`.
|
||||
export function collectStringKeys(node: unknown, path: string, sink: string[]): void {
|
||||
if (typeof node === 'string') {
|
||||
@@ -331,6 +337,7 @@ export function collectStringKeys(node: unknown, path: string, sink: string[]):
|
||||
}
|
||||
if (!node || typeof node !== 'object' || Array.isArray(node)) return;
|
||||
for (const [key, value] of Object.entries(node as Dictionary)) {
|
||||
if (typeof value === 'string' && UNSEARCHED_LEAVES.has(key)) continue;
|
||||
collectStringKeys(value, `${path}.${key}`, sink);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user