feat: mark read for cateogry in ctx menu

Signed-off-by: Innei <i@innei.in>
This commit is contained in:
Innei 2024-08-21 16:34:51 +08:00
parent e5b0583d38
commit da79f1c278
No known key found for this signature in database
GPG Key ID: 0F62D33977F021F7
7 changed files with 30 additions and 20 deletions

View File

@ -1,5 +1,5 @@
const OpenInBrowser = (_t?: any) =>
window.electron ? "Open in Browser" : "Open in New Tab"
window.electron ? "Open in browser" : "Open in new tab"
export const COPY_MAP = {
OpenInBrowser,

View File

@ -189,7 +189,7 @@ export const useEntryActions = ({
},
{
key: "copyLink",
name: "Copy Link",
name: "Copy link",
className: "i-mgc-link-cute-re",
hide: !populatedEntry.entries.url,
shortcut: shortcuts.entry.copyLink.key,
@ -223,7 +223,8 @@ export const useEntryActions = ({
"",
),
key: "readability",
hide: type === "entryList" ||
hide:
type === "entryList" ||
views[view].wideMode ||
!populatedEntry.entries.url ||
!window.electron,
@ -231,7 +232,7 @@ export const useEntryActions = ({
onClick: readabilityToggle,
},
{
name: "Save Media to Eagle",
name: "Save media to Eagle",
icon: <SimpleIconsEagle />,
key: "saveToEagle",
hide:
@ -284,7 +285,7 @@ export const useEntryActions = ({
},
{
key: "read",
name: `Mark as Read`,
name: `Mark as read`,
shortcut: shortcuts.entry.toggleRead.key,
className: "i-mgc-round-cute-fi",
hide: !!(!!populatedEntry.read || populatedEntry.collections),
@ -294,7 +295,7 @@ export const useEntryActions = ({
},
{
key: "unread",
name: `Mark as Unread`,
name: `Mark as unread`,
shortcut: shortcuts.entry.toggleRead.key,
className: "i-mgc-round-cute-re",
hide: !!(!populatedEntry.read || populatedEntry.collections),
@ -317,6 +318,8 @@ export const useEntryActions = ({
read,
unread,
entryReadabilityStatus,
feed?.ownerUserId,
type,
])
return {

View File

@ -41,7 +41,7 @@ export const useFeedActions = ({
const items: NativeMenuItem[] = [
{
type: "text" as const,
label: isEntryList ? "Edit Feed" : "Edit",
label: isEntryList ? "Edit feed" : "Edit",
shortcut: "E",
click: () => {
present({
@ -54,13 +54,13 @@ export const useFeedActions = ({
},
{
type: "text" as const,
label: isEntryList ? "Unfollow Feed" : "Unfollow",
label: isEntryList ? "Unfollow feed" : "Unfollow",
shortcut: "Meta+Backspace",
click: () => deleteSubscription.mutate(subscription),
},
{
type: "text" as const,
label: "Navigate to Feed",
label: "Navigate to feed",
shortcut: "Meta+G",
disabled: !isEntryList || getRouteParams().feedId === feedId,
click: () => {
@ -73,7 +73,7 @@ export const useFeedActions = ({
},
{
type: "text",
label: "Mark All as Read",
label: "Mark all as read",
shortcut: "Meta+Shift+A",
disabled: isEntryList,
click: () => subscriptionActions.markReadByFeedIds([feedId]),
@ -105,7 +105,7 @@ export const useFeedActions = ({
{
type: "text" as const,
label: "Open Feed in Browser",
label: "Open feed in browser",
disabled: isEntryList,
shortcut: "O",
click: () =>
@ -113,7 +113,7 @@ export const useFeedActions = ({
},
{
type: "text" as const,
label: "Open Site in Browser",
label: "Open site in browser",
shortcut: "Meta+O",
disabled: isEntryList,
click: () => {
@ -129,14 +129,14 @@ export const useFeedActions = ({
},
{
type: "text" as const,
label: "Copy Feed URL",
label: "Copy feed URL",
disabled: isEntryList,
shortcut: "Meta+C",
click: () => navigator.clipboard.writeText(feed.url),
},
{
type: "text" as const,
label: "Copy Feed ID",
label: "Copy feed ID",
shortcut: "Meta+Shift+C",
disabled: isEntryList,
click: () => {

View File

@ -13,7 +13,7 @@ import {
useState,
} from "react"
import { useMarkAll } from "../hooks/useMarkAll"
import { useMarkAllByRoute } from "../hooks/useMarkAll"
import { MarkAllReadButton } from "./mark-all-button"
const useParseDate = (date: string) =>
@ -77,7 +77,7 @@ const UniversalDateItem = ({
const RelativeElement = <RelativeDay date={dateObj} />
const handleMarkAllAsRead = useMarkAll({
const handleMarkAllAsRead = useMarkAllByRoute({
startTime: startOfDay,
endTime: endOfDay,
})

View File

@ -13,7 +13,7 @@ import type { FC, ReactNode } from "react"
import { forwardRef, useState } from "react"
import type { MarkAllFilter } from "../hooks/useMarkAll"
import { useMarkAll } from "../hooks/useMarkAll"
import { useMarkAllByRoute } from "../hooks/useMarkAll"
interface MarkAllButtonProps {
filter?: MarkAllFilter
@ -28,7 +28,7 @@ export const MarkAllReadButton = forwardRef<
>(({ filter, className, which = "all", shortcut }, ref) => {
const [markPopoverOpen, setMarkPopoverOpen] = useState(false)
const handleMarkAllAsRead = useMarkAll(filter)
const handleMarkAllAsRead = useMarkAllByRoute(filter)
return (
<Popover open={markPopoverOpen} onOpenChange={setMarkPopoverOpen}>
@ -87,7 +87,7 @@ export const FlatMarkAllReadButton: FC<MarkAllButtonProps> = (props) => {
const [status, setStatus] = useState<"initial" | "confirm" | "done">(
"initial",
)
const handleMarkAll = useMarkAll(filter)
const handleMarkAll = useMarkAllByRoute(filter)
if (status === "done") return null
const animate = {

View File

@ -7,7 +7,7 @@ export interface MarkAllFilter {
startTime: number
endTime: number
}
export const useMarkAll = (filter?: MarkAllFilter) => {
export const useMarkAllByRoute = (filter?: MarkAllFilter) => {
const routerParams = useRouteParms()
const { feedId, view } = routerParams
const folderIds = useFolderFeedsByFeedId({

View File

@ -154,6 +154,13 @@ function FeedCategoryImpl({
},
})),
},
{
type: "text",
label: "Mark as read",
click: () => {
subscriptionActions.markReadByFeedIds(ids)
},
},
{ type: "separator" },
{
type: "text",