fix: stop a settings search for "recover" from offering Reading

This commit is contained in:
Linus Rath
2026-10-31 13:52:07 +01:00
parent b17d4d4069
commit 7eb7289472
2 changed files with 17 additions and 0 deletions
@@ -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);
});
});
+7
View File
@@ -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);
}
}