diff --git a/apps/desktop/layer/renderer/src/components/common/SharePanel.tsx b/apps/desktop/layer/renderer/src/components/common/SharePanel.tsx index b1d636e25..09a446da6 100644 --- a/apps/desktop/layer/renderer/src/components/common/SharePanel.tsx +++ b/apps/desktop/layer/renderer/src/components/common/SharePanel.tsx @@ -5,7 +5,6 @@ import { useTranslation } from "react-i18next" import { toast } from "sonner" import { ipcServices } from "~/lib/client" -import { UrlBuilder } from "~/lib/url-builder" import { getEntry } from "~/store/entry" interface SharePanelProps { @@ -66,7 +65,27 @@ const socialOptions: SocialShareOption[] = [ ] const getShareUrl = (entryId: string) => { - return UrlBuilder.shareEntry(entryId) + const entry = getEntry(entryId) + if (!entry) return "" + + // Temporarily use the original link + return entry.entries.url! + // const params = getRouteParams() + + // let subscriptionId = "all" + + // if (params.feedId) { + // subscriptionId = params.feedId + // } else if (params.inboxId) { + // subscriptionId = params.inboxId + // } else if (params.listId) { + // subscriptionId = params.listId + // } + + // return UrlBuilder.shareEntry(entryId, { + // view: params.view, + // subscriptionId, + // }) } export const SharePanel = ({ entryId }: SharePanelProps) => { diff --git a/apps/desktop/layer/renderer/src/lib/url-builder.ts b/apps/desktop/layer/renderer/src/lib/url-builder.ts index 4ab887427..6dc99f6f7 100644 --- a/apps/desktop/layer/renderer/src/lib/url-builder.ts +++ b/apps/desktop/layer/renderer/src/lib/url-builder.ts @@ -1,5 +1,24 @@ +import { FeedViewType } from "@follow/constants" import { UrlBuilder as UrlBuilderClass } from "@follow/utils/url-builder" import { WEB_URL } from "~/constants/env" -export const UrlBuilder = new UrlBuilderClass(WEB_URL) +class WebUrlBuilder extends UrlBuilderClass { + constructor() { + super(WEB_URL) + } + + shareEntry( + id: string, + options?: { + view?: FeedViewType + subscriptionId?: string + }, + ) { + const { view = FeedViewType.Articles, subscriptionId = "all" } = options || {} + + return super.join(`timeline/view-${view}/${subscriptionId}/${id}`, { share: "1" }) + } +} + +export const UrlBuilder = new WebUrlBuilder() diff --git a/packages/internal/utils/src/url-builder.ts b/packages/internal/utils/src/url-builder.ts index ce01f3bfc..c35cfc3be 100644 --- a/packages/internal/utils/src/url-builder.ts +++ b/packages/internal/utils/src/url-builder.ts @@ -1,6 +1,6 @@ export class UrlBuilder { constructor(private readonly webUrl: string) {} - private join(path: string, query?: Record) { + protected join(path: string, query?: Record) { const nextUrl = new URL(this.webUrl) nextUrl.pathname = path if (query) { @@ -17,10 +17,6 @@ export class UrlBuilder { return this.join(`share/lists/${id}`, view ? { view: view.toString() } : undefined) } - shareEntry(id: string) { - return this.join(`timeline/view-0/all/${id}`, { share: "1" }) - } - profile(id: string) { return this.join(`share/users/${id}`) }