|
|
|
@ -1,11 +1,4 @@
@@ -1,11 +1,4 @@
|
|
|
|
|
import React, { |
|
|
|
|
FC, |
|
|
|
|
useCallback, |
|
|
|
|
useEffect, |
|
|
|
|
useMemo, |
|
|
|
|
useRef, |
|
|
|
|
useState, |
|
|
|
|
} from 'react' |
|
|
|
|
import React, { FC, useCallback, useEffect, useMemo, useState } from 'react' |
|
|
|
|
import { ScrollView, StyleSheet, TouchableOpacity, View } from 'react-native' |
|
|
|
|
import { |
|
|
|
|
$size, |
|
|
|
@ -40,7 +33,8 @@ export const HomeScreen: FC<IProps> = ({ navigation }) => {
@@ -40,7 +33,8 @@ export const HomeScreen: FC<IProps> = ({ navigation }) => {
|
|
|
|
|
|
|
|
|
|
const [searchValue, setValue] = useState<string>(null) |
|
|
|
|
const [isOpenDrawer, setDrawer] = useState<boolean>(false) |
|
|
|
|
const countsRef = useRef(defaultCountsState) |
|
|
|
|
const [counts, setCounts] = useState(defaultCountsState) |
|
|
|
|
|
|
|
|
|
const taskFilter = useTaskFilter({ |
|
|
|
|
onSubmit: () => { |
|
|
|
|
setDrawer(false) |
|
|
|
@ -65,39 +59,31 @@ export const HomeScreen: FC<IProps> = ({ navigation }) => {
@@ -65,39 +59,31 @@ export const HomeScreen: FC<IProps> = ({ navigation }) => {
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
|
if (!searchValue) countsRef.current = defaultCountsState |
|
|
|
|
if (!searchValue) setCounts(counts) |
|
|
|
|
}, [searchValue]) |
|
|
|
|
|
|
|
|
|
const searchResult = useMemo( |
|
|
|
|
() => getHomeSearchResult(countsRef.current, searchValue), |
|
|
|
|
[ |
|
|
|
|
searchValue, |
|
|
|
|
countsRef.current.tasks, |
|
|
|
|
countsRef.current.executors, |
|
|
|
|
countsRef.current.groups, |
|
|
|
|
], |
|
|
|
|
() => getHomeSearchResult(counts, searchValue), |
|
|
|
|
[searchValue, counts], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
const setTasksCount = useCallback( |
|
|
|
|
count => { |
|
|
|
|
countsRef.current.tasks = count |
|
|
|
|
}, |
|
|
|
|
[countsRef.current], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
const setExecutorsCount = useCallback( |
|
|
|
|
count => { |
|
|
|
|
countsRef.current.executors = count |
|
|
|
|
}, |
|
|
|
|
[countsRef.current], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
const setGroupsCount = useCallback( |
|
|
|
|
count => { |
|
|
|
|
countsRef.current.groups = count |
|
|
|
|
}, |
|
|
|
|
[countsRef.current], |
|
|
|
|
) |
|
|
|
|
const setTasksCount = count => |
|
|
|
|
setCounts({ |
|
|
|
|
...counts, |
|
|
|
|
tasks: count, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const setExecutorsCount = count => |
|
|
|
|
setCounts({ |
|
|
|
|
...counts, |
|
|
|
|
executors: count, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const setGroupsCount = count => |
|
|
|
|
setCounts({ |
|
|
|
|
...counts, |
|
|
|
|
groups: count, |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
const openDrawer = useCallback(() => { |
|
|
|
|
setDrawer(true) |
|
|
|
|