mirror of
https://github.com/yang991178/fluent-reader.git
synced 2025-01-30 00:55:09 +01:00
dismiss read articles on refresh #94
This commit is contained in:
parent
7a286de5aa
commit
58e32f9985
@ -115,6 +115,7 @@ export type FeedState = {
|
||||
export const INIT_FEEDS = "INIT_FEEDS"
|
||||
export const INIT_FEED = "INIT_FEED"
|
||||
export const LOAD_MORE = "LOAD_MORE"
|
||||
export const DISMISS_ITEMS = "DISMISS_ITEMS"
|
||||
|
||||
interface initFeedsAction {
|
||||
type: typeof INIT_FEEDS
|
||||
@ -137,7 +138,34 @@ interface loadMoreAction {
|
||||
err?
|
||||
}
|
||||
|
||||
export type FeedActionTypes = initFeedAction | initFeedsAction | loadMoreAction
|
||||
interface dismissItemsAction{
|
||||
type: typeof DISMISS_ITEMS
|
||||
fid: string
|
||||
iids: Set<number>
|
||||
}
|
||||
|
||||
export type FeedActionTypes = initFeedAction | initFeedsAction | loadMoreAction
|
||||
| dismissItemsAction
|
||||
|
||||
export function dismissItems(): AppThunk {
|
||||
return (dispatch, getState) => {
|
||||
const state = getState()
|
||||
let fid = state.page.feedId
|
||||
let filter = state.feeds[fid].filter
|
||||
let iids = new Set<number>()
|
||||
for (let iid of state.feeds[fid].iids) {
|
||||
let item = state.items[iid]
|
||||
if (!FeedFilter.testItem(filter, item)) {
|
||||
iids.add(iid)
|
||||
}
|
||||
}
|
||||
dispatch({
|
||||
type: DISMISS_ITEMS,
|
||||
fid: fid,
|
||||
iids: iids
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function initFeedsRequest(): FeedActionTypes {
|
||||
return {
|
||||
@ -293,6 +321,14 @@ export function feedReducer(
|
||||
}
|
||||
default: return state
|
||||
}
|
||||
case DISMISS_ITEMS:
|
||||
let nextState = { ...state }
|
||||
let feed = state[action.fid]
|
||||
nextState[action.fid] = {
|
||||
...feed,
|
||||
iids: feed.iids.filter(iid => !action.iids.has(iid))
|
||||
}
|
||||
return nextState
|
||||
case INIT_FEED:
|
||||
switch (action.status) {
|
||||
case ActionStatus.Success: return {
|
||||
|
@ -3,7 +3,7 @@ import lf from "lovefield"
|
||||
import intl from "react-intl-universal"
|
||||
import { domParser, htmlDecode, ActionStatus, AppThunk, platformCtrl } from "../utils"
|
||||
import { RSSSource, updateSource, updateUnreadCounts } from "./source"
|
||||
import { FeedActionTypes, INIT_FEED, LOAD_MORE, FilterType, initFeeds } from "./feed"
|
||||
import { FeedActionTypes, INIT_FEED, LOAD_MORE, FilterType, initFeeds, dismissItems } from "./feed"
|
||||
import Parser from "@yang991178/rss-parser"
|
||||
import { pushNotification, setupAutoFetch, SettingsActionTypes, FREE_MEMORY } from "./app"
|
||||
import { getServiceHooks, syncWithService, ServiceActionTypes, SYNC_LOCAL_ITEMS } from "./service"
|
||||
@ -213,6 +213,8 @@ export function fetchItems(background = false, sids: number[] = null): AppThunk<
|
||||
if (inserted.length > 0) {
|
||||
window.utils.requestAttention()
|
||||
}
|
||||
} else {
|
||||
dispatch(dismissItems())
|
||||
}
|
||||
dispatch(setupAutoFetch())
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user