fix(mobile): persist trending query
This commit is contained in:
parent
7a95a159f7
commit
684dc53379
|
|
@ -307,6 +307,7 @@
|
|||
"${PODS_CONFIGURATION_BUILD_DIR}/PromisesObjC/FBLPromises_Privacy.bundle",
|
||||
"${PODS_CONFIGURATION_BUILD_DIR}/PromisesSwift/Promises_Privacy.bundle",
|
||||
"${PODS_CONFIGURATION_BUILD_DIR}/RCT-Folly/RCT-Folly_privacy.bundle",
|
||||
"${PODS_CONFIGURATION_BUILD_DIR}/RNDeviceInfo/RNDeviceInfoPrivacyInfo.bundle",
|
||||
"${PODS_CONFIGURATION_BUILD_DIR}/RNSVG/RNSVGFilters.bundle",
|
||||
"${PODS_CONFIGURATION_BUILD_DIR}/ReachabilitySwift/ReachabilitySwift.bundle",
|
||||
"${PODS_CONFIGURATION_BUILD_DIR}/React-Core/React-Core_privacy.bundle",
|
||||
|
|
@ -346,6 +347,7 @@
|
|||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/FBLPromises_Privacy.bundle",
|
||||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/Promises_Privacy.bundle",
|
||||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RCT-Folly_privacy.bundle",
|
||||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RNDeviceInfoPrivacyInfo.bundle",
|
||||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/RNSVGFilters.bundle",
|
||||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/ReachabilitySwift.bundle",
|
||||
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/React-Core_privacy.bundle",
|
||||
|
|
|
|||
|
|
@ -2,14 +2,31 @@ import { persistQueryClient } from "@tanstack/react-query-persist-client"
|
|||
|
||||
import { kvStoragePersister, queryClient } from "../lib/query-client"
|
||||
|
||||
declare module "@tanstack/react-query" {
|
||||
interface Meta {
|
||||
queryMeta: { persist?: boolean }
|
||||
}
|
||||
|
||||
interface Register extends Meta {}
|
||||
}
|
||||
|
||||
export const hydrateSettings = () => {}
|
||||
export const hydrateQueryClient = () => {
|
||||
persistQueryClient({
|
||||
queryClient,
|
||||
persister: kvStoragePersister,
|
||||
dehydrateOptions: {
|
||||
shouldDehydrateQuery(query) {
|
||||
return query.queryKey.includes("cache")
|
||||
shouldDehydrateQuery: (query) => {
|
||||
if (!query.meta?.persist) return false
|
||||
const queryIsReadyForPersistence = query.state.status === "success"
|
||||
if (queryIsReadyForPersistence) {
|
||||
return (
|
||||
!((query.state?.data as any)?.pages?.length > 1) &&
|
||||
query.queryKey?.[0] !== "check-eagle"
|
||||
)
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
},
|
||||
shouldDehydrateMutation() {
|
||||
return false
|
||||
|
|
|
|||
|
|
@ -129,16 +129,22 @@ export const RecommendationTab: TabComponent<{
|
|||
const discoverLanguage = useUISettingKey("discoverLanguage")
|
||||
|
||||
const { data, isLoading } = useQuery({
|
||||
queryKey: ["rsshub-popular", "cache", tab.value, discoverLanguage],
|
||||
queryKey: ["rsshub-popular", tab.value, discoverLanguage],
|
||||
queryFn: () =>
|
||||
fetchRsshubPopular(tab.value, LanguageMap[discoverLanguage]).then((res) => res.data),
|
||||
staleTime: 1000 * 60 * 60 * 24, // 1 day
|
||||
meta: {
|
||||
persist: true,
|
||||
},
|
||||
})
|
||||
|
||||
const { data: analysisData, isLoading: isAnalysisLoading } = useQuery({
|
||||
queryKey: ["rsshub-analysis", "cache", discoverLanguage],
|
||||
queryKey: ["rsshub-analysis", discoverLanguage],
|
||||
queryFn: () => fetchRsshubAnalysis(LanguageMap[discoverLanguage]).then((res) => res.data),
|
||||
staleTime: 1000 * 60 * 60 * 24, // 1 day
|
||||
meta: {
|
||||
persist: true,
|
||||
},
|
||||
})
|
||||
|
||||
const keys = useMemo(() => {
|
||||
|
|
|
|||
|
|
@ -32,6 +32,9 @@ export const Trending = ({
|
|||
lang: discoverLanguage === "all" ? undefined : discoverLanguage,
|
||||
limit: 20,
|
||||
}).then((res) => res.data),
|
||||
meta: {
|
||||
persist: true,
|
||||
},
|
||||
})
|
||||
const navigation = useNavigation()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue