diff --git a/src/components/DateSort/index.js b/src/components/DateSort/index.js
new file mode 100644
index 0000000..76d97d4
--- /dev/null
+++ b/src/components/DateSort/index.js
@@ -0,0 +1,69 @@
+import PropTypes from 'prop-types';
+import React from 'react';
+import map from '../../services/map';
+import classNames from 'classnames';
+import { connect } from 'react-redux';
+import { bindActionCreators } from 'redux';
+import * as actions from '../../actions/index';
+import * as dateSortTypes from '../../constants/dateSortTypes';
+import { DATE_SORT_NAMES } from '../../constants/sort';
+import ButtonActive from '../../components/ButtonActive';
+import ButtonInline from '../../components/ButtonInline';
+
+function hasActiveSort(activeDateSort) {
+ return activeDateSort !== dateSortTypes.NONE;
+}
+
+function DateSort({
+ activeDateSort,
+ onSort,
+ }) {
+ const sortIconClass = classNames(
+ 'stream-interaction-icon',
+ {
+ 'stream-interaction-icon-active': hasActiveSort(activeDateSort)
+ }
+ );
+
+ return (
+
+
+ onSort(dateSortTypes.NONE)}>
+
+
+
+
+ {
+ map((value, key) => {
+ return (
+
+ onSort(value)} isActive={value === activeDateSort}>
+ {DATE_SORT_NAMES[value]}
+
+
+ );
+ }, dateSortTypes)
+ }
+
+
+ );
+}
+
+function mapStateToProps(state) {
+ return {
+ activeDateSort: state.sort.dateSortType
+ };
+}
+
+function mapDispatchToProps(dispatch) {
+ return {
+ onSort: (dateSortType) => bindActionCreators(actions.dateSortStream, dispatch)(dateSortType)
+ };
+}
+
+DateSort.propTypes = {
+ activeDateSort: PropTypes.string,
+ onSort: PropTypes.func
+};
+
+export default connect(mapStateToProps, mapDispatchToProps)(DateSort);
diff --git a/src/components/StreamActivities/index.js b/src/components/StreamActivities/index.js
index 49a8065..b818b62 100644
--- a/src/components/StreamActivities/index.js
+++ b/src/components/StreamActivities/index.js
@@ -11,7 +11,7 @@ import LoadingSpinner from '../../components/LoadingSpinner';
import StreamInteractions from '../../components/StreamInteractions';
import { DURATION_FILTER_FUNCTIONS } from '../../constants/durationFilter';
import { getTracknameFilter } from '../../constants/nameFilter';
-import { SORT_FUNCTIONS } from '../../constants/sort';
+import { SORT_FUNCTIONS, DATE_SORT_FUNCTIONS } from '../../constants/sort';
import { getArtistFilter } from '../../constants/artistFilter';
function StreamActivities({
@@ -21,6 +21,7 @@ function StreamActivities({
trackEntities,
activeFilter,
activeSort,
+ activeDateSort,
onFetchActivities,
}) {
return (
@@ -32,6 +33,7 @@ function StreamActivities({
ids={activities}
activeFilter={activeFilter}
activeSort={activeSort}
+ activeDateSort={activeDateSort}
scrollFunction={() => onFetchActivities(null, nextHref)}
/>
@@ -55,6 +57,7 @@ function mapStateToProps(state) {
nextHref: state.paginate[paginateLinkTypes.ACTIVITIES],
activeFilter: getAndCombined(filters),
activeSort: SORT_FUNCTIONS[state.sort.sortType],
+ activeDateSort: DATE_SORT_FUNCTIONS[state.sort.dateSortType],
};
}
@@ -71,6 +74,7 @@ StreamActivities.propTypes = {
nextHref: PropTypes.string,
activeFilter: PropTypes.func,
activeSort: PropTypes.func,
+ activeDateSort: PropTypes.func,
onFetchActivities: PropTypes.func,
};
diff --git a/src/components/StreamInteractions/index.js b/src/components/StreamInteractions/index.js
index cba4acb..ac78941 100644
--- a/src/components/StreamInteractions/index.js
+++ b/src/components/StreamInteractions/index.js
@@ -2,6 +2,7 @@ import React from 'react';
import FilterDuration from '../../components/FilterDuration';
import FilterName from '../../components/FilterName';
import Sort from '../../components/Sort';
+import DateSort from '../../components/DateSort';
function StreamInteractions() {
return (
@@ -12,6 +13,9 @@ function StreamInteractions() {
+
+
+
diff --git a/src/components/Track/index.js b/src/components/Track/index.js
index bbefd6d..6508126 100644
--- a/src/components/Track/index.js
+++ b/src/components/Track/index.js
@@ -17,6 +17,7 @@ function mapStateToProps(state, props) {
isPlaying: state.player.isPlaying,
activeTrackId: state.player.activeTrackId,
activeSortType: state.sort.sortType,
+ activeDateSortType: state.sort.dateSortType,
activeDurationFilterType: state.filter.durationFilterType,
};
}
diff --git a/src/components/Track/stream.js b/src/components/Track/stream.js
index 1dc1e97..ac4efb7 100644
--- a/src/components/Track/stream.js
+++ b/src/components/Track/stream.js
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import * as sortTypes from '../../constants/sortTypes';
+import * as dateSortTypes from '../../constants/dateSortTypes';
import * as filterTypes from '../../constants/filterTypes';
import WaveformSc from '../../components/WaveformSc';
import TrackActions from '../../components/TrackActions';
@@ -26,6 +27,18 @@ function Duration({ duration, isActive }) {
);
}
+function Created({ created_at, isActive }) {
+ const durationClass = classNames({
+ 'active-duration-filter': isActive
+ });
+
+ return (
+
+ {fromNow(created_at)}
+
+ );
+}
+
function TrackStream({
activity,
activeTrackId,
@@ -34,6 +47,7 @@ function TrackStream({
typeReposts,
typeTracks,
activeSortType,
+ activeDateSortType,
activeDurationFilterType,
onActivateTrack,
}) {
@@ -50,7 +64,6 @@ function TrackStream({
permalink_url,
created_at
} = activity;
-
const userEntity = userEntities[user];
const { avatar_url, username } = userEntity;
@@ -123,7 +136,12 @@ function TrackStream({
/ {fromNow(created_at)}