support for marking entries older than a threshold

This commit is contained in:
Athou
2022-08-15 20:47:46 +02:00
parent 11f5b22cb4
commit a8db632c4a
6 changed files with 125 additions and 74 deletions

View File

@@ -2,7 +2,8 @@ import { createAsyncThunk, createSlice, PayloadAction } from "@reduxjs/toolkit"
import { client } from "app/client"
import { Category, CollapseRequest } from "app/types"
import { visitCategoryTree } from "app/utils"
import { markAllEntries, markEntry } from "./entries"
// eslint-disable-next-line import/no-cycle
import { markEntry } from "./entries"
import { redirectTo } from "./redirect"
interface TreeState {
@@ -47,26 +48,6 @@ export const treeSlice = createSlice({
})
)
})
builder.addCase(markAllEntries.pending, (state, action) => {
if (!state.rootCategory) return
const { sourceType } = action.meta.arg
const sourceId = action.meta.arg.req.id
visitCategoryTree(state.rootCategory, c => {
if (sourceType === "category" && c.id === sourceId) {
visitCategoryTree(c, c2 =>
c2.feeds.forEach(f => {
f.unread = 0
})
)
} else if (sourceType === "feed") {
c.feeds
.filter(f => f.id === +sourceId)
.forEach(f => {
f.unread = 0
})
}
})
})
builder.addCase(redirectTo, state => {
state.mobileMenuOpen = false
})