feat(desktop): return to back path in preview mode (#4168)
This commit is contained in:
@@ -8,9 +8,11 @@ import {
|
||||
import { useUserRole } from "@follow/store/user/hooks"
|
||||
import { t } from "i18next"
|
||||
import { useCallback } from "react"
|
||||
import { useNavigate } from "react-router"
|
||||
import { withoutTrailingSlash, withTrailingSlash } from "ufo"
|
||||
import { useEventCallback } from "usehooks-ts"
|
||||
|
||||
import { previewBackPath } from "~/atoms/preview"
|
||||
import { useServerConfigs } from "~/atoms/server-configs"
|
||||
import { useModalStack } from "~/components/ui/modal/stacked/hooks"
|
||||
import { CustomSafeError } from "~/errors/CustomSafeError"
|
||||
@@ -67,6 +69,7 @@ export interface FollowOptions {
|
||||
export const useFollow = () => {
|
||||
const { present } = useModalStack()
|
||||
const canFollowMoreInboxAndNotify = useCanFollowMoreInboxAndNotify()
|
||||
const navigate = useNavigate()
|
||||
|
||||
return useCallback(
|
||||
(options?: FollowOptions) => {
|
||||
@@ -92,6 +95,9 @@ export const useFollow = () => {
|
||||
content: ({ dismiss }) => {
|
||||
const onSuccess = () => {
|
||||
options?.onSuccess?.()
|
||||
// If it's a preview, navigate to the back path
|
||||
const backPath = previewBackPath()
|
||||
backPath && navigate(backPath)
|
||||
dismiss()
|
||||
}
|
||||
return options?.isList ? (
|
||||
|
||||
@@ -207,7 +207,7 @@ const FeedItemImpl = ({ view, feedId, className, isPreview }: FeedItemProps) =>
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
{isPreview && (
|
||||
{isPreview ? (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
@@ -222,8 +222,9 @@ const FeedItemImpl = ({ view, feedId, className, isPreview }: FeedItemProps) =>
|
||||
>
|
||||
<i className="i-mgc-add-cute-re text-accent text-base" />
|
||||
</Button>
|
||||
) : (
|
||||
<UnreadNumber unread={feedUnread} className="ml-2" />
|
||||
)}
|
||||
<UnreadNumber unread={feedUnread} className="ml-2" />
|
||||
</DraggableItemWrapper>
|
||||
)
|
||||
}
|
||||
@@ -325,7 +326,7 @@ const ListItemImpl: Component<ListItemProps> = ({
|
||||
</Tooltip>
|
||||
)}
|
||||
</div>
|
||||
{isPreview && (
|
||||
{isPreview ? (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
@@ -339,8 +340,9 @@ const ListItemImpl: Component<ListItemProps> = ({
|
||||
>
|
||||
<i className="i-mgc-add-cute-re text-accent text-base" />
|
||||
</Button>
|
||||
) : (
|
||||
<UnreadNumber unread={listUnread} className="ml-2" />
|
||||
)}
|
||||
<UnreadNumber unread={listUnread} className="ml-2" />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
+3
-1
@@ -35,7 +35,9 @@ export const EmptyFeedList = memo(({ onClick }: { onClick?: (e: React.MouseEvent
|
||||
onClick={handleClick}
|
||||
>
|
||||
<i className="i-mgc-arrow-right-up-cute-re text-3xl" />
|
||||
<span className="text-balance text-sm">{t("sidebar.already_on_discover_page")}</span>
|
||||
<span className="text-balance text-center text-sm">
|
||||
{t("sidebar.already_on_discover_page")}
|
||||
</span>
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user