fix: sync active view after close sheet

This commit is contained in:
Stephen Zhou
2024-11-25 18:49:10 +08:00
parent 42ccdeaf29
commit 6f751a4a21
@@ -12,12 +12,14 @@ import * as React from "react"
import { useTranslation } from "react-i18next"
import { setGeneralSetting, useGeneralSettingKey } from "~/atoms/settings/general"
import { getSidebarActiveView } from "~/atoms/sidebar"
import { useWhoami } from "~/atoms/user"
import { HeaderTopReturnBackButton } from "~/components/mobile/button"
import { FEED_COLLECTION_LIST, ROUTE_FEED_IN_LIST } from "~/constants"
import { LOGO_MOBILE_ID } from "~/constants/dom"
import { shortcuts } from "~/constants/shortcuts"
import { useRouteParams } from "~/hooks/biz/useRouteParams"
import { navigateEntry } from "~/hooks/biz/useNavigateEntry"
import { getRouteParams, useRouteParams } from "~/hooks/biz/useRouteParams"
import { FeedColumnMobile } from "~/modules/app-layout/feed-column/mobile"
import { useRefreshFeedMutation } from "~/queries/feed"
import { useFeedById, useFeedHeaderTitle } from "~/store/feed"
@@ -177,6 +179,18 @@ const FollowSubscriptionButton = () => {
content={<FeedColumnMobile asWidget />}
modalClassName="bg-background pt-4 h-[calc(100svh-3rem)]"
contentClassName="p-0 overflow-visible"
onOpenChange={(isOpen) => {
if (!isOpen) {
const sidebarActiveView = getSidebarActiveView()
const { view } = getRouteParams()
if (sidebarActiveView !== view) {
navigateEntry({
view: sidebarActiveView,
feedId: null,
})
}
}
}}
>
<ActionButton
id={LOGO_MOBILE_ID}