Skip to content

Commit

Permalink
refactor: update source content view entry
Browse files Browse the repository at this point in the history
  • Loading branch information
lawvs committed Sep 27, 2024
1 parent 58a1291 commit 55c27ba
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
30 changes: 24 additions & 6 deletions apps/renderer/src/hooks/biz/useEntryActions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import {
setReadabilityStatus,
} from "~/atoms/readability"
import { useIntegrationSettingKey } from "~/atoms/settings/integration"
import { getShowSourceContent, toggleShowSourceContent } from "~/atoms/source-content"
import {
getShowSourceContent,
setShowSourceContent,
toggleShowSourceContent,
} from "~/atoms/source-content"
import { whoami } from "~/atoms/user"
import { mountLottie } from "~/components/ui/lottie-container"
import {
Expand All @@ -32,6 +36,8 @@ import type { FlatEntryModel } from "~/store/entry"
import { entryActions } from "~/store/entry"
import { useFeedById } from "~/store/feed"

import { navigateEntry } from "./useNavigateEntry"

const absoluteStarAnimationUri = new URL(StarAnimationUri, import.meta.url).href

export const useEntryReadabilityToggle = ({ id, url }: { id: string; url: string }) =>
Expand Down Expand Up @@ -172,7 +178,6 @@ export const useEntryActions = ({
active?: boolean
disabled?: boolean
onClick: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void
onContextMenu?: (e: React.MouseEvent<HTMLElement, MouseEvent>) => void
}[] = [
{
name: t("entry_actions.save_media_to_eagle"),
Expand Down Expand Up @@ -344,14 +349,27 @@ export const useEntryActions = ({
name: t("entry_actions.open_in_browser"),
shortcut: shortcuts.entry.openInBrowser.key,
className: "i-mgc-world-2-cute-re",
hide: !populatedEntry.entries.url,
active: getShowSourceContent(),
hide: type === "toolbar" || !populatedEntry.entries.url,
onClick: () => {
if (!populatedEntry.entries.url) return
window.open(populatedEntry.entries.url, "_blank")
},
onContextMenu: () => {
toggleShowSourceContent()
},
{
key: "openSourceContent",
// TODO update i18n
name: "Open source content",
// shortcut: shortcuts.entry.openInBrowser.key,
className: "i-mgc-world-2-cute-re",
hide: !populatedEntry.entries.url,
active: getShowSourceContent(),
onClick: () => {
if (type === "toolbar") {
toggleShowSourceContent()
return
}
navigateEntry({ entryId: populatedEntry.entries.id })
setShowSourceContent(true)
},
},
{
Expand Down
1 change: 0 additions & 1 deletion apps/renderer/src/modules/entry-content/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ function EntryHeaderImpl({
active={item.active}
shortcut={item.shortcut}
onClick={item.onClick}
onContextMenu={item.onContextMenu}
tooltip={item.name}
key={item.name}
/>
Expand Down

0 comments on commit 55c27ba

Please sign in to comment.