Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(wallet): ensure activity items get date header rows
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Jun 2, 2020
1 parent d637c0a commit be47b82
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions renderer/reducers/activity/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const returnTimestamp = activity => {
*/
export const addDate = entry => {
const timestamp = returnTimestamp(entry)
const d = new Date(Number(timestamp) * 1000)
const d = new Date(timestamp * 1000)
const date = d.getDate()
return { ...entry, date: `${months[d.getMonth()]} ${date}, ${d.getFullYear()}`, timestamp }
}
Expand All @@ -66,17 +66,13 @@ export const propMatches = function propMatches(prop) {
* @returns {any[]} Grouped items
*/
export function groupActivity(data) {
// according too https://stackoverflow.com/a/11252167/3509860
// this provides an accurate measurement including handling of DST
const daysBetween = (t1, t2) => Math.round((t2 - t1) / 86400)
return data
.sort((a, b) => b.timestamp - a.timestamp)
.reduce((acc, next) => {
const prev = acc[acc.length - 1]
// check if need insert a group title
if (prev) {
const days = daysBetween(next.timestamp, prev.timestamp)
if (days >= 1) {
if (prev.date !== next.date) {
acc.push({ title: next.date })
}
} else {
Expand Down

0 comments on commit be47b82

Please sign in to comment.