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

28
ios/taskme2.xcodeproj/project.pbxproj

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

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

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

Loading…
Cancel
Save