Files
native/src/lib/files-back.ts
T
Linus Rath 4fdf39aa08 fix: go up one folder on Android back in the Files tab
Back inside a Files subfolder switched to the Mail tab. It now closes an
open preview, then leaves selection mode, then goes up one folder, and
only switches tabs at the root. `filesBackStep` holds that order.
2026-09-24 19:28:37 +02:00

20 lines
735 B
TypeScript

/** What Android back does in the Files tab. */
export type FilesBackStep = 'close-preview' | 'clear-selection' | 'folder-up' | 'leave';
/**
* Back works through the tab's own layers, innermost first: an open preview
* closes, then selection mode ends (like the header's X), then the folder
* goes up one level. Only at the root with nothing open does it `leave`,
* i.e. fall through to navigation, which switches to the Mail tab.
*/
export function filesBackStep(state: {
previewOpen: boolean;
selecting: boolean;
folderDepth: number;
}): FilesBackStep {
if (state.previewOpen) return 'close-preview';
if (state.selecting) return 'clear-selection';
if (state.folderDepth > 0) return 'folder-up';
return 'leave';
}