refactor(mobile): sperate store package (#3819)
This commit is contained in:
@@ -28,6 +28,7 @@
|
||||
"@follow/legal": "workspace:*",
|
||||
"@follow/models": "workspace:*",
|
||||
"@follow/shared": "workspace:*",
|
||||
"@follow/store": "workspace:*",
|
||||
"@follow/tracker": "workspace:*",
|
||||
"@follow/types": "workspace:*",
|
||||
"@follow/utils": "workspace:*",
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { usePrefetchActions } from "@follow/store/src/action/hooks"
|
||||
import { usePrefetchSessionUser } from "@follow/store/src/user/hooks"
|
||||
import { StatusBar } from "expo-status-bar"
|
||||
import { View } from "react-native"
|
||||
import Animated, { interpolate, useAnimatedStyle } from "react-native-reanimated"
|
||||
@@ -6,11 +8,10 @@ import { useSheet } from "react-native-sheet-transitions"
|
||||
|
||||
import { useBackHandler } from "./hooks/useBackHandler"
|
||||
import { useIntentHandler } from "./hooks/useIntentHandler"
|
||||
import { useMessaging, useUpdateMessagingToken } from "./hooks/useMessaging"
|
||||
import { useOnboarding } from "./hooks/useOnboarding"
|
||||
import { useUnreadCountBadge } from "./hooks/useUnreadCountBadge"
|
||||
import { DebugButton, EnvProfileIndicator } from "./modules/debug"
|
||||
import { usePrefetchActions } from "./store/action/hooks"
|
||||
import { useMessaging, useUpdateMessagingToken } from "./store/messaging/hooks"
|
||||
import { useUnreadCountBadge } from "./store/unread/hooks"
|
||||
import { useOnboarding, usePrefetchSessionUser } from "./store/user/hooks"
|
||||
|
||||
export function App({ children }: { children: React.ReactNode }) {
|
||||
useIntentHandler()
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { defaultGeneralSettings } from "@follow/shared/src/settings/defaults"
|
||||
import type { GeneralSettings } from "@follow/shared/src/settings/interface"
|
||||
import type { FetchEntriesPropsSettings } from "@follow/store/src/entry/types"
|
||||
import { useMemo } from "react"
|
||||
|
||||
import { getDeviceLanguage } from "@/src/lib/i18n"
|
||||
import type { SupportedLanguages } from "@/src/lib/language"
|
||||
@@ -51,3 +53,22 @@ export function useHideAllReadSubscriptions() {
|
||||
const unreadOnly = useGeneralSettingKey("unreadOnly")
|
||||
return hideAllReadSubscriptions && unreadOnly
|
||||
}
|
||||
|
||||
export function getHideAllReadSubscriptions() {
|
||||
const { hideAllReadSubscriptions, unreadOnly } = getGeneralSettings()
|
||||
return hideAllReadSubscriptions && unreadOnly
|
||||
}
|
||||
|
||||
export function useFetchEntriesSettings(): FetchEntriesPropsSettings {
|
||||
const hidePrivateSubscriptionsInTimeline = useGeneralSettingKey(
|
||||
"hidePrivateSubscriptionsInTimeline",
|
||||
)
|
||||
const unreadOnly = useGeneralSettingKey("unreadOnly")
|
||||
return useMemo(
|
||||
() => ({
|
||||
hidePrivateSubscriptionsInTimeline,
|
||||
unreadOnly,
|
||||
}),
|
||||
[hidePrivateSubscriptionsInTimeline, unreadOnly],
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import type { EntryModel, EntryWithTranslation } from "@follow/store/src/entry/types"
|
||||
import { clsx } from "@follow/utils"
|
||||
import { Portal } from "@gorhom/portal"
|
||||
import { useAtom } from "jotai"
|
||||
@@ -7,7 +8,6 @@ import { TouchableOpacity, View } from "react-native"
|
||||
|
||||
import { useUISettingKey } from "@/src/atoms/settings/ui"
|
||||
import { BugCuteReIcon } from "@/src/icons/bug_cute_re"
|
||||
import type { EntryModel, EntryWithTranslation } from "@/src/store/entry/types"
|
||||
|
||||
import { PlatformActivityIndicator } from "../../ui/loading/PlatformActivityIndicator"
|
||||
import { sharedWebViewHeightAtom } from "./atom"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { useIsEntryStarred } from "@follow/store/src/collection/hooks"
|
||||
import { collectionSyncService } from "@follow/store/src/collection/store"
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import ImageEditor from "@react-native-community/image-editor"
|
||||
import { requireNativeModule } from "expo"
|
||||
import * as FileSystem from "expo-file-system"
|
||||
@@ -12,10 +16,6 @@ import { findNodeHandle, Image, Pressable } from "react-native"
|
||||
|
||||
import { isIOS } from "@/src/lib/platform"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { useIsEntryStarred } from "@/src/store/collection/hooks"
|
||||
import { collectionSyncService } from "@/src/store/collection/store"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import { unreadSyncService } from "@/src/store/unread/store"
|
||||
|
||||
import { ContextMenu } from "../context-menu"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { ViewDefinition as ViewDefinitionBase } from "@follow/constants"
|
||||
import { FeedViewType, views as viewsBase } from "@follow/constants"
|
||||
import colors from "tailwindcss/colors"
|
||||
|
||||
import { AnnouncementCuteFiIcon } from "../icons/announcement_cute_fi"
|
||||
import { MicCuteFiIcon } from "../icons/mic_cute_fi"
|
||||
@@ -8,36 +7,28 @@ import { PaperCuteFiIcon } from "../icons/paper_cute_fi"
|
||||
import { PicCuteFiIcon } from "../icons/pic_cute_fi"
|
||||
import { TwitterCuteFiIcon } from "../icons/twitter_cute_fi"
|
||||
import { VideoCuteFiIcon } from "../icons/video_cute_fi"
|
||||
import { accentColor } from "../theme/colors"
|
||||
|
||||
interface ViewDefinitionExtended {
|
||||
icon: React.FC<{ color?: string; height?: number; width?: number }>
|
||||
activeColor: string
|
||||
}
|
||||
const extendMap: Record<FeedViewType, ViewDefinitionExtended> = {
|
||||
[FeedViewType.Articles]: {
|
||||
icon: PaperCuteFiIcon,
|
||||
activeColor: accentColor,
|
||||
},
|
||||
[FeedViewType.SocialMedia]: {
|
||||
icon: TwitterCuteFiIcon,
|
||||
activeColor: colors.sky[500],
|
||||
},
|
||||
[FeedViewType.Pictures]: {
|
||||
icon: PicCuteFiIcon,
|
||||
activeColor: colors.green[500],
|
||||
},
|
||||
[FeedViewType.Videos]: {
|
||||
icon: VideoCuteFiIcon,
|
||||
activeColor: colors.red[500],
|
||||
},
|
||||
[FeedViewType.Audios]: {
|
||||
icon: MicCuteFiIcon,
|
||||
activeColor: colors.purple[500],
|
||||
},
|
||||
[FeedViewType.Notifications]: {
|
||||
icon: AnnouncementCuteFiIcon,
|
||||
activeColor: colors.yellow[500],
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { useHasNotificationActions } from "@follow/store/src/action/hooks"
|
||||
import { useWhoami } from "@follow/store/src/user/hooks"
|
||||
import { getApp } from "@react-native-firebase/app"
|
||||
import type { FirebaseMessagingTypes } from "@react-native-firebase/messaging"
|
||||
import { getMessaging } from "@react-native-firebase/messaging"
|
||||
@@ -11,9 +13,6 @@ import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { requestNotificationPermission } from "@/src/lib/permission"
|
||||
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]/EntryDetailScreen"
|
||||
|
||||
import { useHasNotificationActions } from "../action/hooks"
|
||||
import { useWhoami } from "../user/hooks"
|
||||
|
||||
const FIREBASE_MESSAGING_TOKEN_STORAGE_KEY = "firebase_messaging_token"
|
||||
|
||||
async function saveMessagingToken() {
|
||||
@@ -0,0 +1,21 @@
|
||||
import { isOnboardingFinishedStorageKey } from "@follow/store/src/user/constants"
|
||||
import { useIsNewUser, useWhoami } from "@follow/store/src/user/hooks"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import { kv } from "../lib/kv"
|
||||
import { useNavigation } from "../lib/navigation/hooks"
|
||||
import { OnboardingScreen } from "../screens/OnboardingScreen"
|
||||
|
||||
export function useOnboarding() {
|
||||
const whoami = useWhoami()
|
||||
const isNewUser = useIsNewUser({ enabled: !!whoami })
|
||||
const navigation = useNavigation()
|
||||
useEffect(() => {
|
||||
async function checkOnboarding() {
|
||||
if (isNewUser && !(await kv.get(isOnboardingFinishedStorageKey))) {
|
||||
navigation.presentControllerView(OnboardingScreen, undefined, "fullScreenModal")
|
||||
}
|
||||
}
|
||||
checkOnboarding()
|
||||
}, [isNewUser, navigation])
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import { useUnreadCounts } from "@follow/store/src/unread/hooks"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { useEffect } from "react"
|
||||
|
||||
import { setBadgeCountAsyncWithPermission } from "../lib/permission"
|
||||
|
||||
export function useUnreadCountBadge() {
|
||||
const unreadCount = useUnreadCounts()
|
||||
const { mutate, isPending } = useMutation({
|
||||
mutationFn: (unread: number) => setBadgeCountAsyncWithPermission(unread),
|
||||
})
|
||||
useEffect(() => {
|
||||
if (!isPending) {
|
||||
mutate(unreadCount)
|
||||
}
|
||||
}, [unreadCount, mutate, isPending])
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
import { whoami } from "@follow/store/src/user/getters"
|
||||
import { setFirebaseTracker, setOpenPanelTracker, tracker } from "@follow/tracker"
|
||||
import { getAnalytics } from "@react-native-firebase/analytics"
|
||||
import { nativeApplicationVersion, nativeBuildVersion } from "expo-application"
|
||||
|
||||
import { getUserAgent } from "../lib/native/user-agent"
|
||||
import { op } from "../lib/op"
|
||||
import { whoami } from "../store/user/getters"
|
||||
|
||||
export const initAnalytics = async () => {
|
||||
setOpenPanelTracker(op)
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { getAllUnreadCount } from "@follow/store/src/unread/getter"
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import { whoami } from "@follow/store/src/user/getters"
|
||||
import * as BackgroundTask from "expo-background-task"
|
||||
import * as TaskManager from "expo-task-manager"
|
||||
|
||||
import { getUISettings } from "../atoms/settings/ui"
|
||||
import { unreadSyncService } from "../store/unread/store"
|
||||
import { whoami } from "../store/user/getters"
|
||||
import { setBadgeCountAsyncWithPermission } from "../lib/permission"
|
||||
|
||||
const BACKGROUND_FETCH_TASK = "background-fetch"
|
||||
|
||||
@@ -18,7 +20,9 @@ export async function initBackgroundTask() {
|
||||
}
|
||||
|
||||
try {
|
||||
await unreadSyncService.updateBadgeAtBackground()
|
||||
await unreadSyncService.resetFromRemote()
|
||||
const allUnreadCount = getAllUnreadCount()
|
||||
await setBadgeCountAsyncWithPermission(allUnreadCount)
|
||||
return BackgroundTask.BackgroundTaskResult.Success
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import { whoami } from "@follow/store/src/user/getters"
|
||||
import { getCrashlytics, setAttributes, setUserId } from "@react-native-firebase/crashlytics"
|
||||
|
||||
import { whoami } from "../store/user/getters"
|
||||
|
||||
export const initCrashlytics = async () => {
|
||||
const crashlytics = getCrashlytics()
|
||||
const user = whoami()
|
||||
|
||||
@@ -2,7 +2,6 @@ import { persistQueryClient } from "@tanstack/react-query-persist-client"
|
||||
|
||||
import { kvStoragePersister, queryClient } from "../lib/query-client"
|
||||
|
||||
export { hydrateDatabaseToStore } from "../store"
|
||||
export const hydrateSettings = () => {}
|
||||
export const hydrateQueryClient = () => {
|
||||
persistQueryClient({
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
import { initializeDb } from "@follow/database/src/db"
|
||||
import { hydrateDatabaseToStore } from "@follow/store/src"
|
||||
import { tracker } from "@follow/tracker"
|
||||
import { nativeApplicationVersion } from "expo-application"
|
||||
|
||||
import { getGeneralSettings } from "../atoms/settings/general"
|
||||
import { settingSyncQueue } from "../modules/settings/sync-queue"
|
||||
import { initAnalytics } from "./analytics"
|
||||
import { initializeAppCheck } from "./app-check"
|
||||
@@ -9,7 +11,7 @@ import { initBackgroundTask } from "./background"
|
||||
import { initCrashlytics } from "./crashlytics"
|
||||
import { initializeDayjs } from "./dayjs"
|
||||
import { initDeviceType } from "./device"
|
||||
import { hydrateDatabaseToStore, hydrateQueryClient, hydrateSettings } from "./hydrate"
|
||||
import { hydrateQueryClient, hydrateSettings } from "./hydrate"
|
||||
import { migrateDatabase } from "./migration"
|
||||
import { initializePlayer } from "./player"
|
||||
|
||||
@@ -27,7 +29,13 @@ export const initializeApp = async () => {
|
||||
|
||||
await apm("hydrateSettings", hydrateSettings)
|
||||
let dataHydratedTime = Date.now()
|
||||
await apm("hydrateDatabaseToStore", hydrateDatabaseToStore)
|
||||
await apm("hydrateDatabaseToStore", () => {
|
||||
const { hidePrivateSubscriptionsInTimeline, unreadOnly } = getGeneralSettings()
|
||||
return hydrateDatabaseToStore({
|
||||
hidePrivateSubscriptionsInTimeline,
|
||||
unreadOnly,
|
||||
})
|
||||
})
|
||||
|
||||
dataHydratedTime = Date.now() - dataHydratedTime
|
||||
await apm("hydrateQueryClient", hydrateQueryClient)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
/* eslint-disable no-console */
|
||||
import type { AppType } from "@follow/shared"
|
||||
import { userActions } from "@follow/store/src/user/store"
|
||||
import { FetchError, ofetch } from "ofetch"
|
||||
|
||||
import { InvitationScreen } from "../screens/(modal)/InvitationScreen"
|
||||
import { userActions } from "../store/user/store"
|
||||
import { getCookie } from "./auth"
|
||||
import { getUserAgent } from "./native/user-agent"
|
||||
import { Navigation } from "./navigation/Navigation"
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { expoClient } from "@better-auth/expo/client"
|
||||
import type { authPlugins } from "@follow/shared/src/hono"
|
||||
import { isNewUserQueryKey } from "@follow/store/src/user/constants"
|
||||
import { whoamiQueryKey } from "@follow/store/src/user/hooks"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { inferAdditionalFields, twoFactorClient } from "better-auth/client/plugins"
|
||||
import { createAuthClient } from "better-auth/react"
|
||||
@@ -7,8 +9,6 @@ import type { BetterAuthClientPlugin } from "better-auth/types"
|
||||
import * as SecureStore from "expo-secure-store"
|
||||
import { Platform } from "react-native"
|
||||
|
||||
import { isNewUserQueryKey } from "../store/user/constants"
|
||||
import { whoamiQueryKey } from "../store/user/hooks"
|
||||
import { proxyEnv } from "./proxy-env"
|
||||
import { queryClient } from "./query-client"
|
||||
|
||||
@@ -41,7 +41,7 @@ const serverPlugins = [
|
||||
}),
|
||||
] satisfies BetterAuthClientPlugin[]
|
||||
|
||||
const authClient = createAuthClient({
|
||||
export const authClient = createAuthClient({
|
||||
baseURL: `${proxyEnv.API_URL}/better-auth`,
|
||||
plugins: [
|
||||
twoFactorClient(),
|
||||
|
||||
@@ -11,6 +11,8 @@ import { App } from "./App"
|
||||
import { BottomTabProvider } from "./components/layouts/tabbar/BottomTabProvider"
|
||||
import { BottomTabs } from "./components/layouts/tabbar/BottomTabs"
|
||||
import { initializeApp } from "./initialize"
|
||||
import { apiClient } from "./lib/api-fetch"
|
||||
import { authClient } from "./lib/auth"
|
||||
import { initializeI18n } from "./lib/i18n"
|
||||
import { TabBarPortal } from "./lib/navigation/bottom-tab/TabBarPortal"
|
||||
import { TabRoot } from "./lib/navigation/bottom-tab/TabRoot"
|
||||
@@ -23,6 +25,11 @@ import { SettingsTabScreen } from "./screens/(stack)/(tabs)/settings"
|
||||
import { SubscriptionsTabScreen } from "./screens/(stack)/(tabs)/subscriptions"
|
||||
import { registerSitemap } from "./sitemap"
|
||||
|
||||
// @ts-expect-error
|
||||
globalThis.apiClient = apiClient
|
||||
// @ts-expect-error
|
||||
globalThis.authClient = authClient
|
||||
|
||||
enableFreeze(true)
|
||||
;[Image, LinearGradient].forEach((Component) => {
|
||||
cssInterop(Component, { className: "style" })
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { useIsEntryStarred } from "@follow/store/src/collection/hooks"
|
||||
import { collectionSyncService } from "@follow/store/src/collection/store"
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import { PortalProvider } from "@gorhom/portal"
|
||||
import type { PropsWithChildren } from "react"
|
||||
import { useCallback } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Share, Text, View } from "react-native"
|
||||
|
||||
import { getHideAllReadSubscriptions } from "@/src/atoms/settings/general"
|
||||
import {
|
||||
EntryContentWebView,
|
||||
preloadWebViewEntry,
|
||||
@@ -13,13 +18,8 @@ import { ContextMenu } from "@/src/components/ui/context-menu"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]/EntryDetailScreen"
|
||||
import { useIsEntryStarred } from "@/src/store/collection/hooks"
|
||||
import { collectionSyncService } from "@/src/store/collection/store"
|
||||
import { getFetchEntryPayload } from "@/src/store/entry/getter"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import { unreadSyncService } from "@/src/store/unread/store"
|
||||
|
||||
import { useSelectedFeed, useSelectedView } from "../screen/atoms"
|
||||
import { getFetchEntryPayload, useSelectedFeed, useSelectedView } from "../screen/atoms"
|
||||
|
||||
export const EntryItemContextMenu = ({
|
||||
id,
|
||||
@@ -76,6 +76,7 @@ export const EntryItemContextMenu = ({
|
||||
startTime: new Date(publishedAt).getTime() + 1,
|
||||
endTime: Date.now(),
|
||||
},
|
||||
excludePrivate: getHideAllReadSubscriptions(),
|
||||
})
|
||||
}}
|
||||
>
|
||||
@@ -121,6 +122,7 @@ export const EntryItemContextMenu = ({
|
||||
startTime: 1,
|
||||
endTime: new Date(publishedAt).getTime() - 1,
|
||||
},
|
||||
excludePrivate: getHideAllReadSubscriptions(),
|
||||
})
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useEntryIdsByFeedId, usePrefetchEntries } from "@follow/store/src/entry/hooks"
|
||||
import { getFeed } from "@follow/store/src/feed/getter"
|
||||
import { getSubscription } from "@follow/store/src/subscription/getter"
|
||||
import { getSubscriptionCategory } from "@follow/store/src/subscription/hooks"
|
||||
import { subscriptionSyncService } from "@follow/store/src/subscription/store"
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import dayjs from "dayjs"
|
||||
import { setStringAsync } from "expo-clipboard"
|
||||
import { t } from "i18next"
|
||||
@@ -8,6 +14,7 @@ import { useTranslation } from "react-i18next"
|
||||
import type { ListRenderItemInfo } from "react-native"
|
||||
import { Alert, FlatList, View } from "react-native"
|
||||
|
||||
import { useFetchEntriesSettings } from "@/src/atoms/settings/general"
|
||||
import { ContextMenu } from "@/src/components/ui/context-menu"
|
||||
import { PlatformActivityIndicator } from "@/src/components/ui/loading/PlatformActivityIndicator"
|
||||
import { views } from "@/src/constants/views"
|
||||
@@ -16,12 +23,6 @@ import type { Navigation } from "@/src/lib/navigation/Navigation"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { FollowScreen } from "@/src/screens/(modal)/FollowScreen"
|
||||
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
|
||||
import { useEntryIdsByFeedId, usePrefetchEntries } from "@/src/store/entry/hooks"
|
||||
import { getFeed } from "@/src/store/feed/getter"
|
||||
import { getSubscription } from "@/src/store/subscription/getter"
|
||||
import { getSubscriptionCategory } from "@/src/store/subscription/hooks"
|
||||
import { subscriptionSyncService } from "@/src/store/subscription/store"
|
||||
import { unreadSyncService } from "@/src/store/unread/store"
|
||||
|
||||
import { ItemSeparator } from "../entry-list/ItemSeparator"
|
||||
import { EntryNormalItem } from "../entry-list/templates/EntryNormalItem"
|
||||
@@ -339,7 +340,8 @@ export const SubscriptionFeedCategoryContextMenu = ({
|
||||
const PreviewFeeds = (props: { id: string; view: FeedViewType }) => {
|
||||
const { id: feedId } = props
|
||||
const entryIds = useEntryIdsByFeedId(feedId)
|
||||
const { isLoading } = usePrefetchEntries({ feedId, limit: 5 })
|
||||
const options = useFetchEntriesSettings()
|
||||
const { isLoading } = usePrefetchEntries({ feedId, limit: 5, ...options })
|
||||
|
||||
const renderItem = useCallback(
|
||||
({ item: id }: ListRenderItemInfo<string>) => (
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { useInbox } from "@follow/store/src/inbox/hooks"
|
||||
import { setStringAsync } from "expo-clipboard"
|
||||
import type { PropsWithChildren } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { ContextMenu } from "@/src/components/ui/context-menu"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { useInbox } from "@/src/store/inbox/hooks"
|
||||
|
||||
type InboxContextMenuProps = PropsWithChildren<{
|
||||
inboxId: string
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { env } from "@follow/shared/src/env.rn"
|
||||
import { getList } from "@follow/store/src/list/getters"
|
||||
import { subscriptionSyncService } from "@follow/store/src/subscription/store"
|
||||
import type { FC, PropsWithChildren } from "react"
|
||||
import { useMemo } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
@@ -8,8 +10,6 @@ import { ContextMenu } from "@/src/components/ui/context-menu"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { FollowScreen } from "@/src/screens/(modal)/FollowScreen"
|
||||
import { getList } from "@/src/store/list/getters"
|
||||
import { subscriptionSyncService } from "@/src/store/subscription/store"
|
||||
|
||||
export const SubscriptionListItemContextMenu: FC<
|
||||
PropsWithChildren & {
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useIsEntryStarred } from "@follow/store/src/collection/hooks"
|
||||
import { collectionSyncService } from "@follow/store/src/collection/store"
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import type { PropsWithChildren } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Share } from "react-native"
|
||||
|
||||
import { ContextMenu } from "@/src/components/ui/context-menu"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { useIsEntryStarred } from "@/src/store/collection/hooks"
|
||||
import { collectionSyncService } from "@/src/store/collection/store"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import { unreadSyncService } from "@/src/store/unread/store"
|
||||
|
||||
type VideoContextMenuProps = PropsWithChildren<{
|
||||
entryId: string
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import { t } from "i18next"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Text, View } from "react-native"
|
||||
|
||||
import { getHideAllReadSubscriptions } from "@/src/atoms/settings/general"
|
||||
import { CheckCircleCuteReIcon } from "@/src/icons/check_circle_cute_re"
|
||||
import type { DialogComponent } from "@/src/lib/dialog"
|
||||
import { Dialog } from "@/src/lib/dialog"
|
||||
import { getFetchEntryPayload } from "@/src/store/entry/getter"
|
||||
import { unreadSyncService } from "@/src/store/unread/store"
|
||||
|
||||
import { useSelectedFeed, useSelectedView } from "../screen/atoms"
|
||||
import { getFetchEntryPayload, useSelectedFeed, useSelectedView } from "../screen/atoms"
|
||||
|
||||
export const MarkAllAsReadDialog: DialogComponent = () => {
|
||||
const { t } = useTranslation()
|
||||
@@ -25,7 +25,11 @@ export const MarkAllAsReadDialog: DialogComponent = () => {
|
||||
|
||||
if (typeof selectedView === "number") {
|
||||
const payload = getFetchEntryPayload(selectedFeed, selectedView)
|
||||
unreadSyncService.markViewAsRead({ view: selectedView, filter: payload })
|
||||
unreadSyncService.markViewAsRead({
|
||||
view: selectedView,
|
||||
filter: payload,
|
||||
excludePrivate: getHideAllReadSubscriptions(),
|
||||
})
|
||||
}
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useSubscriptionByFeedId } from "@follow/store/src/subscription/hooks"
|
||||
import { Text, View } from "react-native"
|
||||
|
||||
import { RelativeDateTime } from "@/src/components/ui/datetime/RelativeDateTime"
|
||||
@@ -5,7 +6,6 @@ import { SafeAlertCuteReIcon } from "@/src/icons/safe_alert_cute_re"
|
||||
import { SafetyCertificateCuteReIcon } from "@/src/icons/safety_certificate_cute_re"
|
||||
import { User3CuteReIcon } from "@/src/icons/user_3_cute_re"
|
||||
import type { apiClient } from "@/src/lib/api-fetch"
|
||||
import { useSubscriptionByFeedId } from "@/src/store/subscription/hooks"
|
||||
import { useColor } from "@/src/theme/colors"
|
||||
|
||||
import { FeedSummary } from "../FeedSummary"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useSubscriptionByListId } from "@follow/store/src/subscription/hooks"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { useAtomValue } from "jotai"
|
||||
import { memo } from "react"
|
||||
@@ -13,7 +14,6 @@ import { apiClient } from "@/src/lib/api-fetch"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { UrlBuilder } from "@/src/lib/url-builder"
|
||||
import { FollowScreen } from "@/src/screens/(modal)/FollowScreen"
|
||||
import { useSubscriptionByListId } from "@/src/store/subscription/hooks"
|
||||
import { useColor } from "@/src/theme/colors"
|
||||
|
||||
import { useSearchPageContext } from "../ctx"
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { SummaryGeneratingStatus } from "@follow/store/src/summary/enum"
|
||||
import { usePrefetchSummary, useSummary } from "@follow/store/src/summary/hooks"
|
||||
import { useSummaryStore } from "@follow/store/src/summary/store"
|
||||
import { useAtomValue } from "jotai"
|
||||
import type { FC } from "react"
|
||||
|
||||
import { useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import { SummaryGeneratingStatus } from "@/src/store/summary/enum"
|
||||
import { usePrefetchSummary, useSummary } from "@/src/store/summary/hooks"
|
||||
import { useSummaryStore } from "@/src/store/summary/store"
|
||||
import { useActionLanguage, useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
|
||||
import { AISummary } from "../ai/summary"
|
||||
import { useEntryContentContext } from "./ctx"
|
||||
@@ -19,13 +19,13 @@ export const EntryAISummary: FC<{
|
||||
const showAISummary = useGeneralSettingKey("summary") || showAISummaryOnce
|
||||
const entryReadabilityContent = useEntry(entryId, (state) => state.readabilityContent)
|
||||
const summary = useSummary(entryId)
|
||||
usePrefetchSummary(
|
||||
const actionLanguage = useActionLanguage()
|
||||
usePrefetchSummary({
|
||||
entryId,
|
||||
showReadability && entryReadabilityContent ? "readabilityContent" : "content",
|
||||
{
|
||||
enabled: showAISummary,
|
||||
},
|
||||
)
|
||||
target: showReadability && entryReadabilityContent ? "readabilityContent" : "content",
|
||||
actionLanguage,
|
||||
enabled: showAISummary,
|
||||
})
|
||||
const summaryToShow = showReadability
|
||||
? summary?.readabilitySummary || summary?.summary
|
||||
: summary?.summary
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
import { useIsEntryStarred } from "@follow/store/src/collection/hooks"
|
||||
import { collectionSyncService } from "@follow/store/src/collection/store"
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { entrySyncServices } from "@follow/store/src/entry/store"
|
||||
import { useFeed } from "@follow/store/src/feed/hooks"
|
||||
import { useSubscription } from "@follow/store/src/subscription/hooks"
|
||||
import { summaryActions, summarySyncService } from "@follow/store/src/summary/store"
|
||||
import { translationSyncService } from "@follow/store/src/translation/store"
|
||||
import { setStringAsync } from "expo-clipboard"
|
||||
import { useAtom } from "jotai"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
@@ -20,14 +28,7 @@ import { StarCuteReIcon } from "@/src/icons/star_cute_re"
|
||||
import { Translate2CuteReIcon } from "@/src/icons/translate_2_cute_re"
|
||||
import { hideIntelligenceGlowEffect, openLink, showIntelligenceGlowEffect } from "@/src/lib/native"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { useIsEntryStarred } from "@/src/store/collection/hooks"
|
||||
import { collectionSyncService } from "@/src/store/collection/store"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import { entrySyncServices } from "@/src/store/entry/store"
|
||||
import { useFeed } from "@/src/store/feed/hooks"
|
||||
import { useSubscription } from "@/src/store/subscription/hooks"
|
||||
import { summaryActions, summarySyncService } from "@/src/store/summary/store"
|
||||
import { translationSyncService } from "@/src/store/translation/store"
|
||||
import { checkLanguage } from "@/src/lib/translation"
|
||||
|
||||
import { useEntryContentContext } from "./ctx"
|
||||
|
||||
@@ -115,10 +116,11 @@ const HeaderRightActionsImpl = ({
|
||||
if (hasSummary) return
|
||||
|
||||
const hideGlowEffect = showIntelligenceGlowEffect()
|
||||
await summarySyncService.generateSummary(
|
||||
await summarySyncService.generateSummary({
|
||||
entryId,
|
||||
showReadability ? "readabilityContent" : "content",
|
||||
)
|
||||
target: showReadability ? "readabilityContent" : "content",
|
||||
actionLanguage: getActionLanguage(),
|
||||
})
|
||||
hideGlowEffect()
|
||||
}
|
||||
|
||||
@@ -135,6 +137,7 @@ const HeaderRightActionsImpl = ({
|
||||
language: getActionLanguage(),
|
||||
withContent: true,
|
||||
target: showReadability ? "readabilityContent" : "content",
|
||||
checkLanguage,
|
||||
})
|
||||
setShowTranslation((prev) => !prev)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { useFeed } from "@follow/store/src/feed/hooks"
|
||||
import { useEntryTranslation } from "@follow/store/src/translation/hooks"
|
||||
import { cn } from "@follow/utils"
|
||||
import { Text, View } from "react-native"
|
||||
|
||||
import { useActionLanguage } from "@/src/atoms/settings/general"
|
||||
import { RelativeDateTime } from "@/src/components/ui/datetime/RelativeDateTime"
|
||||
import { FeedIcon } from "@/src/components/ui/icon/feed-icon"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import { useFeed } from "@/src/store/feed/hooks"
|
||||
import { useEntryTranslation } from "@/src/store/translation/hooks"
|
||||
|
||||
import { EntryTranslation } from "../entry-list/templates/EntryTranslation"
|
||||
|
||||
@@ -20,8 +21,8 @@ export const EntryGridFooter = ({
|
||||
view: FeedViewType
|
||||
}) => {
|
||||
const entry = useEntry(entryId)
|
||||
|
||||
const translation = useEntryTranslation(entryId)
|
||||
const actionLanguage = useActionLanguage()
|
||||
const translation = useEntryTranslation(entryId, actionLanguage)
|
||||
const feed = useFeed(entry?.feedId || "")
|
||||
|
||||
if (!entry) return null
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { useAtomValue } from "jotai"
|
||||
import type { FC } from "react"
|
||||
import { use, useState } from "react"
|
||||
@@ -17,7 +18,6 @@ import { useUISettingKey } from "@/src/atoms/settings/ui"
|
||||
import { DefaultHeaderBackButton } from "@/src/components/layouts/header/NavigationHeader"
|
||||
import { NavigationBlurEffectHeaderView } from "@/src/components/layouts/views/SafeNavigationScrollView"
|
||||
import { ScreenItemContext } from "@/src/lib/navigation/ScreenItemContext"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
|
||||
import { useHeaderHeight } from "../screen/hooks/useHeaderHeight"
|
||||
import { EntryContentContext } from "./ctx"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { isInboxEntry } from "@follow/store/src/entry/utils"
|
||||
import { userActions } from "@follow/store/src/user/store"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { Pressable, View } from "react-native"
|
||||
|
||||
@@ -5,9 +8,6 @@ import { UserAvatar } from "@/src/components/ui/avatar/UserAvatar"
|
||||
import { apiClient } from "@/src/lib/api-fetch"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { ProfileScreen } from "@/src/screens/(modal)/ProfileScreen"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import { isInboxEntry } from "@/src/store/entry/utils"
|
||||
import { userActions } from "@/src/store/user/store"
|
||||
|
||||
export const EntryReadHistory = ({ entryId }: { entryId: string }) => {
|
||||
const entry = useEntry(entryId)
|
||||
|
||||
@@ -1,18 +1,20 @@
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { useFeed } from "@follow/store/src/feed/hooks"
|
||||
import { useEntryTranslation } from "@follow/store/src/translation/hooks"
|
||||
import { useSetAtom } from "jotai"
|
||||
import { use } from "react"
|
||||
import { Text, View } from "react-native"
|
||||
|
||||
import { useActionLanguage } from "@/src/atoms/settings/general"
|
||||
import { UserAvatar } from "@/src/components/ui/avatar/UserAvatar"
|
||||
import { FeedIcon } from "@/src/components/ui/icon/feed-icon"
|
||||
import { EntryContentContext } from "@/src/modules/entry-content/ctx"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import { useFeed } from "@/src/store/feed/hooks"
|
||||
import { useEntryTranslation } from "@/src/store/translation/hooks"
|
||||
|
||||
import { EntryTranslation } from "../entry-list/templates/EntryTranslation"
|
||||
|
||||
export const EntryTitle = ({ title, entryId }: { title: string; entryId: string }) => {
|
||||
const translation = useEntryTranslation(entryId)
|
||||
const actionLanguage = useActionLanguage()
|
||||
const translation = useEntryTranslation(entryId, actionLanguage)
|
||||
|
||||
const { titleHeightAtom } = use(EntryContentContext)
|
||||
const setTitleHeight = useSetAtom(titleHeightAtom)
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { usePrefetchEntryTranslation } from "@follow/store/src/translation/hooks"
|
||||
import type { ListRenderItemInfo } from "@shopify/flash-list"
|
||||
import type { ElementRef } from "react"
|
||||
import { useCallback, useImperativeHandle, useMemo } from "react"
|
||||
import { View } from "react-native"
|
||||
|
||||
import { useActionLanguage, useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
import { usePlayingUrl } from "@/src/lib/player"
|
||||
import { usePrefetchEntryTranslation } from "@/src/store/translation/hooks"
|
||||
import { checkLanguage } from "@/src/lib/translation"
|
||||
|
||||
import { useFetchEntriesControls } from "../screen/atoms"
|
||||
import { TimelineSelectorList } from "../screen/TimelineSelectorList"
|
||||
@@ -53,7 +55,14 @@ export const EntryListContentArticle = ({
|
||||
|
||||
useImperativeHandle(forwardRef, () => ref.current!)
|
||||
|
||||
usePrefetchEntryTranslation({ entryIds: active ? viewableItems.map((item) => item.key) : [] })
|
||||
const translation = useGeneralSettingKey("translation")
|
||||
const actionLanguage = useActionLanguage()
|
||||
usePrefetchEntryTranslation({
|
||||
entryIds: active ? viewableItems.map((item) => item.key) : [],
|
||||
language: actionLanguage,
|
||||
translation,
|
||||
checkLanguage,
|
||||
})
|
||||
|
||||
return (
|
||||
<TimelineSelectorList
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { usePrefetchEntryTranslation } from "@follow/store/src/translation/hooks"
|
||||
import type { MasonryFlashListProps } from "@shopify/flash-list"
|
||||
import type { ElementRef } from "react"
|
||||
import { useImperativeHandle } from "react"
|
||||
import { View } from "react-native"
|
||||
|
||||
import { useActionLanguage, useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
import { PlatformActivityIndicator } from "@/src/components/ui/loading/PlatformActivityIndicator"
|
||||
import { checkLanguage } from "@/src/lib/translation"
|
||||
import { useFetchEntriesControls } from "@/src/modules/screen/atoms"
|
||||
import { usePrefetchEntryTranslation } from "@/src/store/translation/hooks"
|
||||
|
||||
import { TimelineSelectorMasonryList } from "../screen/TimelineSelectorList"
|
||||
import { GridEntryListFooter } from "./EntryListFooter"
|
||||
@@ -31,8 +33,14 @@ export const EntryListContentPicture = ({
|
||||
disabled: active === false || isFetching,
|
||||
onScroll: hackOnScroll,
|
||||
})
|
||||
|
||||
usePrefetchEntryTranslation({ entryIds: active ? viewableItems.map((item) => item.key) : [] })
|
||||
const translation = useGeneralSettingKey("translation")
|
||||
const actionLanguage = useActionLanguage()
|
||||
usePrefetchEntryTranslation({
|
||||
entryIds: active ? viewableItems.map((item) => item.key) : [],
|
||||
language: actionLanguage,
|
||||
checkLanguage,
|
||||
translation,
|
||||
})
|
||||
|
||||
return (
|
||||
<TimelineSelectorMasonryList
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
import { usePrefetchEntryTranslation } from "@follow/store/src/translation/hooks"
|
||||
import type { ListRenderItemInfo } from "@shopify/flash-list"
|
||||
import type { ElementRef } from "react"
|
||||
import { useCallback, useImperativeHandle, useMemo } from "react"
|
||||
import { View } from "react-native"
|
||||
|
||||
import { usePrefetchEntryTranslation } from "@/src/store/translation/hooks"
|
||||
import { useActionLanguage, useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
import { checkLanguage } from "@/src/lib/translation"
|
||||
|
||||
import { useFetchEntriesControls } from "../screen/atoms"
|
||||
import { TimelineSelectorList } from "../screen/TimelineSelectorList"
|
||||
@@ -44,7 +46,14 @@ export const EntryListContentSocial = ({
|
||||
onScroll: hackOnScroll,
|
||||
})
|
||||
|
||||
usePrefetchEntryTranslation({ entryIds: active ? viewableItems.map((item) => item.key) : [] })
|
||||
const translation = useGeneralSettingKey("translation")
|
||||
const actionLanguage = useActionLanguage()
|
||||
usePrefetchEntryTranslation({
|
||||
entryIds: active ? viewableItems.map((item) => item.key) : [],
|
||||
language: actionLanguage,
|
||||
translation,
|
||||
checkLanguage,
|
||||
})
|
||||
|
||||
return (
|
||||
<TimelineSelectorList
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
import { useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { usePrefetchEntryTranslation } from "@follow/store/src/translation/hooks"
|
||||
import type { MasonryFlashListProps } from "@shopify/flash-list"
|
||||
import type { ElementRef } from "react"
|
||||
import { useImperativeHandle, useMemo } from "react"
|
||||
import { View } from "react-native"
|
||||
|
||||
import { useActionLanguage, useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
import { checkLanguage } from "@/src/lib/translation"
|
||||
import { useFetchEntriesControls } from "@/src/modules/screen/atoms"
|
||||
import { usePrefetchEntryTranslation } from "@/src/store/translation/hooks"
|
||||
|
||||
import { TimelineSelectorMasonryList } from "../screen/TimelineSelectorList"
|
||||
import { GridEntryListFooter } from "./EntryListFooter"
|
||||
@@ -30,7 +32,14 @@ export const EntryListContentVideo = ({
|
||||
onScroll: hackOnScroll,
|
||||
})
|
||||
|
||||
usePrefetchEntryTranslation({ entryIds: active ? viewableItems.map((item) => item.key) : [] })
|
||||
const translation = useGeneralSettingKey("translation")
|
||||
const actionLanguage = useActionLanguage()
|
||||
usePrefetchEntryTranslation({
|
||||
entryIds: active ? viewableItems.map((item) => item.key) : [],
|
||||
language: actionLanguage,
|
||||
translation,
|
||||
checkLanguage,
|
||||
})
|
||||
|
||||
const ListFooterComponent = useMemo(
|
||||
() =>
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Text, TouchableOpacity } from "react-native"
|
||||
|
||||
import { getHideAllReadSubscriptions } from "@/src/atoms/settings/general"
|
||||
import { CheckCircleCuteReIcon } from "@/src/icons/check_circle_cute_re"
|
||||
import { getFetchEntryPayload } from "@/src/store/entry/getter"
|
||||
import { unreadSyncService } from "@/src/store/unread/store"
|
||||
import { useColor } from "@/src/theme/colors"
|
||||
|
||||
import { useSelectedFeed, useSelectedView } from "../screen/atoms"
|
||||
import { getFetchEntryPayload, useSelectedFeed, useSelectedView } from "../screen/atoms"
|
||||
import { ItemSeparator } from "./ItemSeparator"
|
||||
|
||||
export const EntryListFooter = () => {
|
||||
@@ -23,7 +23,11 @@ export const EntryListFooter = () => {
|
||||
onPress={() => {
|
||||
if (typeof selectedView === "number") {
|
||||
const payload = getFetchEntryPayload(selectedFeed, selectedView)
|
||||
unreadSyncService.markViewAsRead({ view: selectedView, filter: payload })
|
||||
unreadSyncService.markViewAsRead({
|
||||
view: selectedView,
|
||||
filter: payload,
|
||||
excludePrivate: getHideAllReadSubscriptions(),
|
||||
})
|
||||
}
|
||||
}}
|
||||
>
|
||||
@@ -49,7 +53,11 @@ export const GridEntryListFooter = () => {
|
||||
onPress={() => {
|
||||
if (typeof selectedView === "number") {
|
||||
const payload = getFetchEntryPayload(selectedFeed, selectedView)
|
||||
unreadSyncService.markViewAsRead({ view: selectedView, filter: payload })
|
||||
unreadSyncService.markViewAsRead({
|
||||
view: selectedView,
|
||||
filter: payload,
|
||||
excludePrivate: getHideAllReadSubscriptions(),
|
||||
})
|
||||
}
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useWhoami } from "@follow/store/src/user/hooks"
|
||||
import type { FlashList } from "@shopify/flash-list"
|
||||
import { useEffect } from "react"
|
||||
|
||||
@@ -8,7 +9,6 @@ import { NoLoginInfo } from "@/src/components/common/NoLoginInfo"
|
||||
import { ListErrorView } from "@/src/components/errors/ListErrorView"
|
||||
import { useRegisterNavigationScrollView } from "@/src/components/layouts/tabbar/hooks"
|
||||
import { EntryListContentPicture } from "@/src/modules/entry-list/EntryListContentPicture"
|
||||
import { useWhoami } from "@/src/store/user/hooks"
|
||||
|
||||
import { useFetchEntriesControls } from "../screen/atoms"
|
||||
import { EntryListContentArticle } from "./EntryListContentArticle"
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { debouncedFetchEntryContentByStream } from "@follow/store/src/entry/store"
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import type { FlashList } from "@shopify/flash-list"
|
||||
import type ViewToken from "@shopify/flash-list/dist/viewability/ViewToken"
|
||||
import { fetch as expoFetch } from "expo/fetch"
|
||||
import type { RefObject } from "react"
|
||||
import { use, useCallback, useEffect, useInsertionEffect, useMemo, useRef, useState } from "react"
|
||||
import type { NativeScrollEvent, NativeSyntheticEvent, ViewStyle } from "react-native"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
import { debouncedFetchEntryContentByStream } from "@/src/store/entry/store"
|
||||
import { unreadSyncService } from "@/src/store/unread/store"
|
||||
import { getCookie } from "@/src/lib/auth"
|
||||
|
||||
import { PagerListVisibleContext, PagerListWillVisibleContext } from "../screen/PagerListContext"
|
||||
|
||||
@@ -38,7 +40,10 @@ export function useOnViewableItemsChanged({
|
||||
}) => void = useNonReactiveCallback(({ viewableItems, changed }) => {
|
||||
setViewableItems(viewableItems)
|
||||
|
||||
debouncedFetchEntryContentByStream(viewableItems.map((item) => stableIdExtractor(item)))
|
||||
debouncedFetchEntryContentByStream(
|
||||
viewableItems.map((item) => stableIdExtractor(item)),
|
||||
{ cookie: getCookie(), fetch: expoFetch as any },
|
||||
)
|
||||
const removed = changed.filter((item) => !item.isViewable)
|
||||
|
||||
if (orientation.current === "down") {
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { memo, useMemo } from "react"
|
||||
|
||||
import { useSelectedFeed, useSelectedView } from "@/src/modules/screen/atoms"
|
||||
import { PagerList } from "@/src/modules/screen/PagerList"
|
||||
import { TimelineHeader } from "@/src/modules/screen/TimelineSelectorProvider"
|
||||
import {
|
||||
useEntryIdsByCategory,
|
||||
useEntryIdsByFeedId,
|
||||
useEntryIdsByInboxId,
|
||||
useEntryIdsByListId,
|
||||
useEntryIdsByView,
|
||||
} from "@/src/store/entry/hooks"
|
||||
} from "@follow/store/src/entry/hooks"
|
||||
import { memo, useMemo } from "react"
|
||||
|
||||
import { useSelectedFeed, useSelectedView } from "@/src/modules/screen/atoms"
|
||||
import { PagerList } from "@/src/modules/screen/PagerList"
|
||||
import { TimelineHeader } from "@/src/modules/screen/TimelineSelectorProvider"
|
||||
|
||||
import { EntryListSelector } from "./EntryListSelector"
|
||||
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import type { EntryModel } from "@follow/store/src/entry/types"
|
||||
import { getInboxFrom } from "@follow/store/src/entry/utils"
|
||||
import { useFeed } from "@follow/store/src/feed/hooks"
|
||||
import { useEntryTranslation } from "@follow/store/src/translation/hooks"
|
||||
import { tracker } from "@follow/tracker"
|
||||
import { cn, formatEstimatedMins, formatTimeToSeconds } from "@follow/utils"
|
||||
import { useVideoPlayer, VideoView } from "expo-video"
|
||||
import { memo, useCallback, useMemo, useRef, useState } from "react"
|
||||
import { StyleSheet, Text, View } from "react-native"
|
||||
|
||||
import { useActionLanguage } from "@/src/atoms/settings/general"
|
||||
import { useUISettingKey } from "@/src/atoms/settings/ui"
|
||||
import { ThemedBlurView } from "@/src/components/common/ThemedBlurView"
|
||||
import { preloadWebViewEntry } from "@/src/components/native/webview/EntryContentWebView"
|
||||
@@ -21,11 +27,6 @@ import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { isIOS } from "@/src/lib/platform"
|
||||
import { getAttachmentState, player } from "@/src/lib/player"
|
||||
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]/EntryDetailScreen"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import type { EntryModel } from "@/src/store/entry/types"
|
||||
import { getInboxFrom } from "@/src/store/entry/utils"
|
||||
import { useFeed } from "@/src/store/feed/hooks"
|
||||
import { useEntryTranslation } from "@/src/store/translation/hooks"
|
||||
|
||||
import { EntryItemContextMenu } from "../../context-menu/entry"
|
||||
import { EntryItemSkeleton } from "../EntryListContentArticle"
|
||||
@@ -43,7 +44,8 @@ export const EntryNormalItem = memo(
|
||||
view: FeedViewType
|
||||
}) => {
|
||||
const entry = useEntry(entryId)
|
||||
const translation = useEntryTranslation(entryId)
|
||||
const actionLanguage = useActionLanguage()
|
||||
const translation = useEntryTranslation(entryId, actionLanguage)
|
||||
const from = getInboxFrom(entry)
|
||||
const feed = useFeed(entry?.feedId as string)
|
||||
const navigation = useNavigation()
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import type { MediaModel } from "@follow/database/src/schemas/types"
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { getFeed } from "@follow/store/src/feed/getter"
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import { tracker } from "@follow/tracker"
|
||||
import { uniqBy } from "es-toolkit/compat"
|
||||
import { useMemo } from "react"
|
||||
@@ -9,9 +12,6 @@ import { showEntryGaleriaAccessory } from "@/src/components/native/GaleriaAccess
|
||||
import { preloadWebViewEntry } from "@/src/components/native/webview/EntryContentWebView"
|
||||
import { MediaCarousel } from "@/src/components/ui/carousel/MediaCarousel"
|
||||
import { getFeedIconSource } from "@/src/lib/image"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import { getFeed } from "@/src/store/feed/getter"
|
||||
import { unreadSyncService } from "@/src/store/unread/store"
|
||||
|
||||
export function EntryPictureItem({ id }: { id: string }) {
|
||||
const item = useEntry(id)
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { useFeed } from "@follow/store/src/feed/hooks"
|
||||
import { useEntryTranslation } from "@follow/store/src/translation/hooks"
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import { tracker } from "@follow/tracker"
|
||||
import { memo, useCallback, useMemo } from "react"
|
||||
import { Pressable, Text, View } from "react-native"
|
||||
|
||||
import { useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
import { useActionLanguage, useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
import { UserAvatar } from "@/src/components/ui/avatar/UserAvatar"
|
||||
import { RelativeDateTime } from "@/src/components/ui/datetime/RelativeDateTime"
|
||||
import { FeedIcon } from "@/src/components/ui/icon/feed-icon"
|
||||
@@ -16,10 +20,6 @@ import { VideoPlayer } from "@/src/components/ui/video/VideoPlayer"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { EntryDetailScreen } from "@/src/screens/(stack)/entries/[entryId]/EntryDetailScreen"
|
||||
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import { useFeed } from "@/src/store/feed/hooks"
|
||||
import { useEntryTranslation } from "@/src/store/translation/hooks"
|
||||
import { unreadSyncService } from "@/src/store/unread/store"
|
||||
|
||||
import { EntryItemContextMenu } from "../../context-menu/entry"
|
||||
import { EntryItemSkeleton } from "../EntryListContentSocial"
|
||||
@@ -29,7 +29,8 @@ import { EntryTranslation } from "./EntryTranslation"
|
||||
export const EntrySocialItem = memo(
|
||||
({ entryId, extraData }: { entryId: string; extraData: EntryExtraData }) => {
|
||||
const entry = useEntry(entryId)
|
||||
const translation = useEntryTranslation(entryId)
|
||||
const actionLanguage = useActionLanguage()
|
||||
const translation = useEntryTranslation(entryId, actionLanguage)
|
||||
|
||||
const feed = useFeed(entry?.feedId || "")
|
||||
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useEntry } from "@follow/store/src/entry/hooks"
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import { tracker } from "@follow/tracker"
|
||||
import { formatDuration, transformVideoUrl } from "@follow/utils"
|
||||
import { memo, useMemo } from "react"
|
||||
@@ -10,8 +12,6 @@ import { ItemPressableStyle } from "@/src/components/ui/pressable/enum"
|
||||
import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
|
||||
import { openLink } from "@/src/lib/native"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { useEntry } from "@/src/store/entry/hooks"
|
||||
import { unreadSyncService } from "@/src/store/unread/store"
|
||||
|
||||
import { VideoContextMenu } from "../../context-menu/video"
|
||||
import { EntryGridFooter } from "../../entry-content/EntryGridFooter"
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useFeed, usePrefetchFeed, usePrefetchFeedByUrl } from "@follow/store/src/feed/hooks"
|
||||
import { useSubscriptionByFeedId } from "@follow/store/src/subscription/hooks"
|
||||
import { subscriptionSyncService } from "@follow/store/src/subscription/store"
|
||||
import type { SubscriptionForm } from "@follow/store/src/subscription/types"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { useEffect, useState } from "react"
|
||||
import { Controller, useForm } from "react-hook-form"
|
||||
@@ -22,10 +26,6 @@ import { useCanDismiss, useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { useSetModalScreenOptions } from "@/src/lib/navigation/ScreenOptionsContext"
|
||||
import { FeedSummary } from "@/src/modules/discover/FeedSummary"
|
||||
import { FeedViewSelector } from "@/src/modules/feed/view-selector"
|
||||
import { useFeed, usePrefetchFeed, usePrefetchFeedByUrl } from "@/src/store/feed/hooks"
|
||||
import { useSubscriptionByFeedId } from "@/src/store/subscription/hooks"
|
||||
import { subscriptionSyncService } from "@/src/store/subscription/store"
|
||||
import type { SubscriptionForm } from "@/src/store/subscription/types"
|
||||
|
||||
const formSchema = z.object({
|
||||
view: z.coerce.number(),
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useList } from "@follow/store/src/list/hooks"
|
||||
import { listSyncServices } from "@follow/store/src/list/store"
|
||||
import { useSubscriptionByListId } from "@follow/store/src/subscription/hooks"
|
||||
import { subscriptionSyncService } from "@follow/store/src/subscription/store"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { useEffect } from "react"
|
||||
@@ -23,10 +27,6 @@ import { PowerIcon } from "@/src/icons/power"
|
||||
import { useNavigation, useScreenIsInSheetModal } from "@/src/lib/navigation/hooks"
|
||||
import { useSetModalScreenOptions } from "@/src/lib/navigation/ScreenOptionsContext"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { useList } from "@/src/store/list/hooks"
|
||||
import { listSyncServices } from "@/src/store/list/store"
|
||||
import { useSubscriptionByListId } from "@/src/store/subscription/hooks"
|
||||
import { subscriptionSyncService } from "@/src/store/subscription/store"
|
||||
import { accentColor } from "@/src/theme/colors"
|
||||
|
||||
import { FeedViewSelector } from "../feed/view-selector"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usePrefetchImageColors } from "@follow/store/src/image/hooks"
|
||||
import { cn } from "@follow/utils"
|
||||
import { useAtomValue } from "jotai"
|
||||
import { use, useEffect } from "react"
|
||||
@@ -14,7 +15,6 @@ import { BottomTabContext } from "@/src/lib/navigation/bottom-tab/BottomTabConte
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { useActiveTrack } from "@/src/lib/player"
|
||||
import { PlayerScreen } from "@/src/screens/PlayerScreen"
|
||||
import { usePrefetchImageColors } from "@/src/store/image/hooks"
|
||||
|
||||
import { PlayPauseButton, SeekButton } from "./control"
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
import { useImageColors } from "@follow/store/src/image/hooks"
|
||||
import { getLuminance, shadeColor } from "@follow/utils"
|
||||
import { useMemo } from "react"
|
||||
|
||||
import { useImageColors } from "@/src/store/image/hooks"
|
||||
|
||||
const defaultBackgroundColor = "#000000"
|
||||
|
||||
export function useCoverGradient(url?: string) {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { useViewWithSubscription } from "@follow/store/src/subscription/hooks"
|
||||
import { EventBus } from "@follow/utils/src/event-bus"
|
||||
import * as Haptics from "expo-haptics"
|
||||
import { useEffect, useId, useMemo, useRef, useState } from "react"
|
||||
@@ -7,7 +8,6 @@ import type { StyleProp, ViewStyle } from "react-native"
|
||||
|
||||
import { PagerView } from "@/src/components/native/PagerView"
|
||||
import type { PagerRef } from "@/src/components/native/PagerView/specs"
|
||||
import { useViewWithSubscription } from "@/src/store/subscription/hooks"
|
||||
|
||||
import { selectTimeline, useSelectedFeed } from "./atoms"
|
||||
import { PagerListVisibleContext, PagerListWillVisibleContext } from "./PagerListContext"
|
||||
@@ -24,7 +24,7 @@ export function PagerList({
|
||||
|
||||
const activeViews = useViewWithSubscription()
|
||||
const activeViewIndex = useMemo(
|
||||
() => activeViews.findIndex((view) => view.view === viewId),
|
||||
() => activeViews.indexOf(viewId as FeedViewType),
|
||||
[activeViews, viewId],
|
||||
)
|
||||
const pagerRef = useRef<PagerRef>(null)
|
||||
@@ -32,7 +32,7 @@ export function PagerList({
|
||||
useEffect(() => {
|
||||
return EventBus.subscribe("SELECT_TIMELINE", (data) => {
|
||||
if (data.target !== rid) {
|
||||
pagerRef.current?.setPage(activeViews.findIndex((view) => view.view === data.view.viewId))
|
||||
pagerRef.current?.setPage(activeViews.indexOf(data.view.viewId))
|
||||
}
|
||||
})
|
||||
}, [activeViews, pagerRef, rid])
|
||||
@@ -48,16 +48,16 @@ export function PagerList({
|
||||
containerClassName="flex-1 absolute inset-0"
|
||||
containerStyle={style}
|
||||
onPageChange={(targetIndex) => {
|
||||
selectTimeline({ type: "view", viewId: activeViews[targetIndex]!.view }, rid)
|
||||
selectTimeline({ type: "view", viewId: activeViews[targetIndex]! }, rid)
|
||||
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light)
|
||||
}}
|
||||
renderPage={useTypeScriptHappyCallback(
|
||||
(index) => (
|
||||
<PagerListVisibleContext value={index === activeViewIndex} key={activeViews[index]!.view}>
|
||||
<PagerListVisibleContext value={index === activeViewIndex} key={activeViews[index]!}>
|
||||
<PagerListWillVisibleContext
|
||||
value={(index === activeViewIndex + 1 || index === activeViewIndex - 1) && dragging}
|
||||
>
|
||||
{renderItem(activeViews[index]!.view, index === activeViewIndex)}
|
||||
{renderItem(activeViews[index]!, index === activeViewIndex)}
|
||||
</PagerListWillVisibleContext>
|
||||
</PagerListVisibleContext>
|
||||
),
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { useViewWithSubscription } from "@follow/store/src/subscription/hooks"
|
||||
import { EventBus } from "@follow/utils/src/event-bus"
|
||||
import * as Haptics from "expo-haptics"
|
||||
import { useCallback, useEffect, useId, useMemo, useRef, useState } from "react"
|
||||
@@ -8,7 +9,6 @@ import PagerView from "react-native-pager-view"
|
||||
import { useSharedValue } from "react-native-reanimated"
|
||||
|
||||
import { selectTimeline, useSelectedFeed } from "@/src/modules/screen/atoms"
|
||||
import { useViewWithSubscription } from "@/src/store/subscription/hooks"
|
||||
|
||||
import { PagerListVisibleContext, PagerListWillVisibleContext } from "./PagerListContext"
|
||||
|
||||
@@ -27,7 +27,7 @@ export function PagerList({
|
||||
const activeViews = useViewWithSubscription()
|
||||
|
||||
const activeViewIndex = useMemo(
|
||||
() => activeViews.findIndex((view) => view.view === viewId),
|
||||
() => activeViews.indexOf(viewId as FeedViewType),
|
||||
[activeViews, viewId],
|
||||
)
|
||||
|
||||
@@ -37,7 +37,7 @@ export function PagerList({
|
||||
useEffect(() => {
|
||||
return EventBus.subscribe("SELECT_TIMELINE", (data) => {
|
||||
if (data.target !== rid) {
|
||||
pagerRef.current?.setPage(activeViews.findIndex((view) => view.view === data.view.viewId))
|
||||
pagerRef.current?.setPage(activeViews.indexOf(data.view.viewId))
|
||||
}
|
||||
})
|
||||
}, [activeViews, pagerRef, rid])
|
||||
@@ -70,7 +70,7 @@ export function PagerList({
|
||||
}
|
||||
|
||||
if (targetIndex !== activeViewIndex) {
|
||||
selectTimeline({ type: "view", viewId: activeViews[targetIndex]!.view }, rid)
|
||||
selectTimeline({ type: "view", viewId: activeViews[targetIndex]! }, rid)
|
||||
userInitiatedDragRef.value = false
|
||||
}
|
||||
},
|
||||
@@ -105,11 +105,11 @@ export function PagerList({
|
||||
{useMemo(
|
||||
() =>
|
||||
activeViews.map((view, index) => (
|
||||
<PagerListVisibleContext value={index === activeViewIndex} key={view.view}>
|
||||
<PagerListVisibleContext value={index === activeViewIndex} key={view}>
|
||||
<PagerListWillVisibleContext
|
||||
value={(index === activeViewIndex + 1 || index === activeViewIndex - 1) && dragging}
|
||||
>
|
||||
{renderItem(view.view, index === activeViewIndex)}
|
||||
{renderItem(view, index === activeViewIndex)}
|
||||
</PagerListWillVisibleContext>
|
||||
</PagerListVisibleContext>
|
||||
)),
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { useTypeScriptHappyCallback } from "@follow/hooks"
|
||||
import { usePrefetchSubscription } from "@follow/store/src/subscription/hooks"
|
||||
import { usePrefetchUnread } from "@follow/store/src/unread/hooks"
|
||||
import { nextFrame } from "@follow/utils"
|
||||
import type {
|
||||
FlashListProps,
|
||||
@@ -17,8 +19,6 @@ import { useColor } from "react-native-uikit-colors"
|
||||
import { useBottomTabBarHeight } from "@/src/components/layouts/tabbar/hooks"
|
||||
import { ScreenItemContext } from "@/src/lib/navigation/ScreenItemContext"
|
||||
import { useHeaderHeight } from "@/src/modules/screen/hooks/useHeaderHeight"
|
||||
import { usePrefetchSubscription } from "@/src/store/subscription/hooks"
|
||||
import { usePrefetchUnread } from "@/src/store/unread/hooks"
|
||||
|
||||
import { EntryListEmpty } from "../entry-list/EntryListEmpty"
|
||||
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { useViewWithSubscription } from "@follow/store/src/subscription/hooks"
|
||||
import { useUnreadCountByView } from "@follow/store/src/unread/hooks"
|
||||
import * as React from "react"
|
||||
import { useEffect } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
@@ -9,9 +11,8 @@ import { ReAnimatedPressable } from "@/src/components/common/AnimatedComponents"
|
||||
import { gentleSpringPreset } from "@/src/constants/spring"
|
||||
import { TIMELINE_VIEW_SELECTOR_HEIGHT } from "@/src/constants/ui"
|
||||
import type { ViewDefinition } from "@/src/constants/views"
|
||||
import { views } from "@/src/constants/views"
|
||||
import { selectTimeline, useSelectedFeed } from "@/src/modules/screen/atoms"
|
||||
import { useViewWithSubscription } from "@/src/store/subscription/hooks"
|
||||
import { useUnreadCountByView } from "@/src/store/unread/hooks"
|
||||
import { useColor } from "@/src/theme/colors"
|
||||
|
||||
import { UnreadCount } from "../subscription/items/UnreadCount"
|
||||
@@ -37,14 +38,18 @@ export function TimelineViewSelector() {
|
||||
contentContainerClassName="flex-row gap-3 items-center px-3"
|
||||
showsHorizontalScrollIndicator={false}
|
||||
>
|
||||
{activeViews.map((view) => (
|
||||
<ViewItem
|
||||
key={view.name}
|
||||
view={view}
|
||||
scrollViewRef={scrollViewRef}
|
||||
isActive={selectedFeed?.type === "view" && selectedFeed.viewId === view.view}
|
||||
/>
|
||||
))}
|
||||
{activeViews.map((v) => {
|
||||
const view = views.find((view) => view.view === v)
|
||||
if (!view) return null
|
||||
return (
|
||||
<ViewItem
|
||||
key={view.name}
|
||||
view={view}
|
||||
scrollViewRef={scrollViewRef}
|
||||
isActive={selectedFeed?.type === "view" && selectedFeed.viewId === view.view}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
</ScrollView>
|
||||
</View>
|
||||
)
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { unreadSyncService } from "@follow/store/src/unread/store"
|
||||
import type { FC, PropsWithChildren } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { getHideAllReadSubscriptions } from "@/src/atoms/settings/general"
|
||||
import { ContextMenu } from "@/src/components/ui/context-menu"
|
||||
import { unreadSyncService } from "@/src/store/unread/store"
|
||||
|
||||
export const TimelineViewSelectorContextMenu: FC<
|
||||
PropsWithChildren<{ type: string | undefined; viewId: FeedViewType | undefined }>
|
||||
@@ -18,7 +19,10 @@ export const TimelineViewSelectorContextMenu: FC<
|
||||
<ContextMenu.Item
|
||||
key="MarkAsRead"
|
||||
onSelect={() => {
|
||||
unreadSyncService.markViewAsRead({ view: viewId })
|
||||
unreadSyncService.markViewAsRead({
|
||||
view: viewId,
|
||||
excludePrivate: getHideAllReadSubscriptions(),
|
||||
})
|
||||
}}
|
||||
>
|
||||
<ContextMenu.ItemTitle>{t("operation.mark_as_read")}</ContextMenu.ItemTitle>
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { getFeed } from "@follow/store/src/feed/getter"
|
||||
import { useWhoami } from "@follow/store/src/user/hooks"
|
||||
import { cn } from "@follow/utils"
|
||||
import * as Haptics from "expo-haptics"
|
||||
import type { PropsWithChildren } from "react"
|
||||
@@ -18,8 +20,6 @@ import { proxyEnv } from "@/src/lib/proxy-env"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { LoginScreen } from "@/src/screens/(modal)/LoginScreen"
|
||||
import { ProfileScreen } from "@/src/screens/(modal)/ProfileScreen"
|
||||
import { getFeed } from "@/src/store/feed/getter"
|
||||
import { useWhoami } from "@/src/store/user/hooks"
|
||||
import { accentColor, useColor } from "@/src/theme/colors"
|
||||
|
||||
import { MarkAllAsReadDialog } from "../dialogs/MarkAllAsReadDialog"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { usePrefetchEntries } from "@follow/store/src/entry/hooks"
|
||||
import type { FetchEntriesProps } from "@follow/store/src/entry/types"
|
||||
import { FEED_COLLECTION_LIST } from "@follow/store/src/entry/utils"
|
||||
import { useFeed } from "@follow/store/src/feed/hooks"
|
||||
import { useInbox } from "@follow/store/src/inbox/hooks"
|
||||
import { useList } from "@follow/store/src/list/hooks"
|
||||
import { getSubscriptionByCategory } from "@follow/store/src/subscription/getter"
|
||||
import { jotaiStore } from "@follow/utils"
|
||||
import { EventBus } from "@follow/utils/src/event-bus"
|
||||
import { atom, useAtomValue } from "jotai"
|
||||
@@ -6,13 +13,8 @@ import { selectAtom } from "jotai/utils"
|
||||
import { createContext, use, useMemo, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
|
||||
import { useFetchEntriesSettings } from "@/src/atoms/settings/general"
|
||||
import { views } from "@/src/constants/views"
|
||||
import { getFetchEntryPayload } from "@/src/store/entry/getter"
|
||||
import { usePrefetchEntries } from "@/src/store/entry/hooks"
|
||||
import { FEED_COLLECTION_LIST } from "@/src/store/entry/utils"
|
||||
import { useFeed } from "@/src/store/feed/hooks"
|
||||
import { useInbox } from "@/src/store/inbox/hooks"
|
||||
import { useList } from "@/src/store/list/hooks"
|
||||
|
||||
export type SelectedTimeline = {
|
||||
type: "view"
|
||||
@@ -87,12 +89,57 @@ export function useSelectedFeed<T>(
|
||||
)
|
||||
}
|
||||
|
||||
export const getFetchEntryPayload = (
|
||||
selectedFeed: SelectedTimeline | SelectedFeed,
|
||||
view: FeedViewType = FeedViewType.Articles,
|
||||
): FetchEntriesProps | null => {
|
||||
if (!selectedFeed) {
|
||||
return null
|
||||
}
|
||||
|
||||
let payload: FetchEntriesProps = {}
|
||||
switch (selectedFeed.type) {
|
||||
case "view": {
|
||||
payload = { view: selectedFeed.viewId }
|
||||
break
|
||||
}
|
||||
case "feed": {
|
||||
payload = { feedId: selectedFeed.feedId }
|
||||
break
|
||||
}
|
||||
case "category": {
|
||||
payload = {
|
||||
feedIdList: getSubscriptionByCategory({ category: selectedFeed.categoryName, view }),
|
||||
}
|
||||
break
|
||||
}
|
||||
case "list": {
|
||||
payload = { listId: selectedFeed.listId }
|
||||
break
|
||||
}
|
||||
case "inbox": {
|
||||
payload = { inboxId: selectedFeed.inboxId }
|
||||
break
|
||||
}
|
||||
// No default
|
||||
}
|
||||
const isCollection =
|
||||
selectedFeed && selectedFeed.type === "feed" && selectedFeed?.feedId === FEED_COLLECTION_LIST
|
||||
if (isCollection) {
|
||||
payload.view = view
|
||||
payload.isCollection = true
|
||||
}
|
||||
|
||||
return payload
|
||||
}
|
||||
|
||||
export function useFetchEntriesControls() {
|
||||
const selectedFeed = useSelectedFeed()
|
||||
const view = useSelectedView()
|
||||
|
||||
const payload = getFetchEntryPayload(selectedFeed, view)
|
||||
return usePrefetchEntries(payload)
|
||||
const options = useFetchEntriesSettings()
|
||||
return usePrefetchEntries({ ...payload, ...options })
|
||||
}
|
||||
|
||||
export const useSelectedFeedTitle = () => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { UserRole } from "@follow/constants"
|
||||
import type { ServerConfigs } from "@follow/models/src/types"
|
||||
import { useRole, useWhoami } from "@follow/store/src/user/hooks"
|
||||
import * as FileSystem from "expo-file-system"
|
||||
import type { ParseKeys } from "i18next"
|
||||
import type { FC } from "react"
|
||||
@@ -30,7 +31,6 @@ import { signOut } from "@/src/lib/auth"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import type { Navigation } from "@/src/lib/navigation/Navigation"
|
||||
import { InvitationScreen } from "@/src/screens/(modal)/InvitationScreen"
|
||||
import { useRole, useWhoami } from "@/src/store/user/hooks"
|
||||
|
||||
import { AboutScreen } from "./routes/About"
|
||||
import { AccountScreen } from "./routes/Account"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { useImageColors, usePrefetchImageColors } from "@follow/store/src/image/hooks"
|
||||
import { useUser } from "@follow/store/src/user/hooks"
|
||||
import { cn, getLuminance } from "@follow/utils"
|
||||
import { LinearGradient } from "expo-linear-gradient"
|
||||
import { useMemo } from "react"
|
||||
@@ -10,8 +12,6 @@ import { useColor } from "react-native-uikit-colors"
|
||||
import { UserAvatar } from "@/src/components/ui/avatar/UserAvatar"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { LoginScreen } from "@/src/screens/(modal)/LoginScreen"
|
||||
import { useImageColors, usePrefetchImageColors } from "@/src/store/image/hooks"
|
||||
import { useUser } from "@/src/store/user/hooks"
|
||||
|
||||
const defaultGradientColors = ["#000", "#100", "#200"]
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import type { ActionId } from "@follow/models/src/types"
|
||||
import { actionActions } from "@follow/store/src/action/store"
|
||||
import type { ParseKeys } from "i18next"
|
||||
import type { SFSymbol } from "sf-symbols-typescript"
|
||||
|
||||
import type { SupportedLanguages } from "@/src/lib/language"
|
||||
import type { Navigation } from "@/src/lib/navigation/Navigation"
|
||||
import { actionActions } from "@/src/store/action/store"
|
||||
|
||||
import { EditRewriteRulesScreen } from "../routes/EditRewriteRules"
|
||||
import { EditWebhooksScreen } from "../routes/EditWebhooks"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useWhoami } from "@follow/store/src/user/hooks"
|
||||
import { useCallback } from "react"
|
||||
import Siblings from "react-native-root-siblings"
|
||||
|
||||
@@ -5,7 +6,6 @@ import { getFetchErrorInfo } from "@/src/lib/error-parser"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { TwoFactorAuthScreen } from "@/src/screens/(modal)/TwoFactorAuthScreen"
|
||||
import { useWhoami } from "@/src/store/user/hooks"
|
||||
|
||||
import { OTPWindow } from "../components/OTPWindow"
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { whoamiQueryKey } from "@follow/store/src/user/hooks"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { useRef } from "react"
|
||||
import { KeyboardAvoidingView, Text, View } from "react-native"
|
||||
@@ -14,7 +15,6 @@ import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { queryClient } from "@/src/lib/query-client"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { whoamiQueryKey } from "@/src/store/user/hooks"
|
||||
import { accentColor, useColor } from "@/src/theme/colors"
|
||||
|
||||
const isAuthCodeValid = (code: string) => {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { useWhoami } from "@follow/store/src/user/hooks"
|
||||
import { userSyncService } from "@follow/store/src/user/store"
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query"
|
||||
import * as FileSystem from "expo-file-system"
|
||||
import type { FC } from "react"
|
||||
@@ -36,8 +38,6 @@ import { loading } from "@/src/lib/loading"
|
||||
import { openLink } from "@/src/lib/native"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { useWhoami } from "@/src/store/user/hooks"
|
||||
import { userSyncService } from "@/src/store/user/store"
|
||||
|
||||
import { ConfirmPasswordDialog } from "../../dialogs/ConfirmPasswordDialog"
|
||||
import { TwoFASetting } from "./2FASetting"
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
import type { ActionModel } from "@follow/models/src/types"
|
||||
import {
|
||||
useActionRules,
|
||||
useIsActionDataDirty,
|
||||
usePrefetchActions,
|
||||
useUpdateActionsMutation,
|
||||
} from "@follow/store/src/action/hooks"
|
||||
import { actionActions } from "@follow/store/src/action/store"
|
||||
import { useCallback } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import type { ListRenderItem } from "react-native"
|
||||
@@ -24,13 +31,7 @@ import { Switch } from "@/src/components/ui/switch/Switch"
|
||||
import { Book6CuteReIcon } from "@/src/icons/book_6_cute_re"
|
||||
import { Magic2CuteFiIcon } from "@/src/icons/magic_2_cute_fi"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import {
|
||||
useActionRules,
|
||||
useIsActionDataDirty,
|
||||
usePrefetchActions,
|
||||
useUpdateActionsMutation,
|
||||
} from "@/src/store/action/hooks"
|
||||
import { actionActions } from "@/src/store/action/store"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { accentColor } from "@/src/theme/colors"
|
||||
|
||||
import { EditRuleScreen } from "./EditRule"
|
||||
@@ -120,7 +121,16 @@ const NewRuleButton = () => {
|
||||
}
|
||||
|
||||
const SaveRuleButton = ({ disabled }: { disabled?: boolean }) => {
|
||||
const { mutate, isPending } = useUpdateActionsMutation()
|
||||
const navigation = useNavigation()
|
||||
const { mutate, isPending } = useUpdateActionsMutation({
|
||||
onSuccess() {
|
||||
navigation.back()
|
||||
toast.success("Actions saved")
|
||||
},
|
||||
onError(errorMessage) {
|
||||
toast.error(errorMessage)
|
||||
},
|
||||
})
|
||||
|
||||
return (
|
||||
<HeaderSubmitTextButton
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { getAllUnreadCount } from "@follow/store/src/unread/getter"
|
||||
import { themeNames } from "@shikijs/themes"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { useColorScheme, View } from "react-native"
|
||||
@@ -15,7 +16,6 @@ import {
|
||||
} from "@/src/components/ui/grouped/GroupedList"
|
||||
import { Switch } from "@/src/components/ui/switch/Switch"
|
||||
import { setBadgeCountAsyncWithPermission } from "@/src/lib/permission"
|
||||
import { getAllUnreadCount } from "@/src/store/unread/getter"
|
||||
|
||||
export const AppearanceScreen = () => {
|
||||
const { t } = useTranslation("settings")
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import type { ActionConditionIndex } from "@follow/models/src/types"
|
||||
import { useActionRuleCondition } from "@follow/store/src/action/hooks"
|
||||
import { actionActions } from "@follow/store/src/action/store"
|
||||
import { useMemo } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Text, View } from "react-native"
|
||||
@@ -16,8 +18,6 @@ import {
|
||||
} from "@/src/components/ui/grouped/GroupedList"
|
||||
import { views } from "@/src/constants/views"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { useActionRuleCondition } from "@/src/store/action/hooks"
|
||||
import { actionActions } from "@/src/store/action/store"
|
||||
import { accentColor } from "@/src/theme/colors"
|
||||
|
||||
import { filterFieldOptions, filterOperatorOptions } from "../actions/constant"
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import { useWhoami } from "@follow/store/src/user/hooks"
|
||||
import type { MeModel } from "@follow/store/src/user/store"
|
||||
import { userSyncService } from "@follow/store/src/user/store"
|
||||
import type { UserProfileEditable } from "@follow/store/src/user/types"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import type { FC } from "react"
|
||||
import { useState } from "react"
|
||||
@@ -24,10 +28,6 @@ import { CloseCircleFillIcon } from "@/src/icons/close_circle_fill"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { EditEmailScreen } from "@/src/screens/(modal)/EditEmailScreen"
|
||||
import { useWhoami } from "@/src/store/user/hooks"
|
||||
import type { MeModel } from "@/src/store/user/store"
|
||||
import { userSyncService } from "@/src/store/user/store"
|
||||
import type { UserProfileEditable } from "@/src/store/user/types"
|
||||
import { accentColor } from "@/src/theme/colors"
|
||||
|
||||
import { setAvatar } from "../utils"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { useActionRule } from "@follow/store/src/action/hooks"
|
||||
import { actionActions } from "@follow/store/src/action/store"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Text } from "react-native"
|
||||
|
||||
@@ -13,8 +15,6 @@ import {
|
||||
GroupedPlainButtonCell,
|
||||
} from "@/src/components/ui/grouped/GroupedList"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { useActionRule } from "@/src/store/action/hooks"
|
||||
import { actionActions } from "@/src/store/action/store"
|
||||
|
||||
export const EditRewriteRulesScreen: NavigationControllerView<{ index: number }> = ({ index }) => {
|
||||
const { t } = useTranslation("settings")
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import type { ActionFilter, ActionModel } from "@follow/models/src/types"
|
||||
import { useActionRule } from "@follow/store/src/action/hooks"
|
||||
import { actionActions } from "@follow/store/src/action/store"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Text, View } from "react-native"
|
||||
import * as DropdownMenu from "zeego/dropdown-menu"
|
||||
@@ -20,8 +22,6 @@ import {
|
||||
import { views } from "@/src/constants/views"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { useActionRule } from "@/src/store/action/hooks"
|
||||
import { actionActions } from "@/src/store/action/store"
|
||||
import { accentColor, useColors } from "@/src/theme/colors"
|
||||
|
||||
import { availableActionList, filterFieldOptions, filterOperatorOptions } from "../actions/constant"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { useActionRule } from "@follow/store/src/action/hooks"
|
||||
import { actionActions } from "@follow/store/src/action/store"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import { Text } from "react-native"
|
||||
|
||||
@@ -13,8 +15,6 @@ import {
|
||||
GroupedInsetListSectionHeader,
|
||||
} from "@/src/components/ui/grouped/GroupedList"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { useActionRule } from "@/src/store/action/hooks"
|
||||
import { actionActions } from "@/src/store/action/store"
|
||||
|
||||
export const EditWebhooksScreen: NavigationControllerView<{ index: number }> = ({ index }) => {
|
||||
const { t } = useTranslation("settings")
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { useOwnedLists, usePrefetchOwnedLists } from "@follow/store/src/list/hooks"
|
||||
import type { ListModel } from "@follow/store/src/list/store"
|
||||
import type { HonoApiClient } from "@follow/store/src/morph/types"
|
||||
import { createContext, createElement, use, useCallback, useMemo } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import type { ListRenderItem } from "react-native"
|
||||
@@ -25,10 +28,7 @@ import { RadaCuteFiIcon } from "@/src/icons/rada_cute_fi"
|
||||
import { UserAdd2CuteFiIcon } from "@/src/icons/user_add_2_cute_fi"
|
||||
import { Wallet2CuteFiIcon } from "@/src/icons/wallet_2_cute_fi"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import type { HonoApiClient } from "@/src/morph/types"
|
||||
import { ListScreen } from "@/src/screens/(modal)/ListScreen"
|
||||
import { useOwnedLists, usePrefetchOwnedLists } from "@/src/store/list/hooks"
|
||||
import type { ListModel } from "@/src/store/list/store"
|
||||
import { accentColor } from "@/src/theme/colors"
|
||||
|
||||
import { SwipeableGroupProvider, SwipeableItem } from "../../../components/common/SwipeableItem"
|
||||
|
||||
@@ -1,3 +1,11 @@
|
||||
import { useFeed } from "@follow/store/src/feed/hooks"
|
||||
import { useList, usePrefetchOwnedLists } from "@follow/store/src/list/hooks"
|
||||
import { listSyncServices } from "@follow/store/src/list/store"
|
||||
import {
|
||||
useFeedSubscriptionByView,
|
||||
usePrefetchSubscription,
|
||||
useSortedFeedSubscriptionByAlphabet,
|
||||
} from "@follow/store/src/subscription/hooks"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import type { MutableRefObject } from "react"
|
||||
import { createContext, use, useEffect, useMemo, useRef, useState } from "react"
|
||||
@@ -21,14 +29,6 @@ import { getBizFetchErrorMessage } from "@/src/lib/api-fetch"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { useFeed } from "@/src/store/feed/hooks"
|
||||
import { useList, usePrefetchOwnedLists } from "@/src/store/list/hooks"
|
||||
import { listSyncServices } from "@/src/store/list/store"
|
||||
import {
|
||||
useFeedSubscriptionByView,
|
||||
usePrefetchSubscription,
|
||||
useSortedFeedSubscriptionByAlphabet,
|
||||
} from "@/src/store/subscription/hooks"
|
||||
import { accentColor } from "@/src/theme/colors"
|
||||
|
||||
const ManageListContext = createContext<{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { userSyncService } from "@follow/store/src/user/store"
|
||||
import * as DocumentPicker from "expo-document-picker"
|
||||
import * as FileSystem from "expo-file-system"
|
||||
import * as Sharing from "expo-sharing"
|
||||
@@ -6,7 +7,6 @@ import { getDbPath } from "@/src/database"
|
||||
import { apiClient, apiFetch, getBizFetchErrorMessage } from "@/src/lib/api-fetch"
|
||||
import { pickImage } from "@/src/lib/native/picker"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { userSyncService } from "@/src/store/user/store"
|
||||
|
||||
export const setAvatar = async () => {
|
||||
const result = await pickImage({
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useUnreadCounts } from "@follow/store/src/unread/hooks"
|
||||
import { cn } from "@follow/utils"
|
||||
import { memo, useState } from "react"
|
||||
import { Text, View } from "react-native"
|
||||
@@ -11,7 +12,6 @@ import { RightCuteFiIcon } from "@/src/icons/right_cute_fi"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { selectFeed } from "@/src/modules/screen/atoms"
|
||||
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
|
||||
import { useUnreadCounts } from "@/src/store/unread/hooks"
|
||||
import { useColor } from "@/src/theme/colors"
|
||||
|
||||
import { SubscriptionFeedCategoryContextMenu } from "../context-menu/feeds"
|
||||
|
||||
@@ -1,4 +1,14 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { FEED_COLLECTION_LIST } from "@follow/store/src/entry/utils"
|
||||
import {
|
||||
useGroupedSubscription,
|
||||
useInboxSubscription,
|
||||
useListSubscription,
|
||||
useSortedGroupedSubscription,
|
||||
useSortedListSubscription,
|
||||
useSortedUngroupedSubscription,
|
||||
} from "@follow/store/src/subscription/hooks"
|
||||
import { subscriptionSyncService } from "@follow/store/src/subscription/store"
|
||||
import type { FlashList } from "@shopify/flash-list"
|
||||
import type { ParseKeys } from "i18next"
|
||||
import { memo, useMemo, useState } from "react"
|
||||
@@ -6,6 +16,7 @@ import { useTranslation } from "react-i18next"
|
||||
import { Text, View } from "react-native"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { useGeneralSettingKey, useHideAllReadSubscriptions } from "@/src/atoms/settings/general"
|
||||
import { useRegisterNavigationScrollView } from "@/src/components/layouts/tabbar/hooks"
|
||||
import {
|
||||
GROUPED_ICON_TEXT_GAP,
|
||||
@@ -22,16 +33,6 @@ import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { selectFeed } from "@/src/modules/screen/atoms"
|
||||
import { TimelineSelectorList } from "@/src/modules/screen/TimelineSelectorList"
|
||||
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
|
||||
import { FEED_COLLECTION_LIST } from "@/src/store/entry/utils"
|
||||
import {
|
||||
useGroupedSubscription,
|
||||
useInboxSubscription,
|
||||
useListSubscription,
|
||||
useSortedGroupedSubscription,
|
||||
useSortedListSubscription,
|
||||
useSortedUngroupedSubscription,
|
||||
} from "@/src/store/subscription/hooks"
|
||||
import { subscriptionSyncService } from "@/src/store/subscription/store"
|
||||
|
||||
import { usePagerListPerformanceHack } from "../entry-list/hooks"
|
||||
import { useFeedListSortMethod, useFeedListSortOrder } from "./atoms"
|
||||
@@ -54,17 +55,37 @@ const SubscriptionListImpl = ({
|
||||
view: FeedViewType
|
||||
active?: boolean
|
||||
}) => {
|
||||
const hideAllReadSubscriptions = useHideAllReadSubscriptions()
|
||||
const autoGroup = useGeneralSettingKey("autoGroup")
|
||||
const listIds = useListSubscription(view)
|
||||
const sortedListIds = useSortedListSubscription(listIds, "alphabet")
|
||||
const sortedListIds = useSortedListSubscription({
|
||||
ids: listIds,
|
||||
sortBy: "alphabet",
|
||||
hideAllReadSubscriptions,
|
||||
})
|
||||
|
||||
const inboxes = useInboxSubscription(view)
|
||||
|
||||
const { grouped, unGrouped } = useGroupedSubscription(view)
|
||||
const { grouped, unGrouped } = useGroupedSubscription({
|
||||
view,
|
||||
autoGroup,
|
||||
})
|
||||
|
||||
const sortBy = useFeedListSortMethod()
|
||||
const sortOrder = useFeedListSortOrder()
|
||||
const sortedGrouped = useSortedGroupedSubscription(view, grouped, sortBy, sortOrder)
|
||||
const sortedUnGrouped = useSortedUngroupedSubscription(unGrouped, sortBy, sortOrder)
|
||||
const sortedGrouped = useSortedGroupedSubscription({
|
||||
view,
|
||||
grouped,
|
||||
sortBy,
|
||||
sortOrder,
|
||||
hideAllReadSubscriptions,
|
||||
})
|
||||
const sortedUnGrouped = useSortedUngroupedSubscription({
|
||||
ids: unGrouped,
|
||||
sortBy,
|
||||
sortOrder,
|
||||
hideAllReadSubscriptions,
|
||||
})
|
||||
|
||||
const data = useMemo(
|
||||
() => [
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useSortedUngroupedSubscription } from "@follow/store/src/subscription/hooks"
|
||||
import type { FC } from "react"
|
||||
|
||||
import { useSortedUngroupedSubscription } from "@/src/store/subscription/hooks"
|
||||
import { useHideAllReadSubscriptions } from "@/src/atoms/settings/general"
|
||||
|
||||
import { useFeedListSortMethod, useFeedListSortOrder } from "./atoms"
|
||||
import { SubscriptionItem } from "./items/SubscriptionItem"
|
||||
@@ -11,7 +12,13 @@ export const UnGroupedList: FC<{
|
||||
}> = ({ subscriptionIds, isLastGroup }) => {
|
||||
const sortBy = useFeedListSortMethod()
|
||||
const sortOrder = useFeedListSortOrder()
|
||||
const sortedSubscriptionIds = useSortedUngroupedSubscription(subscriptionIds, sortBy, sortOrder)
|
||||
const hideAllReadSubscriptions = useHideAllReadSubscriptions()
|
||||
const sortedSubscriptionIds = useSortedUngroupedSubscription({
|
||||
ids: subscriptionIds,
|
||||
sortBy,
|
||||
sortOrder,
|
||||
hideAllReadSubscriptions,
|
||||
})
|
||||
|
||||
return sortedSubscriptionIds.map((id, index) => (
|
||||
<SubscriptionItem
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { useSubscription } from "@follow/store/src/subscription/hooks"
|
||||
import { getInboxStoreId } from "@follow/store/src/subscription/utils"
|
||||
import { useUnreadCount } from "@follow/store/src/unread/hooks"
|
||||
import { cn } from "@follow/utils"
|
||||
import { useColorScheme } from "nativewind"
|
||||
import { memo } from "react"
|
||||
@@ -11,9 +14,6 @@ import { InboxCuteFiIcon } from "@/src/icons/inbox_cute_fi"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { selectFeed } from "@/src/modules/screen/atoms"
|
||||
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
|
||||
import { useSubscription } from "@/src/store/subscription/hooks"
|
||||
import { getInboxStoreId } from "@/src/store/subscription/utils"
|
||||
import { useUnreadCount } from "@/src/store/unread/hooks"
|
||||
|
||||
import { InboxContextMenu } from "../../context-menu/inbox"
|
||||
import type { SubscriptionItemBaseProps } from "./types"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { useList } from "@follow/store/src/list/hooks"
|
||||
import { useSubscription } from "@follow/store/src/subscription/hooks"
|
||||
import { useListUnreadCount } from "@follow/store/src/unread/hooks"
|
||||
import { cn } from "@follow/utils"
|
||||
import { memo } from "react"
|
||||
import { Text, View } from "react-native"
|
||||
@@ -12,9 +15,6 @@ import { ItemPressableStyle } from "@/src/components/ui/pressable/enum"
|
||||
import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
|
||||
import { useList } from "@/src/store/list/hooks"
|
||||
import { useSubscription } from "@/src/store/subscription/hooks"
|
||||
import { useListUnreadCount } from "@/src/store/unread/hooks"
|
||||
|
||||
import { SubscriptionListItemContextMenu } from "../../context-menu/lists"
|
||||
import { selectFeed } from "../../screen/atoms"
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import { useFeed, usePrefetchFeed } from "@follow/store/src/feed/hooks"
|
||||
import { useSubscription } from "@follow/store/src/subscription/hooks"
|
||||
import { useUnreadCount } from "@follow/store/src/unread/hooks"
|
||||
import { cn } from "@follow/utils"
|
||||
import { memo, use } from "react"
|
||||
import { Text, View } from "react-native"
|
||||
@@ -14,9 +17,6 @@ import { WifiOffCuteReIcon } from "@/src/icons/wifi_off_cute_re"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { selectFeed } from "@/src/modules/screen/atoms"
|
||||
import { FeedScreen } from "@/src/screens/(stack)/feeds/[feedId]/FeedScreen"
|
||||
import { useFeed, usePrefetchFeed } from "@/src/store/feed/hooks"
|
||||
import { useSubscription } from "@/src/store/subscription/hooks"
|
||||
import { useUnreadCount } from "@/src/store/unread/hooks"
|
||||
|
||||
import { SubscriptionFeedItemContextMenu } from "../../context-menu/feeds"
|
||||
import { GroupedContext } from "../ctx"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import { useWhoami } from "@follow/store/src/user/hooks"
|
||||
import { userSyncService } from "@follow/store/src/user/store"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { useMemo, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
@@ -18,8 +20,6 @@ import {
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { useWhoami } from "@/src/store/user/hooks"
|
||||
import { userSyncService } from "@/src/store/user/store"
|
||||
|
||||
export const EditEmailScreen: NavigationControllerView = () => {
|
||||
const { t } = useTranslation("settings")
|
||||
@@ -102,7 +102,9 @@ export const EditEmailScreen: NavigationControllerView = () => {
|
||||
}
|
||||
onPress={() => {
|
||||
setIsSendingVerificationEmail(true)
|
||||
userSyncService.sendVerificationEmail()
|
||||
userSyncService.sendVerificationEmail().then(() => {
|
||||
toast.success("Verification email sent")
|
||||
})
|
||||
}}
|
||||
/>
|
||||
</GroupedInsetListCard>
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { userSyncService } from "@follow/store/src/user/store"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { useState } from "react"
|
||||
import { View } from "react-native"
|
||||
@@ -17,7 +18,6 @@ import { getBizFetchErrorMessage } from "@/src/lib/api-fetch"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { userSyncService } from "@/src/store/user/store"
|
||||
|
||||
export const InvitationScreen: NavigationControllerView = () => {
|
||||
const [code, setCode] = useState("")
|
||||
|
||||
@@ -1,5 +1,10 @@
|
||||
import { useActionSheet } from "@expo/react-native-action-sheet"
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { getList } from "@follow/store/src/list/getters"
|
||||
import { useList } from "@follow/store/src/list/hooks"
|
||||
import type { ListModel } from "@follow/store/src/list/store"
|
||||
import { listSyncServices } from "@follow/store/src/list/store"
|
||||
import type { CreateListModel } from "@follow/store/src/list/types"
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { memo, useEffect, useState } from "react"
|
||||
import { Controller, useForm } from "react-hook-form"
|
||||
@@ -26,11 +31,6 @@ import { useSetModalScreenOptions } from "@/src/lib/navigation/ScreenOptionsCont
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { FeedViewSelector } from "@/src/modules/feed/view-selector"
|
||||
import { getList } from "@/src/store/list/getters"
|
||||
import { useList } from "@/src/store/list/hooks"
|
||||
import type { ListModel } from "@/src/store/list/store"
|
||||
import { listSyncServices } from "@/src/store/list/store"
|
||||
import type { CreateListModel } from "@/src/store/list/types"
|
||||
import { accentColor } from "@/src/theme/colors"
|
||||
|
||||
const listSchema = z.object({
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useWhoami } from "@follow/store/src/user/hooks"
|
||||
import { Fragment, useEffect } from "react"
|
||||
import { ScrollView, Text, TouchableOpacity } from "react-native"
|
||||
|
||||
@@ -6,7 +7,6 @@ import { Navigation } from "@/src/lib/navigation/Navigation"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { useIsiPad } from "@/src/lib/platform"
|
||||
import { Login } from "@/src/modules/login"
|
||||
import { useWhoami } from "@/src/store/user/hooks"
|
||||
|
||||
function exit() {
|
||||
const router = Navigation.rootNavigation
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import type { FeedModel } from "@follow/store/src/feed/types"
|
||||
import type { ListModel } from "@follow/store/src/list/store"
|
||||
import { getSubscription } from "@follow/store/src/subscription/getter"
|
||||
import { subscriptionSyncService } from "@follow/store/src/subscription/store"
|
||||
import { useUser, useWhoami } from "@follow/store/src/user/hooks"
|
||||
import { userSyncService } from "@follow/store/src/user/store"
|
||||
import { useQuery } from "@tanstack/react-query"
|
||||
import { createContext, Fragment, use, useCallback, useEffect, useMemo } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
@@ -41,12 +47,6 @@ import { toast } from "@/src/lib/toast"
|
||||
import { useShareSubscription } from "@/src/modules/settings/hooks/useShareSubscription"
|
||||
import { UserHeaderBanner } from "@/src/modules/settings/UserHeaderBanner"
|
||||
import { ItemSeparator } from "@/src/modules/subscription/ItemSeparator"
|
||||
import type { FeedModel } from "@/src/store/feed/types"
|
||||
import type { ListModel } from "@/src/store/list/store"
|
||||
import { getSubscription } from "@/src/store/subscription/getter"
|
||||
import { subscriptionSyncService } from "@/src/store/subscription/store"
|
||||
import { useUser, useWhoami } from "@/src/store/user/hooks"
|
||||
import { userSyncService } from "@/src/store/user/store"
|
||||
import { useColor } from "@/src/theme/colors"
|
||||
|
||||
import { FeedScreen } from "../(stack)/feeds/[feedId]/FeedScreen"
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { RSSHubParameter, RSSHubParameterObject, RSSHubRoute } from "@follow/models/src/rsshub"
|
||||
import { feedSyncServices } from "@follow/store/src/feed/store"
|
||||
import {
|
||||
MissingOptionalParamError,
|
||||
parseFullPathParams,
|
||||
@@ -26,7 +27,6 @@ import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { useSetModalScreenOptions } from "@/src/lib/navigation/ScreenOptionsContext"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { feedSyncServices } from "@/src/store/feed/store"
|
||||
|
||||
import { FollowScreen } from "./FollowScreen"
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { whoamiQueryKey } from "@follow/store/src/user/hooks"
|
||||
import { useMutation } from "@tanstack/react-query"
|
||||
import { useRef } from "react"
|
||||
import { Text, TouchableWithoutFeedback, View } from "react-native"
|
||||
@@ -13,7 +14,6 @@ import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { queryClient } from "@/src/lib/query-client"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
import { whoamiQueryKey } from "@/src/store/user/hooks"
|
||||
import { accentColor } from "@/src/theme/colors"
|
||||
|
||||
export const TwoFactorAuthScreen: NavigationControllerView = () => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { useWhoami } from "@follow/store/src/user/hooks"
|
||||
import { use } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
import type { ScrollView } from "react-native"
|
||||
@@ -18,7 +19,6 @@ import { ScreenItemContext } from "@/src/lib/navigation/ScreenItemContext"
|
||||
import { EditProfileScreen } from "@/src/modules/settings/routes/EditProfile"
|
||||
import { SettingsList } from "@/src/modules/settings/SettingsList"
|
||||
import { UserHeaderBanner } from "@/src/modules/settings/UserHeaderBanner"
|
||||
import { useWhoami } from "@/src/store/user/hooks"
|
||||
|
||||
export function Settings() {
|
||||
const insets = useSafeAreaInsets()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { useWhoami } from "@follow/store/src/user/hooks"
|
||||
import { useMemo } from "react"
|
||||
import { useColor } from "react-native-uikit-colors"
|
||||
|
||||
@@ -13,7 +14,6 @@ import { EntryListContext } from "@/src/modules/screen/atoms"
|
||||
import { PagerList } from "@/src/modules/screen/PagerList"
|
||||
import { TimelineHeader } from "@/src/modules/screen/TimelineSelectorProvider"
|
||||
import { SubscriptionList } from "@/src/modules/subscription/SubscriptionLists"
|
||||
import { useWhoami } from "@/src/store/user/hooks"
|
||||
|
||||
export default function Subscriptions() {
|
||||
const whoami = useWhoami()
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useEntry, usePrefetchEntryDetail } from "@follow/store/src/entry/hooks"
|
||||
import { entrySyncServices } from "@follow/store/src/entry/store"
|
||||
import type { EntryWithTranslation } from "@follow/store/src/entry/types"
|
||||
import { useFeed } from "@follow/store/src/feed/hooks"
|
||||
import {
|
||||
useEntryTranslation,
|
||||
usePrefetchEntryTranslation,
|
||||
} from "@follow/store/src/translation/hooks"
|
||||
import { useAutoMarkAsRead } from "@follow/store/src/unread/hooks"
|
||||
import { PortalProvider } from "@gorhom/portal"
|
||||
import { atom, useAtomValue, useSetAtom } from "jotai"
|
||||
import { useCallback, useEffect, useMemo } from "react"
|
||||
@@ -6,7 +15,7 @@ import { Text, View } from "react-native"
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
||||
import { useColor } from "react-native-uikit-colors"
|
||||
|
||||
import { useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
import { useActionLanguage, useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
import { BottomTabBarHeightContext } from "@/src/components/layouts/tabbar/contexts/BottomTabBarHeightContext"
|
||||
import { SafeNavigationScrollView } from "@/src/components/layouts/views/SafeNavigationScrollView"
|
||||
import { EntryContentWebView } from "@/src/components/native/webview/EntryContentWebView"
|
||||
@@ -18,16 +27,11 @@ import { CalendarTimeAddCuteReIcon } from "@/src/icons/calendar_time_add_cute_re
|
||||
import { openLink } from "@/src/lib/native"
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { checkLanguage } from "@/src/lib/translation"
|
||||
import { EntryContentContext, useEntryContentContext } from "@/src/modules/entry-content/ctx"
|
||||
import { EntryAISummary } from "@/src/modules/entry-content/EntryAISummary"
|
||||
import { EntryNavigationHeader } from "@/src/modules/entry-content/EntryNavigationHeader"
|
||||
import { usePullUpToNext } from "@/src/modules/entry-content/use-pull-up-to-next"
|
||||
import { useEntry, usePrefetchEntryDetail } from "@/src/store/entry/hooks"
|
||||
import { entrySyncServices } from "@/src/store/entry/store"
|
||||
import type { EntryWithTranslation } from "@/src/store/entry/types"
|
||||
import { useFeed } from "@/src/store/feed/hooks"
|
||||
import { useEntryTranslation, usePrefetchEntryTranslation } from "@/src/store/translation/hooks"
|
||||
import { useAutoMarkAsRead } from "@/src/store/unread/hooks"
|
||||
|
||||
import { EntrySocialTitle, EntryTitle } from "../../../../modules/entry-content/EntryTitle"
|
||||
|
||||
@@ -38,7 +42,8 @@ export const EntryDetailScreen: NavigationControllerView<{
|
||||
}> = ({ entryId, entryIds, view: viewType }) => {
|
||||
useAutoMarkAsRead(entryId)
|
||||
const entry = useEntry(entryId)
|
||||
const translation = useEntryTranslation(entryId)
|
||||
const actionLanguage = useActionLanguage()
|
||||
const translation = useEntryTranslation(entryId, actionLanguage)
|
||||
const entryWithTranslation = useMemo(() => {
|
||||
if (!entry) return entry
|
||||
return {
|
||||
@@ -128,10 +133,15 @@ const EntryContentWebViewWithContext = ({ entry }: { entry: EntryWithTranslation
|
||||
const translationSetting = useGeneralSettingKey("translation")
|
||||
const showTranslation = useAtomValue(showAITranslationAtom)
|
||||
const entryId = entry.id
|
||||
const actionLanguage = useActionLanguage()
|
||||
const translation = useGeneralSettingKey("translation")
|
||||
usePrefetchEntryTranslation({
|
||||
entryIds: [entryId],
|
||||
withContent: true,
|
||||
target: showReadability && entry.readabilityContent ? "readabilityContent" : "content",
|
||||
language: actionLanguage,
|
||||
checkLanguage,
|
||||
translation,
|
||||
})
|
||||
|
||||
// Auto toggle readability when content is empty
|
||||
|
||||
@@ -1,4 +1,13 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
import { useCollectionEntryList } from "@follow/store/src/collection/hooks"
|
||||
import {
|
||||
useEntryIdsByCategory,
|
||||
useEntryIdsByFeedId,
|
||||
useEntryIdsByInboxId,
|
||||
useEntryIdsByListId,
|
||||
} from "@follow/store/src/entry/hooks"
|
||||
import { FEED_COLLECTION_LIST } from "@follow/store/src/entry/utils"
|
||||
import { useFeed } from "@follow/store/src/feed/hooks"
|
||||
import { useMemo } from "react"
|
||||
import { RootSiblingParent } from "react-native-root-siblings"
|
||||
import { useSafeAreaInsets } from "react-native-safe-area-context"
|
||||
@@ -8,15 +17,6 @@ import type { NavigationControllerView } from "@/src/lib/navigation/types"
|
||||
import { EntryListSelector } from "@/src/modules/entry-list/EntryListSelector"
|
||||
import { EntryListContext, useSelectedView } from "@/src/modules/screen/atoms"
|
||||
import { TimelineHeader } from "@/src/modules/screen/TimelineSelectorProvider"
|
||||
import { useCollectionEntryList } from "@/src/store/collection/hooks"
|
||||
import {
|
||||
useEntryIdsByCategory,
|
||||
useEntryIdsByFeedId,
|
||||
useEntryIdsByInboxId,
|
||||
useEntryIdsByListId,
|
||||
} from "@/src/store/entry/hooks"
|
||||
import { FEED_COLLECTION_LIST } from "@/src/store/entry/utils"
|
||||
import { useFeed } from "@/src/store/feed/hooks"
|
||||
|
||||
export const FeedScreen: NavigationControllerView<{
|
||||
feedId: string
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { isNewUserQueryKey, isOnboardingFinishedStorageKey } from "@follow/store/src/user/constants"
|
||||
import { tracker } from "@follow/tracker"
|
||||
import { useCallback, useEffect, useState } from "react"
|
||||
import { useTranslation } from "react-i18next"
|
||||
@@ -13,7 +14,6 @@ import { StepFinished } from "../modules/onboarding/step-finished"
|
||||
import { StepInterests } from "../modules/onboarding/step-interests"
|
||||
import { StepPreferences } from "../modules/onboarding/step-preferences"
|
||||
import { StepWelcome } from "../modules/onboarding/step-welcome"
|
||||
import { isNewUserQueryKey, isOnboardingFinishedStorageKey } from "../store/user/constants"
|
||||
|
||||
export const OnboardingScreen: NavigationControllerView = () => {
|
||||
const { t } = useTranslation("common")
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { usePrefetchImageColors } from "@follow/store/src/image/hooks"
|
||||
import { cn } from "@follow/utils"
|
||||
import { LinearGradient } from "expo-linear-gradient"
|
||||
import { useEffect, useMemo } from "react"
|
||||
@@ -19,7 +20,6 @@ import { useActiveTrack, useIsPlaying } from "../lib/player"
|
||||
import { PlayerScreenContext, usePlayerScreenContext } from "../modules/player/context"
|
||||
import { ControlGroup, ProgressBar, VolumeBar } from "../modules/player/control"
|
||||
import { useCoverGradient } from "../modules/player/hooks"
|
||||
import { usePrefetchImageColors } from "../store/image/hooks"
|
||||
|
||||
function CoverArt({ cover }: { cover?: string }) {
|
||||
const scale = useSharedValue(1)
|
||||
|
||||
@@ -1,58 +0,0 @@
|
||||
import { FeedViewType } from "@follow/constants"
|
||||
|
||||
import type { SelectedFeed, SelectedTimeline } from "@/src/modules/screen/atoms"
|
||||
|
||||
import { getSubscriptionByCategory } from "../subscription/getter"
|
||||
import { useEntryStore } from "./store"
|
||||
import type { EntryModel, FetchEntriesProps } from "./types"
|
||||
import { FEED_COLLECTION_LIST } from "./utils"
|
||||
|
||||
const get = useEntryStore.getState
|
||||
|
||||
export const getEntry = (id: string): EntryModel | undefined => {
|
||||
return get().data[id]
|
||||
}
|
||||
|
||||
export const getFetchEntryPayload = (
|
||||
selectedFeed: SelectedTimeline | SelectedFeed,
|
||||
view: FeedViewType = FeedViewType.Articles,
|
||||
): FetchEntriesProps | null => {
|
||||
if (!selectedFeed) {
|
||||
return null
|
||||
}
|
||||
|
||||
let payload: FetchEntriesProps = {}
|
||||
switch (selectedFeed.type) {
|
||||
case "view": {
|
||||
payload = { view: selectedFeed.viewId }
|
||||
break
|
||||
}
|
||||
case "feed": {
|
||||
payload = { feedId: selectedFeed.feedId }
|
||||
break
|
||||
}
|
||||
case "category": {
|
||||
payload = {
|
||||
feedIdList: getSubscriptionByCategory({ category: selectedFeed.categoryName, view }),
|
||||
}
|
||||
break
|
||||
}
|
||||
case "list": {
|
||||
payload = { listId: selectedFeed.listId }
|
||||
break
|
||||
}
|
||||
case "inbox": {
|
||||
payload = { inboxId: selectedFeed.inboxId }
|
||||
break
|
||||
}
|
||||
// No default
|
||||
}
|
||||
const isCollection =
|
||||
selectedFeed && selectedFeed.type === "feed" && selectedFeed?.feedId === FEED_COLLECTION_LIST
|
||||
if (isCollection) {
|
||||
payload.view = view
|
||||
payload.isCollection = true
|
||||
}
|
||||
|
||||
return payload
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
export interface Hydratable {
|
||||
hydrate: () => Promise<void>
|
||||
}
|
||||
@@ -17,6 +17,7 @@ export interface ViewDefinition {
|
||||
view: FeedViewType
|
||||
wideMode?: boolean
|
||||
gridMode?: boolean
|
||||
activeColor: string
|
||||
}
|
||||
export const views: ViewDefinition[] = [
|
||||
{
|
||||
@@ -26,6 +27,7 @@ export const views: ViewDefinition[] = [
|
||||
peerClassName: "peer-checked:text-accent dark:peer-checked:text-accent",
|
||||
translation: "title,description",
|
||||
view: FeedViewType.Articles,
|
||||
activeColor: "#FF5C00",
|
||||
},
|
||||
{
|
||||
name: "feed_view_type.social_media",
|
||||
@@ -35,6 +37,8 @@ export const views: ViewDefinition[] = [
|
||||
wideMode: true,
|
||||
translation: "content",
|
||||
view: FeedViewType.SocialMedia,
|
||||
// sky-500
|
||||
activeColor: "#0ea5e9",
|
||||
},
|
||||
{
|
||||
name: "feed_view_type.pictures",
|
||||
@@ -45,6 +49,8 @@ export const views: ViewDefinition[] = [
|
||||
wideMode: true,
|
||||
translation: "title",
|
||||
view: FeedViewType.Pictures,
|
||||
// green-500
|
||||
activeColor: "#22c55e",
|
||||
},
|
||||
{
|
||||
name: "feed_view_type.videos",
|
||||
@@ -55,6 +61,8 @@ export const views: ViewDefinition[] = [
|
||||
wideMode: true,
|
||||
translation: "title",
|
||||
view: FeedViewType.Videos,
|
||||
// red-500
|
||||
activeColor: "#ef4444",
|
||||
},
|
||||
{
|
||||
name: "feed_view_type.audios",
|
||||
@@ -63,6 +71,8 @@ export const views: ViewDefinition[] = [
|
||||
peerClassName: "peer-checked:text-purple-600 peer-checked:dark:text-purple-500",
|
||||
translation: "title",
|
||||
view: FeedViewType.Audios,
|
||||
// purple-500
|
||||
activeColor: "#a855f7",
|
||||
},
|
||||
{
|
||||
name: "feed_view_type.notifications",
|
||||
@@ -71,6 +81,8 @@ export const views: ViewDefinition[] = [
|
||||
peerClassName: "peer-checked:text-yellow-600 peer-checked:dark:text-yellow-500",
|
||||
translation: "title",
|
||||
view: FeedViewType.Notifications,
|
||||
// yellow-500
|
||||
activeColor: "#eab308",
|
||||
},
|
||||
]
|
||||
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "@follow/store",
|
||||
"type": "module",
|
||||
"private": true,
|
||||
"author": "Folo Team",
|
||||
"license": "GPL-3.0-only",
|
||||
"homepage": "https://github.com/RSSNext",
|
||||
"repository": {
|
||||
"url": "https://github.com/RSSNext/follow",
|
||||
"type": "git"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"exports": {
|
||||
"./src/*": {
|
||||
"types": "./src/*.ts",
|
||||
"require": "./src/*.ts",
|
||||
"import": "./src/*.ts"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^19.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@follow/configs": "workspace:*",
|
||||
"@follow/constants": "workspace:*",
|
||||
"@follow/database": "workspace:*",
|
||||
"@follow/models": "workspace:*",
|
||||
"@follow/shared": "workspace:*",
|
||||
"@follow/tracker": "workspace:*",
|
||||
"@follow/utils": "workspace:*",
|
||||
"@tanstack/react-query": "5.74.7",
|
||||
"es-toolkit": "1.36.0",
|
||||
"immer": "10.1.1",
|
||||
"zustand": "5.0.3"
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,7 @@ import { useMutation, useQuery } from "@tanstack/react-query"
|
||||
import { FetchError } from "ofetch"
|
||||
import { useCallback } from "react"
|
||||
|
||||
import { useNavigation } from "@/src/lib/navigation/hooks"
|
||||
import { toast } from "@/src/lib/toast"
|
||||
|
||||
import type { GeneralMutationOptions } from "../types"
|
||||
import { actionSyncService, useActionStore } from "./store"
|
||||
|
||||
export const usePrefetchActions = () => {
|
||||
@@ -14,22 +12,20 @@ export const usePrefetchActions = () => {
|
||||
})
|
||||
}
|
||||
|
||||
export const useUpdateActionsMutation = () => {
|
||||
const navigation = useNavigation()
|
||||
export const useUpdateActionsMutation = (options?: GeneralMutationOptions) => {
|
||||
return useMutation({
|
||||
mutationFn: () => actionSyncService.saveRules(),
|
||||
onSuccess() {
|
||||
navigation.back()
|
||||
toast.success("Actions saved")
|
||||
options?.onSuccess?.()
|
||||
},
|
||||
onError(err) {
|
||||
if (err instanceof FetchError && err.response?._data) {
|
||||
const { message } = err.response._data
|
||||
toast.error(message)
|
||||
options?.onError?.(message)
|
||||
return
|
||||
}
|
||||
|
||||
toast.error("Error saving actions")
|
||||
options?.onError?.("Error saving actions")
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -7,8 +7,6 @@ import type {
|
||||
} from "@follow/models/src/types"
|
||||
import { merge } from "es-toolkit/compat"
|
||||
|
||||
import { apiClient } from "@/src/lib/api-fetch"
|
||||
|
||||
import { createImmerSetter, createZustandStore } from "../internal/helper"
|
||||
|
||||
type ActionStore = {
|
||||
-2
@@ -2,8 +2,6 @@ import type { FeedViewType } from "@follow/constants"
|
||||
import type { CollectionSchema } from "@follow/database/src/schemas/types"
|
||||
import { CollectionService } from "@follow/database/src/services/collection"
|
||||
|
||||
import { apiClient } from "@/src/lib/api-fetch"
|
||||
|
||||
import type { Hydratable } from "../internal/base"
|
||||
import { createTransaction, createZustandStore } from "../internal/helper"
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { useEntryStore } from "./store"
|
||||
import type { EntryModel } from "./types"
|
||||
|
||||
const get = useEntryStore.getState
|
||||
|
||||
export const getEntry = (id: string): EntryModel | undefined => {
|
||||
return get().data[id]
|
||||
}
|
||||
@@ -1,19 +1,25 @@
|
||||
import type { FeedViewType } from "@follow/constants"
|
||||
import { useInfiniteQuery, useMutation, useQuery } from "@tanstack/react-query"
|
||||
import { useCallback, useEffect } from "react"
|
||||
|
||||
import { useGeneralSettingKey } from "@/src/atoms/settings/general"
|
||||
import { useInfiniteQuery, useQuery } from "@tanstack/react-query"
|
||||
import { useCallback } from "react"
|
||||
|
||||
import { getEntry } from "./getter"
|
||||
import { entrySyncServices, useEntryStore } from "./store"
|
||||
import type { EntryModel, FetchEntriesProps } from "./types"
|
||||
import type { EntryModel, FetchEntriesProps, FetchEntriesPropsSettings } from "./types"
|
||||
|
||||
export const usePrefetchEntries = (
|
||||
props: Omit<FetchEntriesProps, "pageParam" | "read"> & FetchEntriesPropsSettings,
|
||||
) => {
|
||||
const {
|
||||
feedId,
|
||||
inboxId,
|
||||
listId,
|
||||
view,
|
||||
limit,
|
||||
feedIdList,
|
||||
unreadOnly,
|
||||
hidePrivateSubscriptionsInTimeline,
|
||||
} = props || {}
|
||||
|
||||
export const usePrefetchEntries = (props: Omit<FetchEntriesProps, "pageParam" | "read"> | null) => {
|
||||
const { feedId, inboxId, listId, view, limit, feedIdList } = props || {}
|
||||
const unreadOnly = useGeneralSettingKey("unreadOnly")
|
||||
const hidePrivateSubscriptionsInTimeline = useGeneralSettingKey(
|
||||
"hidePrivateSubscriptionsInTimeline",
|
||||
)
|
||||
return useInfiniteQuery({
|
||||
queryKey: [
|
||||
"entries",
|
||||
@@ -147,15 +153,3 @@ export const useEntryIdsByListId = (listId: string) => {
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
export const useFetchEntryContentByStream = (remoteEntryIds?: string[]) => {
|
||||
const { mutate: updateEntryContent } = useMutation({
|
||||
mutationKey: ["stream-entry-content", remoteEntryIds],
|
||||
mutationFn: entrySyncServices.fetchEntryContentByStream,
|
||||
})
|
||||
|
||||
useEffect(() => {
|
||||
if (!remoteEntryIds) return
|
||||
updateEntryContent(remoteEntryIds)
|
||||
}, [remoteEntryIds, updateEntryContent])
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user