Skip to content

Commit

Permalink
Temporarily delete non-saved old items on refresh
Browse files Browse the repository at this point in the history
Temporary workaround for: #29, #52
  • Loading branch information
brunolemos committed Dec 21, 2018
1 parent aea9d7f commit 497ec5b
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions packages/components/src/redux/reducers/subscriptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { REHYDRATE } from 'redux-persist'
import {
ActivityColumnSubscription,
ColumnSubscription,
constants,
EnhancedGitHubEvent,
EnhancedGitHubNotification,
NotificationColumnSubscription,
Expand Down Expand Up @@ -57,17 +58,24 @@ export const subscriptionsReducer: Reducer<State> = (
if (subscription.data.items.length) {
const sevenDays = 1000 * 60 * 60 * 24 * 7

subscription.data.items = (subscription.data.items as any[]).filter(
item => {
let count = 0
subscription.data.items = (subscription.data.items as any[])
.filter(item => {
if (!item) return false
if (!item.updated_at) return true
if (item.saved) return true

return (
new Date(item.updated_at).valueOf() >= Date.now() - sevenDays
)
},
)
})
.filter(item => {
count = count + 1

if (item.saved) return true

return count <= constants.DEFAULT_PAGINATION_PER_PAGE
})
}
})
})
Expand Down

0 comments on commit 497ec5b

Please sign in to comment.