mark all as read confirmation now also applies to the "shift+a" keyboard shortcut (#1744)

This commit is contained in:
Athou
2025-04-09 20:12:29 +02:00
parent dfab678070
commit 40c9b42b24
7 changed files with 121 additions and 116 deletions

View File

@@ -1,7 +1,7 @@
import { createAppAsyncThunk } from "app/async-thunk"
import { client } from "app/client"
import { Constants } from "app/constants"
import { type EntrySource, type EntrySourceType, entriesSlice, setSearch } from "app/entries/slice"
import { type EntrySource, type EntrySourceType, entriesSlice, setMarkAllAsReadConfirmationDialogOpen, setSearch } from "app/entries/slice"
import type { RootState } from "app/store"
import { reloadTree } from "app/tree/thunks"
import type { Entry, MarkRequest, TagRequest } from "app/types"
@@ -123,6 +123,32 @@ export const markAllEntries = createAppAsyncThunk(
}
)
export const markAllAsReadWithConfirmationIfRequired = createAppAsyncThunk(
"entries/entry/markAllAsReadWithConfirmationIfRequired",
async (_, thunkApi) => {
const state = thunkApi.getState()
const source = state.entries.source
const entriesTimestamp = state.entries.timestamp ?? Date.now()
const markAllAsReadConfirmation = state.user.settings?.markAllAsReadConfirmation
if (markAllAsReadConfirmation) {
thunkApi.dispatch(setMarkAllAsReadConfirmationDialogOpen(true))
} else {
thunkApi.dispatch(
markAllEntries({
sourceType: source.type,
req: {
id: source.id,
read: true,
olderThan: Date.now(),
insertedBefore: entriesTimestamp,
},
})
)
}
}
)
export const starEntry = createAppAsyncThunk(
"entries/entry/star",
(arg: { entry: Entry; starred: boolean }) => {