fix(mobile): persist trending query

This commit is contained in:
Stephen Zhou 2025-07-08 17:43:27 +08:00
parent 7a95a159f7
commit 684dc53379
No known key found for this signature in database
4 changed files with 32 additions and 4 deletions

View File

@ -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",

View File

@ -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

View File

@ -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(() => {

View File

@ -32,6 +32,9 @@ export const Trending = ({
lang: discoverLanguage === "all" ? undefined : discoverLanguage,
limit: 20,
}).then((res) => res.data),
meta: {
persist: true,
},
})
const navigation = useNavigation()