-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "fix: when selecting categories, the selected categories get r…
…eset"
- Loading branch information
1 parent
5037479
commit e9d5f82
Showing
4 changed files
with
27 additions
and
49 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import {useFocusEffect} from '@react-navigation/native'; | ||
import {useFocusEffect, useIsFocused} from '@react-navigation/native'; | ||
import lodashSortBy from 'lodash/sortBy'; | ||
import React, {useCallback, useEffect, useMemo, useState} from 'react'; | ||
import {ActivityIndicator, View} from 'react-native'; | ||
|
@@ -23,7 +23,6 @@ import TableListItemSkeleton from '@components/Skeletons/TableRowSkeleton'; | |
import Text from '@components/Text'; | ||
import TextLink from '@components/TextLink'; | ||
import useAutoTurnSelectionModeOffWhenHasNoActiveOption from '@hooks/useAutoTurnSelectionModeOffWhenHasNoActiveOption'; | ||
import useCleanupSelectedOptions from '@hooks/useCleanupSelectedOptions'; | ||
import useEnvironment from '@hooks/useEnvironment'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useMobileSelectionMode from '@hooks/useMobileSelectionMode'; | ||
|
@@ -71,6 +70,7 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { | |
const [selectedCategories, setSelectedCategories] = useState<Record<string, boolean>>({}); | ||
const [isDownloadFailureModalVisible, setIsDownloadFailureModalVisible] = useState(false); | ||
const [deleteCategoriesConfirmModalVisible, setDeleteCategoriesConfirmModalVisible] = useState(false); | ||
const isFocused = useIsFocused(); | ||
const {environmentURL} = useEnvironment(); | ||
const policyId = route.params.policyID ?? '-1'; | ||
Check failure on line 75 in src/pages/workspace/categories/WorkspaceCategoriesPage.tsx GitHub Actions / Changed files ESLint check
|
||
const backTo = route.params?.backTo; | ||
|
@@ -98,8 +98,12 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { | |
}, [fetchCategories]), | ||
); | ||
|
||
const cleanupSelectedOption = useCallback(() => setSelectedCategories({}), []); | ||
useCleanupSelectedOptions(cleanupSelectedOption); | ||
useEffect(() => { | ||
if (isFocused) { | ||
return; | ||
} | ||
setSelectedCategories({}); | ||
}, [isFocused]); | ||
|
||
const categoryList = useMemo<PolicyOption[]>( | ||
() => | ||
|
@@ -147,10 +151,6 @@ function WorkspaceCategoriesPage({route}: WorkspaceCategoriesPageProps) { | |
}; | ||
|
||
const navigateToCategorySettings = (category: PolicyOption) => { | ||
if (isSmallScreenWidth && selectionMode?.isEnabled) { | ||
toggleCategory(category); | ||
return; | ||
} | ||
Navigation.navigate( | ||
isQuickSettingsFlow | ||
? ROUTES.SETTINGS_CATEGORY_SETTINGS.getRoute(policyId, category.keyForList, backTo) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import {useFocusEffect} from '@react-navigation/native'; | ||
import {useFocusEffect, useIsFocused} from '@react-navigation/native'; | ||
import lodashSortBy from 'lodash/sortBy'; | ||
import React, {useCallback, useMemo, useState} from 'react'; | ||
import React, {useCallback, useEffect, useMemo, useState} from 'react'; | ||
import {ActivityIndicator, View} from 'react-native'; | ||
import {useOnyx} from 'react-native-onyx'; | ||
import Button from '@components/Button'; | ||
|
@@ -22,7 +22,6 @@ import CustomListHeader from '@components/SelectionListWithModal/CustomListHeade | |
import TableListItemSkeleton from '@components/Skeletons/TableRowSkeleton'; | ||
import Text from '@components/Text'; | ||
import TextLink from '@components/TextLink'; | ||
import useCleanupSelectedOptions from '@hooks/useCleanupSelectedOptions'; | ||
import useEnvironment from '@hooks/useEnvironment'; | ||
import useLocalize from '@hooks/useLocalize'; | ||
import useMobileSelectionMode from '@hooks/useMobileSelectionMode'; | ||
|
@@ -65,6 +64,7 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) { | |
const [isDownloadFailureModalVisible, setIsDownloadFailureModalVisible] = useState(false); | ||
const [isDeleteTagsConfirmModalVisible, setIsDeleteTagsConfirmModalVisible] = useState(false); | ||
const [isOfflineModalVisible, setIsOfflineModalVisible] = useState(false); | ||
const isFocused = useIsFocused(); | ||
const policyID = route.params.policyID ?? '-1'; | ||
Check failure on line 68 in src/pages/workspace/tags/WorkspaceTagsPage.tsx GitHub Actions / Changed files ESLint check
|
||
const backTo = route.params.backTo; | ||
const policy = usePolicy(policyID); | ||
|
@@ -87,8 +87,12 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) { | |
|
||
useFocusEffect(fetchTags); | ||
|
||
const cleanupSelectedOption = useCallback(() => setSelectedTags({}), []); | ||
useCleanupSelectedOptions(cleanupSelectedOption); | ||
useEffect(() => { | ||
if (isFocused) { | ||
return; | ||
} | ||
setSelectedTags({}); | ||
}, [isFocused]); | ||
|
||
const getPendingAction = (policyTagList: PolicyTagList): PendingAction | undefined => { | ||
if (!policyTagList) { | ||
|
@@ -172,10 +176,6 @@ function WorkspaceTagsPage({route}: WorkspaceTagsPageProps) { | |
}; | ||
|
||
const navigateToTagSettings = (tag: TagListItem) => { | ||
if (isSmallScreenWidth && selectionMode?.isEnabled) { | ||
toggleTag(tag); | ||
return; | ||
} | ||
if (tag.orderWeight !== undefined) { | ||
Navigation.navigate( | ||
isQuickSettingsFlow ? ROUTES.SETTINGS_TAG_LIST_VIEW.getRoute(policyID, tag.orderWeight, backTo) : ROUTES.WORKSPACE_TAG_LIST_VIEW.getRoute(policyID, tag.orderWeight), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters