Merge branch 'timeline-fixes' into 'develop'
Timeline fixes, fixes #85 #156 #409 Closes #409, #156, and #85 See merge request soapbox-pub/soapbox-fe!261
This commit is contained in:
commit
ff85ff7bd4
4 changed files with 28 additions and 23 deletions
|
@ -143,13 +143,13 @@ export function handleComposeSubmit(dispatch, getState, response, status) {
|
|||
let dequeueArgs = {};
|
||||
if (timelineId === 'community') dequeueArgs.onlyMedia = getSettings(getState()).getIn(['community', 'other', 'onlyMedia']);
|
||||
dispatch(dequeueTimeline(timelineId, null, dequeueArgs));
|
||||
dispatch(updateTimeline(timelineId, { ...response.data }));
|
||||
dispatch(updateTimeline(timelineId, response.data.id));
|
||||
}
|
||||
};
|
||||
|
||||
if (response.data.visibility !== 'direct') {
|
||||
insertIfOnline('home');
|
||||
} else if (response.data.in_reply_to_id === null && response.data.visibility === 'public') {
|
||||
} else if (response.data.visibility === 'public') {
|
||||
insertIfOnline('community');
|
||||
insertIfOnline('public');
|
||||
}
|
||||
|
|
|
@ -25,31 +25,31 @@ export function processTimelineUpdate(timeline, status, accept) {
|
|||
const columnSettings = getSettings(getState()).get(timeline, ImmutableMap());
|
||||
const shouldSkipQueue = shouldFilter(fromJS(status), columnSettings);
|
||||
|
||||
dispatch(importFetchedStatus(status));
|
||||
|
||||
if (shouldSkipQueue) {
|
||||
return dispatch(updateTimeline(timeline, status, accept));
|
||||
return dispatch(updateTimeline(timeline, status.id, accept));
|
||||
} else {
|
||||
return dispatch(updateTimelineQueue(timeline, status, accept));
|
||||
return dispatch(updateTimelineQueue(timeline, status.id, accept));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function updateTimeline(timeline, status, accept) {
|
||||
export function updateTimeline(timeline, statusId, accept) {
|
||||
return dispatch => {
|
||||
if (typeof accept === 'function' && !accept(status)) {
|
||||
return;
|
||||
}
|
||||
|
||||
dispatch(importFetchedStatus(status));
|
||||
|
||||
dispatch({
|
||||
type: TIMELINE_UPDATE,
|
||||
timeline,
|
||||
status,
|
||||
statusId,
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
export function updateTimelineQueue(timeline, status, accept) {
|
||||
export function updateTimelineQueue(timeline, statusId, accept) {
|
||||
return dispatch => {
|
||||
if (typeof accept === 'function' && !accept(status)) {
|
||||
return;
|
||||
|
@ -58,7 +58,7 @@ export function updateTimelineQueue(timeline, status, accept) {
|
|||
dispatch({
|
||||
type: TIMELINE_UPDATE_QUEUE,
|
||||
timeline,
|
||||
status,
|
||||
statusId,
|
||||
});
|
||||
};
|
||||
};
|
||||
|
@ -73,8 +73,8 @@ export function dequeueTimeline(timeline, expandFunc, optionalExpandArgs) {
|
|||
if (totalQueuedItemsCount === 0) {
|
||||
return;
|
||||
} else if (totalQueuedItemsCount > 0 && totalQueuedItemsCount <= MAX_QUEUED_ITEMS) {
|
||||
queuedItems.forEach(status => {
|
||||
dispatch(updateTimeline(timeline, status.toJS(), null));
|
||||
queuedItems.forEach(statusId => {
|
||||
dispatch(updateTimeline(timeline, statusId, null));
|
||||
});
|
||||
} else {
|
||||
if (typeof expandFunc === 'function') {
|
||||
|
|
|
@ -3,7 +3,8 @@ import {
|
|||
ACCOUNT_MUTE_SUCCESS,
|
||||
} from '../actions/accounts';
|
||||
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
|
||||
import { TIMELINE_DELETE, TIMELINE_UPDATE } from '../actions/timelines';
|
||||
import { TIMELINE_DELETE } from '../actions/timelines';
|
||||
import { STATUS_IMPORT, STATUSES_IMPORT } from 'soapbox/actions/importer';
|
||||
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
||||
|
||||
const initialState = ImmutableMap({
|
||||
|
@ -87,8 +88,12 @@ export default function replies(state = initialState, action) {
|
|||
return normalizeContext(state, action.id, action.ancestors, action.descendants);
|
||||
case TIMELINE_DELETE:
|
||||
return deleteFromContexts(state, [action.id]);
|
||||
case TIMELINE_UPDATE:
|
||||
case STATUS_IMPORT:
|
||||
return updateContext(state, action.status);
|
||||
case STATUSES_IMPORT:
|
||||
return state.withMutations(mutable =>
|
||||
action.statuses.forEach(status => updateContext(mutable, status)));
|
||||
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
|
|
@ -65,10 +65,10 @@ const expandNormalizedTimeline = (state, timeline, statuses, next, isPartial, is
|
|||
}));
|
||||
};
|
||||
|
||||
const updateTimeline = (state, timeline, status) => {
|
||||
const updateTimeline = (state, timeline, statusId) => {
|
||||
const top = state.getIn([timeline, 'top']);
|
||||
const ids = state.getIn([timeline, 'items'], ImmutableList());
|
||||
const includesId = ids.includes(status.get('id'));
|
||||
const includesId = ids.includes(statusId);
|
||||
const unread = state.getIn([timeline, 'unread'], 0);
|
||||
|
||||
if (includesId) {
|
||||
|
@ -80,17 +80,17 @@ const updateTimeline = (state, timeline, status) => {
|
|||
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||
if (!top) mMap.set('unread', unread + 1);
|
||||
if (top && ids.size > 40) newIds = newIds.take(20);
|
||||
mMap.set('items', newIds.unshift(status.get('id')));
|
||||
mMap.set('items', newIds.unshift(statusId));
|
||||
}));
|
||||
};
|
||||
|
||||
const updateTimelineQueue = (state, timeline, status) => {
|
||||
const updateTimelineQueue = (state, timeline, statusId) => {
|
||||
const queuedStatuses = state.getIn([timeline, 'queuedItems'], ImmutableList());
|
||||
const listedStatuses = state.getIn([timeline, 'items'], ImmutableList());
|
||||
const totalQueuedItemsCount = state.getIn([timeline, 'totalQueuedItemsCount'], 0);
|
||||
|
||||
let alreadyExists = queuedStatuses.find(existingQueuedStatus => existingQueuedStatus.get('id') === status.get('id'));
|
||||
if (!alreadyExists) alreadyExists = listedStatuses.find(existingListedStatusId => existingListedStatusId === status.get('id'));
|
||||
let alreadyExists = queuedStatuses.find(existingQueuedStatus => existingQueuedStatus.get('id') === statusId);
|
||||
if (!alreadyExists) alreadyExists = listedStatuses.find(existingListedStatusId => existingListedStatusId === statusId);
|
||||
|
||||
if (alreadyExists) {
|
||||
return state;
|
||||
|
@ -100,7 +100,7 @@ const updateTimelineQueue = (state, timeline, status) => {
|
|||
|
||||
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||
if (totalQueuedItemsCount <= MAX_QUEUED_ITEMS) {
|
||||
mMap.set('queuedItems', newQueuedStatuses.push(status));
|
||||
mMap.set('queuedItems', newQueuedStatuses.push(statusId));
|
||||
}
|
||||
mMap.set('totalQueuedItemsCount', totalQueuedItemsCount + 1);
|
||||
}));
|
||||
|
@ -165,9 +165,9 @@ export default function timelines(state = initialState, action) {
|
|||
case TIMELINE_EXPAND_SUCCESS:
|
||||
return expandNormalizedTimeline(state, action.timeline, fromJS(action.statuses), action.next, action.partial, action.isLoadingRecent);
|
||||
case TIMELINE_UPDATE:
|
||||
return updateTimeline(state, action.timeline, fromJS(action.status));
|
||||
return updateTimeline(state, action.timeline, action.statusId);
|
||||
case TIMELINE_UPDATE_QUEUE:
|
||||
return updateTimelineQueue(state, action.timeline, fromJS(action.status));
|
||||
return updateTimelineQueue(state, action.timeline, action.statusId);
|
||||
case TIMELINE_DEQUEUE:
|
||||
return state.update(action.timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||
mMap.set('queuedItems', ImmutableList());
|
||||
|
|
Loading…
Reference in a new issue