Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/bridges/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,13 @@ const settingsBridge = {
ipcRenderer.invoke("set-nedb-status", flag)
},

getMarkReadDays: (): number => {
return ipcRenderer.sendSync("get-mark-read-days");
},
setMarkReadDays: (days: number) => {
ipcRenderer.invoke("set-mark-read-days", days);
},

getAll: () => {
return ipcRenderer.sendSync("get-all-settings") as Object
},
Expand Down
27 changes: 22 additions & 5 deletions src/components/context-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,8 @@ function GroupContextMenu() {
function MarkReadContextMenu() {
const dispatch = useAppDispatch()

const currentMarkReadDays = window.settings.getMarkReadDays()

const menuItems: IContextualMenuItem[] = [
{
key: "section_1",
Expand All @@ -549,36 +551,51 @@ function MarkReadContextMenu() {
{
key: "all",
text: intl.get("allArticles"),
iconProps: { iconName: "ReceiptCheck" },
iconProps:
currentMarkReadDays === null
? { iconName: "CheckMark" }
: undefined,
onClick: () => {
dispatch(markAllRead())
window.settings.setMarkReadDays(null)
},
},
{
key: "1d",
text: intl.get("app.daysAgo", { days: 1 }),
iconProps:
currentMarkReadDays === 1
? { iconName: "CheckMark" }
: undefined,
onClick: () => {
let date = new Date()
date.setTime(date.getTime() - 86400000)
dispatch(markAllRead(null, date))
window.settings.setMarkReadDays(1)
},
},
{
key: "3d",
text: intl.get("app.daysAgo", { days: 3 }),
iconProps:
currentMarkReadDays === 3
? { iconName: "CheckMark" }
: undefined,
onClick: () => {
let date = new Date()
date.setTime(date.getTime() - 3 * 86400000)
dispatch(markAllRead(null, date))
window.settings.setMarkReadDays(3)
},
},
{
key: "7d",
text: intl.get("app.daysAgo", { days: 7 }),
iconProps:
currentMarkReadDays === 7
? { iconName: "CheckMark" }
: undefined,
onClick: () => {
let date = new Date()
date.setTime(date.getTime() - 7 * 86400000)
dispatch(markAllRead(null, date))
window.settings.setMarkReadDays(7)
},
},
],
Expand Down
29 changes: 21 additions & 8 deletions src/components/nav.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from "react"
import intl from "react-intl-universal"
import { Icon } from "@fluentui/react/lib/Icon"
import { AppState } from "../scripts/models/app"
import { AppState, ContextMenuType } from "../scripts/models/app"
import { ProgressIndicator, IObjectWithKey } from "@fluentui/react"
import { getWindowBreakpoint } from "../scripts/utils"
import { WindowStateListenerType } from "../schema-types"
Expand All @@ -11,7 +11,8 @@ type NavProps = {
itemShown: boolean
menu: () => void
search: () => void
markAllRead: () => void
markAllMenu: () => void
markAllRead: (sids?, date?) => void
fetch: () => void
logs: () => void
views: () => void
Expand Down Expand Up @@ -70,7 +71,7 @@ class Nav extends React.Component<NavProps, NavState> {
this.fetch()
break
case "F6":
this.props.markAllRead()
this.props.markAllMenu()
break
case "F7":
if (!this.props.itemShown) this.props.logs()
Expand Down Expand Up @@ -163,14 +164,26 @@ class Nav extends React.Component<NavProps, NavState> {
<a
className="btn"
id="mark-all-toggle"
onClick={this.props.markAllRead}
title={intl.get("nav.markAllRead")}
onMouseDown={e => {
if (
this.props.state.contextMenu.event ===
"#mark-all-toggle"
)
if (this.props.state.contextMenu.event === "#mark-all-toggle")
e.stopPropagation()
}}
onClick={() => {
const lastMarkReadDays = window.settings.getMarkReadDays();
if (lastMarkReadDays) {
let date = new Date();
date.setTime(date.getTime() - lastMarkReadDays * 86400000);
this.props.markAllRead(null, date);
} else {
this.props.markAllRead();
}
if (this.props.state.contextMenu.type === ContextMenuType.MarkRead) {
this.props.markAllMenu() // Close the menu on left-click if open.
}
}}
onContextMenu={() => {
this.props.markAllMenu()
}}>
<Icon iconName="InboxCheck" />
</a>
Expand Down
3 changes: 2 additions & 1 deletion src/containers/nav-container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ const mapDispatchToProps = dispatch => ({
views: () => dispatch(openViewMenu()),
settings: () => dispatch(toggleSettings()),
search: () => dispatch(toggleSearch()),
markAllRead: () => dispatch(openMarkAllMenu()),
markAllMenu: () => dispatch(openMarkAllMenu()),
markAllRead: (sids?, date?) => dispatch(markAllRead(sids, date)),
})

const NavContainer = connect(mapStateToProps, mapDispatchToProps)(Nav)
Expand Down
8 changes: 8 additions & 0 deletions src/main/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,11 @@ ipcMain.on("get-nedb-status", event => {
ipcMain.handle("set-nedb-status", (_, flag: boolean) => {
store.set(NEDB_STATUS_STORE_KEY, flag)
})

const MARK_READ_DAYS_STORE_KEY = "markReadDays";
ipcMain.on("get-mark-read-days", (event) => {
event.returnValue = store.get(MARK_READ_DAYS_STORE_KEY, null);
});
ipcMain.handle("set-mark-read-days", (_, days: number | null) => {
store.set(MARK_READ_DAYS_STORE_KEY, days);
});
1 change: 1 addition & 0 deletions src/schema-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,5 @@ export type SchemaTypes = {
filterType: number
listViewConfigs: ViewConfigs
useNeDB: boolean
markReadDays: number
}