diff --git a/src/components/ListeningHistoryModal.tsx b/src/components/ListeningHistoryModal.tsx index 423fa73..db30302 100644 --- a/src/components/ListeningHistoryModal.tsx +++ b/src/components/ListeningHistoryModal.tsx @@ -38,6 +38,7 @@ class ListeningHistoryModal extends React.Component <{setModalIsOpen: (value: bo } } + async componentDidMount(): Promise { let newState = await getRecentlyPlayedTracksMetrics(); this.setState({ @@ -55,6 +56,33 @@ class ListeningHistoryModal extends React.Component <{setModalIsOpen: (value: bo }}> {"Listening History"} +
+ {"Week of "} + + {function() { + let getDateRange = () => { + let weekStartDate = new Date(); // Date of the first day of the week + let day = weekStartDate.getDay() || 7; // Return 7 if day is Sunday + + // If today is not a Monday, then rewind the + // date back to Monday + if (day != 1) { + weekStartDate.setHours(-24 * (day - 1)); + } + + // First Monday of the week and the current date + return weekStartDate; + } + + let weekStartDate = getDateRange(); + + return `${weekStartDate.getMonth() + 1}/${weekStartDate.getDate()}`; + }()} + +
this.props.setModalIsOpen(false)}/> diff --git a/src/services/recentlyPlayedService.tsx b/src/services/recentlyPlayedService.tsx index 20aae0b..10d7a99 100644 --- a/src/services/recentlyPlayedService.tsx +++ b/src/services/recentlyPlayedService.tsx @@ -10,8 +10,11 @@ async function getRecentlyPlayedTracksMetrics() : Promise