mirror of
https://github.com/bulwarkmail/native.git
synced 2026-11-04 16:06:41 +00:00
fix: leave contact selection and search with back before leaving the tab
This commit is contained in:
@@ -16,6 +16,8 @@ import * as FileSystem from 'expo-file-system/legacy';
|
|||||||
import * as Sharing from 'expo-sharing';
|
import * as Sharing from 'expo-sharing';
|
||||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||||
import { useNavigation } from '@react-navigation/native';
|
import { useNavigation } from '@react-navigation/native';
|
||||||
|
import { useBackWhileFocused } from '../lib/use-back-while-focused';
|
||||||
|
import { listBackStep } from '../lib/list-back';
|
||||||
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
import type { NativeStackNavigationProp } from '@react-navigation/native-stack';
|
||||||
import {
|
import {
|
||||||
Search, Plus, UserCircle, X, Menu, Trash2, Tag, FolderInput, Upload, CheckSquare, Share2,
|
Search, Plus, UserCircle, X, Menu, Trash2, Tag, FolderInput, Upload, CheckSquare, Share2,
|
||||||
@@ -232,6 +234,17 @@ export default function ContactsScreen({ onOpenContact, activeContactId = null }
|
|||||||
|
|
||||||
const clearSelection = () => setSelection(new Set());
|
const clearSelection = () => setSelection(new Set());
|
||||||
|
|
||||||
|
// Back leaves selection mode, then the search, before it leaves the tab.
|
||||||
|
const backStep = listBackStep({ selecting: selectionMode, searching: searchActive || searchQuery.length > 0 });
|
||||||
|
useBackWhileFocused(backStep !== 'leave', () => {
|
||||||
|
if (backStep === 'clear-selection') {
|
||||||
|
clearSelection();
|
||||||
|
} else {
|
||||||
|
setSearchQuery('');
|
||||||
|
setSearchActive(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const doBulkDelete = async () => {
|
const doBulkDelete = async () => {
|
||||||
const ids = Array.from(selection);
|
const ids = Array.from(selection);
|
||||||
setConfirmBulkDelete(false);
|
setConfirmBulkDelete(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user