Browse Source

RELEASE | 2.3

master 2.3
Vitalik 7 months ago
parent
commit
f8d2723c1d
  1. 2
      android/app/build.gradle
  2. 28
      ios/taskme2.xcodeproj/project.pbxproj
  3. 47
      src/shared/hooks/use-flat-list.hook.ts

2
android/app/build.gradle

@ -26,7 +26,7 @@ android {
applicationId "com.app.task_me" applicationId "com.app.task_me"
minSdkVersion rootProject.ext.minSdkVersion minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 229 versionCode 230
versionName "2.3" versionName "2.3"
resValue "string", "build_config_package", "com.app.task_me" resValue "string", "build_config_package", "com.app.task_me"
} }

28
ios/taskme2.xcodeproj/project.pbxproj

@ -753,10 +753,7 @@
"-DFOLLY_MOBILE=1", "-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1", "-DFOLLY_USE_LIBCPP=1",
); );
OTHER_LDFLAGS = ( OTHER_LDFLAGS = "$(inherited) ";
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -771,7 +768,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = taskme2/taskme2Stage.Debug.entitlements; CODE_SIGN_ENTITLEMENTS = taskme2/taskme2Stage.Debug.entitlements;
CURRENT_PROJECT_VERSION = 29; CURRENT_PROJECT_VERSION = 33;
DEVELOPMENT_TEAM = HQ3J3TDPR2; DEVELOPMENT_TEAM = HQ3J3TDPR2;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
@ -1039,10 +1036,7 @@
"-DFOLLY_MOBILE=1", "-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1", "-DFOLLY_USE_LIBCPP=1",
); );
OTHER_LDFLAGS = ( OTHER_LDFLAGS = "$(inherited) ";
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos; SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;
@ -1058,7 +1052,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = taskme2/taskme2Stage.Release.entitlements; CODE_SIGN_ENTITLEMENTS = taskme2/taskme2Stage.Release.entitlements;
CURRENT_PROJECT_VERSION = 29; CURRENT_PROJECT_VERSION = 33;
DEVELOPMENT_TEAM = HQ3J3TDPR2; DEVELOPMENT_TEAM = HQ3J3TDPR2;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -1338,7 +1332,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = taskme2/taskme2.entitlements; CODE_SIGN_ENTITLEMENTS = taskme2/taskme2.entitlements;
CURRENT_PROJECT_VERSION = 29; CURRENT_PROJECT_VERSION = 33;
DEVELOPMENT_TEAM = HQ3J3TDPR2; DEVELOPMENT_TEAM = HQ3J3TDPR2;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
@ -1476,7 +1470,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO; ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = taskme2/taskme2.entitlements; CODE_SIGN_ENTITLEMENTS = taskme2/taskme2.entitlements;
CURRENT_PROJECT_VERSION = 29; CURRENT_PROJECT_VERSION = 33;
DEVELOPMENT_TEAM = HQ3J3TDPR2; DEVELOPMENT_TEAM = HQ3J3TDPR2;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
"$(inherited)", "$(inherited)",
@ -1680,10 +1674,7 @@
"-DFOLLY_MOBILE=1", "-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1", "-DFOLLY_USE_LIBCPP=1",
); );
OTHER_LDFLAGS = ( OTHER_LDFLAGS = "$(inherited) ";
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos; SDKROOT = iphoneos;
}; };
@ -1761,10 +1752,7 @@
"-DFOLLY_MOBILE=1", "-DFOLLY_MOBILE=1",
"-DFOLLY_USE_LIBCPP=1", "-DFOLLY_USE_LIBCPP=1",
); );
OTHER_LDFLAGS = ( OTHER_LDFLAGS = "$(inherited) ";
"$(inherited)",
" ",
);
REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native"; REACT_NATIVE_PATH = "${PODS_ROOT}/../../node_modules/react-native";
SDKROOT = iphoneos; SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES; VALIDATE_PRODUCT = YES;

47
src/shared/hooks/use-flat-list.hook.ts

@ -35,8 +35,9 @@ const getDefaultProps = () => {
} }
export const useFlatList = <T>(props: IProps<T>) => { export const useFlatList = <T>(props: IProps<T>) => {
if (!props.fetchItems) if (!props.fetchItems) {
throw new Error('Use flat list need a fetchItems function') throw new Error('Use flat list need a fetchItems function')
}
props = Object.assign(getDefaultProps(), props) props = Object.assign(getDefaultProps(), props)
@ -58,8 +59,11 @@ export const useFlatList = <T>(props: IProps<T>) => {
useEffect(() => { useEffect(() => {
if (props.skeletonDataKey) { if (props.skeletonDataKey) {
const items = skeletonDataService.get(props.skeletonDataKey) const items = skeletonDataService.get(props.skeletonDataKey)
if (items) setItems(_.defaultTo(items, [])) if (items) {
else setLoading(true) setItems(_.defaultTo(items, []))
} else {
setLoading(true)
}
} }
}, []) }, [])
@ -67,23 +71,31 @@ export const useFlatList = <T>(props: IProps<T>) => {
const { count, page, limit } = loadParams.current const { count, page, limit } = loadParams.current
if (firstFetch) { if (firstFetch) {
if (isInit || !props.skeletonDataKey) setLoading(true) if (isInit || !props.skeletonDataKey) {
setLoading(true)
}
loadParams.current.page = defaultProps.page loadParams.current.page = defaultProps.page
loadParams.current.count = undefined loadParams.current.count = undefined
} else if (blockLoadingRef.current) return } else if (blockLoadingRef.current) {
else if ((count && page > Math.ceil(count / limit)) || count === 0)
return return
} else if ((count && page > Math.ceil(count / limit)) || count === 0) {
return
}
setIsLoadingNext(true) setIsLoadingNext(true)
blockLoadingRef.current = true blockLoadingRef.current = true
try { try {
if (props.clearWhenReload) setItems([]) if (props.clearWhenReload) {
setItems([])
}
const response = props.serrializatorResponse( const response = props.serrializatorResponse(
await props.fetchItems({ params: loadParams.current }), await props.fetchItems({ params: loadParams.current }),
) )
if (!response) throw {} if (!response) {
throw {}
}
loadParams.current = { loadParams.current = {
...props.loadParams, ...props.loadParams,
@ -94,19 +106,24 @@ export const useFlatList = <T>(props: IProps<T>) => {
} }
const fetchedItems = props.serrializatorItems(response.data.items) const fetchedItems = props.serrializatorItems(response.data.items)
if (firstFetch) setItems(fetchedItems) if (firstFetch) {
else setItems([...items, ...fetchedItems]) setItems(fetchedItems)
} else {
setItems([...items, ...fetchedItems])
}
setTotalCount(response.data.count) setTotalCount(response.data.count)
if (!isInit) { if (!isInit) {
if (props.skeletonDataKey) if (props.skeletonDataKey) {
skeletonDataService.set(props.skeletonDataKey, fetchedItems) skeletonDataService.set(props.skeletonDataKey, fetchedItems)
}
setIsInit(true) setIsInit(true)
} }
} catch (e) { } catch (e) {
console.log(e) console.log(e)
setItems([]) setItems([])
loadParams.current.count = 0
} }
blockLoadingRef.current = false blockLoadingRef.current = false
@ -131,11 +148,15 @@ export const useFlatList = <T>(props: IProps<T>) => {
} }
useEffect(() => { useEffect(() => {
if (props.needInit) fetchItems(true) if (props.needInit) {
fetchItems(true)
}
}, []) }, [])
const loadAll = () => { const loadAll = () => {
if (!loadParams.current.count) return if (!loadParams.current.count) {
return
}
setLoadParams({ limit: loadParams.current.count }) setLoadParams({ limit: loadParams.current.count })
} }

Loading…
Cancel
Save