Skip to content

Commit

Permalink
feat: remove reduceRefetch config
Browse files Browse the repository at this point in the history
  • Loading branch information
DIYgod committed Jan 1, 2025
1 parent 19eea97 commit 43b0ac7
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 40 deletions.
1 change: 0 additions & 1 deletion apps/renderer/src/atoms/settings/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const createDefaultSettings = (): GeneralSettings => ({
// Data control
dataPersist: true,
sendAnonymousData: true,
reduceRefetch: true,
showQuickTimeline: true,

autoGroup: true,
Expand Down
4 changes: 0 additions & 4 deletions apps/renderer/src/modules/settings/tabs/general.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ export const SettingGeneral = () => {
description: t("general.show_quick_timeline.description"),
}),

defineSettingItem("reduceRefetch", {
label: t("general.reduce_refetch.label"),
description: t("general.reduce_refetch.description"),
}),
{ type: "title", value: t("general.unread") },

defineSettingItem("scrollMarkUnread", {
Expand Down
16 changes: 3 additions & 13 deletions apps/renderer/src/providers/invalidate-query-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ import { IN_ELECTRON } from "@follow/shared/constants"
import { useQueryClient } from "@tanstack/react-query"
import { useEffect, useRef } from "react"

import { useGeneralSettingKey } from "~/atoms/settings/general"
import { appLog } from "~/lib/log"

const defaultStaleTime = 600_000 // 10min
const maxStaleTime = 6 * 60 * (60 * 1000) // 6hr
const staleTime = 600_000 // 10min

export class ElectronCloseEvent extends Event {
static type = "electron-close"
Expand All @@ -22,10 +20,6 @@ export class ElectronShowEvent extends Event {
}
}

const useSlateTime = () => {
const reduceRefetch = useGeneralSettingKey("reduceRefetch")
return reduceRefetch ? maxStaleTime : defaultStaleTime
}
/**
* Add a event listener to invalidate all queries
*/
Expand All @@ -48,12 +42,10 @@ const InvalidateQueryProviderElectron = () => {
}
}, [queryClient])

const slateTime = useSlateTime()

useEffect(() => {
const handler = () => {
const now = Date.now()
if (!currentTimeRef.current || now - currentTimeRef.current < slateTime) {
if (!currentTimeRef.current || now - currentTimeRef.current < staleTime) {
appLog(
`Window switch to visible, but skip invalidation, ${currentTimeRef.current ? now - currentTimeRef.current : 0}`,
)
Expand Down Expand Up @@ -90,15 +82,13 @@ const InvalidateQueryProviderWebApp = () => {

const pageVisibility = usePageVisibility()

const slateTime = useSlateTime()

useEffect(() => {
if (currentVisibilityRef.current === pageVisibility) {
return
}

const now = Date.now()
if (now - currentTimeRef.current < slateTime) {
if (now - currentTimeRef.current < staleTime) {
return
}

Expand Down
12 changes: 1 addition & 11 deletions apps/renderer/src/queries/entries.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { useFeedUnreadIsDirty } from "~/atoms/feed"
import { useGeneralSettingKey } from "~/atoms/settings/general"
import { useAuthInfiniteQuery, useAuthQuery } from "~/hooks/common"
import { apiClient } from "~/lib/api-fetch"
import { defineQuery } from "~/lib/defineQuery"
Expand Down Expand Up @@ -126,7 +125,6 @@ export const entries = {
),
}

const maxStaleTime = 6 * 60 * (60 * 1000) // 6 hours
const defaultStaleTime = 10 * (60 * 1000) // 10 minutes

export const useEntries = ({
Expand All @@ -144,7 +142,6 @@ export const useEntries = ({
read?: boolean
isArchived?: boolean
}) => {
const reduceRefetch = useGeneralSettingKey("reduceRefetch")
const fetchUnread = read === false
const feedUnreadDirty = useFeedUnreadIsDirty((feedId as string) || "")

Expand All @@ -165,14 +162,7 @@ export const useEntries = ({
staleTime:
// Force refetch unread entries when feed is dirty
// HACK: disable refetch when the router is pop to previous page
history.isPop
? Infinity
: fetchUnread && feedUnreadDirty
? 0
: // Keep reduce data fetch logic
reduceRefetch
? maxStaleTime
: defaultStaleTime,
history.isPop ? Infinity : fetchUnread && feedUnreadDirty ? 0 : defaultStaleTime,
},
)
}
Expand Down
2 changes: 0 additions & 2 deletions locales/settings/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@
"general.rebuild_database.title": "Rebuild Database",
"general.rebuild_database.warning.line1": "Rebuilding the database will clear all your local data.",
"general.rebuild_database.warning.line2": "Are you sure you want to continue?",
"general.reduce_refetch.description": "Reduce the data refetch of Timeline, to avoid Timeline being refreshed again when switching between different views.",
"general.reduce_refetch.label": "Reduce timeline refetch",
"general.send_anonymous_data.description": "By opting to send anonymized telemetry data, you contribute to improving the overall user experience of Follow.",
"general.send_anonymous_data.label": "Send anonymous data",
"general.show_quick_timeline.description": "Show the quick timeline at the top of the feed list.",
Expand Down
2 changes: 0 additions & 2 deletions locales/settings/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@
"general.rebuild_database.title": "データベースを再構築",
"general.rebuild_database.warning.line1": "データベースの再構築により、すべてのローカルデータが消去されます。",
"general.rebuild_database.warning.line2": "本当に続行しますか?",
"general.reduce_refetch.description": "タイムラインでデータのリフェッチを減らし、異なるビュー間を切り替える際にタイムラインが再度更新されるのを避けます。",
"general.reduce_refetch.label": "リフェッチ頻度",
"general.send_anonymous_data.description": "匿名化されたテレメトリーデータを送信することにより、Follow の全体的なユーザーエクスペリエンスの向上に貢献します。",
"general.send_anonymous_data.label": "匿名データを送信",
"general.show_quick_timeline.description": "フィードリストの最上部にクイックタイムラインを表示する",
Expand Down
2 changes: 0 additions & 2 deletions locales/settings/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@
"general.rebuild_database.title": "重建数据库",
"general.rebuild_database.warning.line1": "重建数据库将清除所有本地数据,且无法恢复。",
"general.rebuild_database.warning.line2": "确定继续?",
"general.reduce_refetch.description": "降低时间线数据的重取频率,以避免在不同视图间切换时时间线被再次刷新。",
"general.reduce_refetch.label": "降低时间线重取频率",
"general.send_anonymous_data.description": "发送匿名用户数据,帮助产品改进和功能迭代。",
"general.send_anonymous_data.label": "发送匿名数据",
"general.show_quick_timeline.description": "在时间线顶部显示列表和分类的时间线快递导航。",
Expand Down
2 changes: 0 additions & 2 deletions locales/settings/zh-HK.json
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@
"general.rebuild_database.title": "重建數據庫",
"general.rebuild_database.warning.line1": "重建數據庫會清除所有本地數據",
"general.rebuild_database.warning.line2": "你確定要繼續嗎?",
"general.reduce_refetch.description": "減少時間軸的數據重新獲取,避免在不同視圖間切換時刷新時間軸。",
"general.reduce_refetch.label": "減少時間軸重新獲取",
"general.send_anonymous_data.description": "選擇發送匿名的遙測數據,將有助於提升 Follow 的整體用戶體驗。",
"general.send_anonymous_data.label": "發送匿名數據",
"general.show_quick_timeline.description": "在訂閱源清單頂部顯示快速時間軸。",
Expand Down
2 changes: 0 additions & 2 deletions locales/settings/zh-TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,6 @@
"general.rebuild_database.title": "重置資料庫",
"general.rebuild_database.warning.line1": "重置資料庫將會清除您所有的本機資料。",
"general.rebuild_database.warning.line2": "您確定要繼續嗎?",
"general.reduce_refetch.description": "降低時間軸資料的重新獲取次數,以避免在不同視圖間切換時時間軸被再次更新。",
"general.reduce_refetch.label": "降低時間軸重新獲取次數",
"general.send_anonymous_data.description": "選擇傳送匿名使用資料,您將幫助改善 Follow 的整體使用體驗。",
"general.send_anonymous_data.label": "傳送匿名資料",
"general.show_quick_timeline.description": "在訂閱源列表頂部顯示快速時間軸。",
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/interface/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export interface GeneralSettings {
jumpOutLinkWarn: boolean
// TTS
voice: string
reduceRefetch: boolean
autoGroup: boolean
/**
* Top timeline for mobile
Expand Down

0 comments on commit 43b0ac7

Please sign in to comment.