[Glitch] Fix “slow mode” issues
Port f109867578
to glitch-soc
Signed-off-by: Thibaut Girka <thib@sitedethib.com>
remotes/1727458204337373841/tmp_refs/heads/signup-info-prompt
parent
15a37a967c
commit
75673cf8e3
|
@ -153,7 +153,9 @@ export default class ScrollableList extends PureComponent {
|
||||||
const someItemInserted = React.Children.count(prevProps.children) > 0 &&
|
const someItemInserted = React.Children.count(prevProps.children) > 0 &&
|
||||||
React.Children.count(prevProps.children) < React.Children.count(this.props.children) &&
|
React.Children.count(prevProps.children) < React.Children.count(this.props.children) &&
|
||||||
this.getFirstChildKey(prevProps) !== this.getFirstChildKey(this.props);
|
this.getFirstChildKey(prevProps) !== this.getFirstChildKey(this.props);
|
||||||
if (someItemInserted && (this.node.scrollTop > 0 || this.mouseMovedRecently)) {
|
const pendingChanged = (prevProps.numPending > 0) !== (this.props.numPending > 0);
|
||||||
|
|
||||||
|
if (pendingChanged || someItemInserted && (this.node.scrollTop > 0 || this.mouseMovedRecently)) {
|
||||||
return this.node.scrollHeight - this.node.scrollTop;
|
return this.node.scrollHeight - this.node.scrollTop;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -228,6 +230,13 @@ export default class ScrollableList extends PureComponent {
|
||||||
handleLoadPending = e => {
|
handleLoadPending = e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
this.props.onLoadPending();
|
this.props.onLoadPending();
|
||||||
|
// Prevent the weird scroll-jumping behavior, as we explicitly don't want to
|
||||||
|
// scroll to top, and we know the scroll height is going to change
|
||||||
|
this.scrollToTopOnMouseIdle = false;
|
||||||
|
this.lastScrollWasSynthetic = false;
|
||||||
|
this.clearMouseIdleTimer();
|
||||||
|
this.mouseIdleTimer = setTimeout(this.handleMouseIdle, MOUSE_IDLE_DELAY);
|
||||||
|
this.mouseMovedRecently = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
|
|
@ -20,7 +20,7 @@ const mapStateToProps = (state, { onlyMedia, columnId }) => {
|
||||||
const index = columns.findIndex(c => c.get('uuid') === uuid);
|
const index = columns.findIndex(c => c.get('uuid') === uuid);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0,
|
hasUnread: state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'unread']) > 0 || state.getIn(['timelines', `community${onlyMedia ? ':media' : ''}`, 'pendingItems']).size > 0,
|
||||||
onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'community', 'other', 'onlyMedia']),
|
onlyMedia: (columnId && index >= 0) ? columns.get(index).getIn(['params', 'other', 'onlyMedia']) : state.getIn(['settings', 'community', 'other', 'onlyMedia']),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
@ -47,7 +47,7 @@ const mapStateToProps = state => ({
|
||||||
notifications: getNotifications(state),
|
notifications: getNotifications(state),
|
||||||
localSettings: state.get('local_settings'),
|
localSettings: state.get('local_settings'),
|
||||||
isLoading: state.getIn(['notifications', 'isLoading'], true),
|
isLoading: state.getIn(['notifications', 'isLoading'], true),
|
||||||
isUnread: state.getIn(['notifications', 'unread']) > 0,
|
isUnread: state.getIn(['notifications', 'unread']) > 0 || state.getIn(['notifications', 'pendingItems']).size > 0,
|
||||||
hasMore: state.getIn(['notifications', 'hasMore']),
|
hasMore: state.getIn(['notifications', 'hasMore']),
|
||||||
numPending: state.getIn(['notifications', 'pendingItems'], ImmutableList()).size,
|
numPending: state.getIn(['notifications', 'pendingItems'], ImmutableList()).size,
|
||||||
notifCleaningActive: state.getIn(['notifications', 'cleaningMode']),
|
notifCleaningActive: state.getIn(['notifications', 'cleaningMode']),
|
||||||
|
|
|
@ -51,7 +51,7 @@ const notificationToMap = (state, notification) => ImmutableMap({
|
||||||
|
|
||||||
const normalizeNotification = (state, notification, usePendingItems) => {
|
const normalizeNotification = (state, notification, usePendingItems) => {
|
||||||
if (usePendingItems) {
|
if (usePendingItems) {
|
||||||
return state.update('pendingItems', list => list.unshift(notificationToMap(state, notification)));
|
return state.update('pendingItems', list => list.unshift(notificationToMap(state, notification))).update('unread', unread => unread + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
const top = !shouldCountUnreadNotifications(state);
|
const top = !shouldCountUnreadNotifications(state);
|
||||||
|
@ -117,7 +117,7 @@ const filterNotifications = (state, accountIds) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearUnread = (state) => {
|
const clearUnread = (state) => {
|
||||||
state = state.set('unread', 0);
|
state = state.set('unread', state.get('pendingItems').size);
|
||||||
const lastNotification = state.get('items').find(item => item !== null);
|
const lastNotification = state.get('items').find(item => item !== null);
|
||||||
return state.set('lastReadId', lastNotification ? lastNotification.get('id') : '0');
|
return state.set('lastReadId', lastNotification ? lastNotification.get('id') : '0');
|
||||||
}
|
}
|
||||||
|
@ -140,6 +140,8 @@ const deleteByStatus = (state, statusId) => {
|
||||||
state = state.update('unread', unread => unread - deletedUnread.size);
|
state = state.update('unread', unread => unread - deletedUnread.size);
|
||||||
}
|
}
|
||||||
const helper = list => list.filterNot(item => item !== null && item.get('status') === statusId);
|
const helper = list => list.filterNot(item => item !== null && item.get('status') === statusId);
|
||||||
|
const deletedUnread = state.get('pendingItems').filter(item => item !== null && item.get('status') === statusId && compareId(item.get('id'), lastReadId) > 0);
|
||||||
|
state = state.update('unread', unread => unread - deletedUnread.size);
|
||||||
return state.update('items', helper).update('pendingItems', helper);
|
return state.update('items', helper).update('pendingItems', helper);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ const updateTimeline = (state, timeline, status, usePendingItems) => {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
return state.update(timeline, initialTimeline, map => map.update('pendingItems', list => list.unshift(status.get('id'))));
|
return state.update(timeline, initialTimeline, map => map.update('pendingItems', list => list.unshift(status.get('id'))).update('unread', unread => unread + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
const top = state.getIn([timeline, 'top']);
|
const top = state.getIn([timeline, 'top']);
|
||||||
|
@ -127,7 +127,7 @@ const filterTimeline = (timeline, state, relationship, statuses) => {
|
||||||
|
|
||||||
const updateTop = (state, timeline, top) => {
|
const updateTop = (state, timeline, top) => {
|
||||||
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||||
if (top) mMap.set('unread', 0);
|
if (top) mMap.set('unread', mMap.get('pendingItems').size);
|
||||||
mMap.set('top', top);
|
mMap.set('top', top);
|
||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue