+
{icon}
- {this.props.type}
+ {type}
);
}
diff --git a/app/assets/javascripts/components/features/ui/containers/status_list_container.jsx b/app/assets/javascripts/components/features/ui/containers/status_list_container.jsx
index 114a7b2c..c185d7eb 100644
--- a/app/assets/javascripts/components/features/ui/containers/status_list_container.jsx
+++ b/app/assets/javascripts/components/features/ui/containers/status_list_container.jsx
@@ -5,7 +5,7 @@ import Immutable from 'immutable';
import { createSelector } from 'reselect';
import { debounce } from 'react-decoration';
-const getStatusIds = createSelector([
+const makeGetStatusIds = () => createSelector([
(state, { type }) => state.getIn(['settings', type], Immutable.Map()),
(state, { type }) => state.getIn(['timelines', type, 'items'], Immutable.List()),
(state) => state.get('statuses'),
@@ -34,10 +34,17 @@ const getStatusIds = createSelector([
return showStatus;
}));
-const mapStateToProps = (state, props) => ({
- statusIds: getStatusIds(state, props),
- isLoading: state.getIn(['timelines', props.type, 'isLoading'], true)
-});
+const makeMapStateToProps = () => {
+ const getStatusIds = makeGetStatusIds();
+
+ const mapStateToProps = (state, props) => ({
+ statusIds: getStatusIds(state, props),
+ isLoading: state.getIn(['timelines', props.type, 'isLoading'], true),
+ isUnread: state.getIn(['timelines', props.type, 'unread']) > 0
+ });
+
+ return mapStateToProps;
+};
const mapDispatchToProps = (dispatch, { type, id }) => ({
@@ -59,4 +66,4 @@ const mapDispatchToProps = (dispatch, { type, id }) => ({
});
-export default connect(mapStateToProps, mapDispatchToProps)(StatusList);
+export default connect(makeMapStateToProps, mapDispatchToProps)(StatusList);
diff --git a/app/assets/javascripts/components/reducers/notifications.jsx b/app/assets/javascripts/components/reducers/notifications.jsx
index 968eae9f..1406a388 100644
--- a/app/assets/javascripts/components/reducers/notifications.jsx
+++ b/app/assets/javascripts/components/reducers/notifications.jsx
@@ -6,7 +6,8 @@ import {
NOTIFICATIONS_EXPAND_REQUEST,
NOTIFICATIONS_REFRESH_FAIL,
NOTIFICATIONS_EXPAND_FAIL,
- NOTIFICATIONS_CLEAR
+ NOTIFICATIONS_CLEAR,
+ NOTIFICATIONS_SCROLL_TOP
} from '../actions/notifications';
import { ACCOUNT_BLOCK_SUCCESS } from '../actions/accounts';
import Immutable from 'immutable';
@@ -14,6 +15,8 @@ import Immutable from 'immutable';
const initialState = Immutable.Map({
items: Immutable.List(),
next: null,
+ top: true,
+ unread: 0,
loaded: false,
isLoading: true
});
@@ -26,6 +29,10 @@ const notificationToMap = notification => Immutable.Map({
});
const normalizeNotification = (state, notification) => {
+ if (!state.get('top')) {
+ state = state.update('unread', unread => unread + 1);
+ }
+
return state.update('items', list => list.unshift(notificationToMap(notification)));
};
@@ -64,6 +71,14 @@ const filterNotifications = (state, relationship) => {
return state.update('items', list => list.filterNot(item => item.get('account') === relationship.id));
};
+const updateTop = (state, top) => {
+ if (top) {
+ state = state.set('unread', 0);
+ }
+
+ return state.set('top', top);
+};
+
export default function notifications(state = initialState, action) {
switch(action.type) {
case NOTIFICATIONS_REFRESH_REQUEST:
@@ -71,6 +86,8 @@ export default function notifications(state = initialState, action) {
case NOTIFICATIONS_REFRESH_FAIL:
case NOTIFICATIONS_EXPAND_FAIL:
return state.set('isLoading', true);
+ case NOTIFICATIONS_SCROLL_TOP:
+ return updateTop(state, action.top);
case NOTIFICATIONS_UPDATE:
return normalizeNotification(state, action.notification);
case NOTIFICATIONS_REFRESH_SUCCESS:
diff --git a/app/assets/javascripts/components/reducers/timelines.jsx b/app/assets/javascripts/components/reducers/timelines.jsx
index 2dbced7a..ffb49be7 100644
--- a/app/assets/javascripts/components/reducers/timelines.jsx
+++ b/app/assets/javascripts/components/reducers/timelines.jsx
@@ -36,6 +36,7 @@ const initialState = Immutable.Map({
isLoading: false,
loaded: false,
top: true,
+ unread: 0,
items: Immutable.List()
}),
@@ -45,6 +46,7 @@ const initialState = Immutable.Map({
isLoading: false,
loaded: false,
top: true,
+ unread: 0,
items: Immutable.List()
}),
@@ -55,6 +57,7 @@ const initialState = Immutable.Map({
isLoading: false,
loaded: false,
top: true,
+ unread: 0,
items: Immutable.List()
}),
@@ -65,6 +68,7 @@ const initialState = Immutable.Map({
id: null,
loaded: false,
top: true,
+ unread: 0,
items: Immutable.List()
}),
@@ -155,6 +159,10 @@ const updateTimeline = (state, timeline, status, references) => {
state = normalizeStatus(state, status);
+ if (!top) {
+ state = state.updateIn([timeline, 'unread'], unread => unread + 1);
+ }
+
state = state.updateIn([timeline, 'items'], Immutable.List(), list => {
if (top && list.size > 40) {
list = list.take(20);
@@ -249,6 +257,14 @@ const resetTimeline = (state, timeline, id) => {
return state;
};
+const updateTop = (state, timeline, top) => {
+ if (top) {
+ state = state.setIn([timeline, 'unread'], 0);
+ }
+
+ return state.setIn([timeline, 'top'], top);
+};
+
export default function timelines(state = initialState, action) {
switch(action.type) {
case TIMELINE_REFRESH_REQUEST:
@@ -280,7 +296,7 @@ export default function timelines(state = initialState, action) {
case ACCOUNT_BLOCK_SUCCESS:
return filterTimelines(state, action.relationship, action.statuses);
case TIMELINE_SCROLL_TOP:
- return state.setIn([action.timeline, 'top'], action.top);
+ return updateTop(state, action.timeline, action.top);
default:
return state;
}
diff --git a/app/assets/stylesheets/components.scss b/app/assets/stylesheets/components.scss
index bc56891f..4b6bfca4 100644
--- a/app/assets/stylesheets/components.scss
+++ b/app/assets/stylesheets/components.scss
@@ -1079,6 +1079,11 @@ button.active i.fa-retweet {
background: lighten($color1, 4%);
flex: 0 0 auto;
cursor: pointer;
+
+ &.active {
+ color: $color4;
+ text-shadow: 0 0 10px rgba($color4, 0.4);
+ }
}
.search {
@@ -1201,3 +1206,14 @@ button.active i.fa-retweet {
}
}
}
+
+.status-list__unread-indicator, .notifications__unread-indicator {
+ position: absolute;
+ top: 48px;
+ left: 0;
+ width: 100%;
+ pointer-events: none;
+ height: 30px;
+ z-index: 2;
+ background: linear-gradient(to bottom, rgba($color4, 0.3) 0%, rgba($color4, 0) 60%);
+}