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 = {};
|
let dequeueArgs = {};
|
||||||
if (timelineId === 'community') dequeueArgs.onlyMedia = getSettings(getState()).getIn(['community', 'other', 'onlyMedia']);
|
if (timelineId === 'community') dequeueArgs.onlyMedia = getSettings(getState()).getIn(['community', 'other', 'onlyMedia']);
|
||||||
dispatch(dequeueTimeline(timelineId, null, dequeueArgs));
|
dispatch(dequeueTimeline(timelineId, null, dequeueArgs));
|
||||||
dispatch(updateTimeline(timelineId, { ...response.data }));
|
dispatch(updateTimeline(timelineId, response.data.id));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (response.data.visibility !== 'direct') {
|
if (response.data.visibility !== 'direct') {
|
||||||
insertIfOnline('home');
|
insertIfOnline('home');
|
||||||
} else if (response.data.in_reply_to_id === null && response.data.visibility === 'public') {
|
} else if (response.data.visibility === 'public') {
|
||||||
insertIfOnline('community');
|
insertIfOnline('community');
|
||||||
insertIfOnline('public');
|
insertIfOnline('public');
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,31 +25,31 @@ export function processTimelineUpdate(timeline, status, accept) {
|
||||||
const columnSettings = getSettings(getState()).get(timeline, ImmutableMap());
|
const columnSettings = getSettings(getState()).get(timeline, ImmutableMap());
|
||||||
const shouldSkipQueue = shouldFilter(fromJS(status), columnSettings);
|
const shouldSkipQueue = shouldFilter(fromJS(status), columnSettings);
|
||||||
|
|
||||||
|
dispatch(importFetchedStatus(status));
|
||||||
|
|
||||||
if (shouldSkipQueue) {
|
if (shouldSkipQueue) {
|
||||||
return dispatch(updateTimeline(timeline, status, accept));
|
return dispatch(updateTimeline(timeline, status.id, accept));
|
||||||
} else {
|
} 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 => {
|
return dispatch => {
|
||||||
if (typeof accept === 'function' && !accept(status)) {
|
if (typeof accept === 'function' && !accept(status)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch(importFetchedStatus(status));
|
|
||||||
|
|
||||||
dispatch({
|
dispatch({
|
||||||
type: TIMELINE_UPDATE,
|
type: TIMELINE_UPDATE,
|
||||||
timeline,
|
timeline,
|
||||||
status,
|
statusId,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
export function updateTimelineQueue(timeline, status, accept) {
|
export function updateTimelineQueue(timeline, statusId, accept) {
|
||||||
return dispatch => {
|
return dispatch => {
|
||||||
if (typeof accept === 'function' && !accept(status)) {
|
if (typeof accept === 'function' && !accept(status)) {
|
||||||
return;
|
return;
|
||||||
|
@ -58,7 +58,7 @@ export function updateTimelineQueue(timeline, status, accept) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: TIMELINE_UPDATE_QUEUE,
|
type: TIMELINE_UPDATE_QUEUE,
|
||||||
timeline,
|
timeline,
|
||||||
status,
|
statusId,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -73,8 +73,8 @@ export function dequeueTimeline(timeline, expandFunc, optionalExpandArgs) {
|
||||||
if (totalQueuedItemsCount === 0) {
|
if (totalQueuedItemsCount === 0) {
|
||||||
return;
|
return;
|
||||||
} else if (totalQueuedItemsCount > 0 && totalQueuedItemsCount <= MAX_QUEUED_ITEMS) {
|
} else if (totalQueuedItemsCount > 0 && totalQueuedItemsCount <= MAX_QUEUED_ITEMS) {
|
||||||
queuedItems.forEach(status => {
|
queuedItems.forEach(statusId => {
|
||||||
dispatch(updateTimeline(timeline, status.toJS(), null));
|
dispatch(updateTimeline(timeline, statusId, null));
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (typeof expandFunc === 'function') {
|
if (typeof expandFunc === 'function') {
|
||||||
|
|
|
@ -3,7 +3,8 @@ import {
|
||||||
ACCOUNT_MUTE_SUCCESS,
|
ACCOUNT_MUTE_SUCCESS,
|
||||||
} from '../actions/accounts';
|
} from '../actions/accounts';
|
||||||
import { CONTEXT_FETCH_SUCCESS } from '../actions/statuses';
|
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';
|
import { Map as ImmutableMap, OrderedSet as ImmutableOrderedSet } from 'immutable';
|
||||||
|
|
||||||
const initialState = ImmutableMap({
|
const initialState = ImmutableMap({
|
||||||
|
@ -87,8 +88,12 @@ export default function replies(state = initialState, action) {
|
||||||
return normalizeContext(state, action.id, action.ancestors, action.descendants);
|
return normalizeContext(state, action.id, action.ancestors, action.descendants);
|
||||||
case TIMELINE_DELETE:
|
case TIMELINE_DELETE:
|
||||||
return deleteFromContexts(state, [action.id]);
|
return deleteFromContexts(state, [action.id]);
|
||||||
case TIMELINE_UPDATE:
|
case STATUS_IMPORT:
|
||||||
return updateContext(state, action.status);
|
return updateContext(state, action.status);
|
||||||
|
case STATUSES_IMPORT:
|
||||||
|
return state.withMutations(mutable =>
|
||||||
|
action.statuses.forEach(status => updateContext(mutable, status)));
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return state;
|
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 top = state.getIn([timeline, 'top']);
|
||||||
const ids = state.getIn([timeline, 'items'], ImmutableList());
|
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);
|
const unread = state.getIn([timeline, 'unread'], 0);
|
||||||
|
|
||||||
if (includesId) {
|
if (includesId) {
|
||||||
|
@ -80,17 +80,17 @@ const updateTimeline = (state, timeline, status) => {
|
||||||
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||||
if (!top) mMap.set('unread', unread + 1);
|
if (!top) mMap.set('unread', unread + 1);
|
||||||
if (top && ids.size > 40) newIds = newIds.take(20);
|
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 queuedStatuses = state.getIn([timeline, 'queuedItems'], ImmutableList());
|
||||||
const listedStatuses = state.getIn([timeline, 'items'], ImmutableList());
|
const listedStatuses = state.getIn([timeline, 'items'], ImmutableList());
|
||||||
const totalQueuedItemsCount = state.getIn([timeline, 'totalQueuedItemsCount'], 0);
|
const totalQueuedItemsCount = state.getIn([timeline, 'totalQueuedItemsCount'], 0);
|
||||||
|
|
||||||
let alreadyExists = queuedStatuses.find(existingQueuedStatus => existingQueuedStatus.get('id') === status.get('id'));
|
let alreadyExists = queuedStatuses.find(existingQueuedStatus => existingQueuedStatus.get('id') === statusId);
|
||||||
if (!alreadyExists) alreadyExists = listedStatuses.find(existingListedStatusId => existingListedStatusId === status.get('id'));
|
if (!alreadyExists) alreadyExists = listedStatuses.find(existingListedStatusId => existingListedStatusId === statusId);
|
||||||
|
|
||||||
if (alreadyExists) {
|
if (alreadyExists) {
|
||||||
return state;
|
return state;
|
||||||
|
@ -100,7 +100,7 @@ const updateTimelineQueue = (state, timeline, status) => {
|
||||||
|
|
||||||
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
return state.update(timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||||
if (totalQueuedItemsCount <= MAX_QUEUED_ITEMS) {
|
if (totalQueuedItemsCount <= MAX_QUEUED_ITEMS) {
|
||||||
mMap.set('queuedItems', newQueuedStatuses.push(status));
|
mMap.set('queuedItems', newQueuedStatuses.push(statusId));
|
||||||
}
|
}
|
||||||
mMap.set('totalQueuedItemsCount', totalQueuedItemsCount + 1);
|
mMap.set('totalQueuedItemsCount', totalQueuedItemsCount + 1);
|
||||||
}));
|
}));
|
||||||
|
@ -165,9 +165,9 @@ export default function timelines(state = initialState, action) {
|
||||||
case TIMELINE_EXPAND_SUCCESS:
|
case TIMELINE_EXPAND_SUCCESS:
|
||||||
return expandNormalizedTimeline(state, action.timeline, fromJS(action.statuses), action.next, action.partial, action.isLoadingRecent);
|
return expandNormalizedTimeline(state, action.timeline, fromJS(action.statuses), action.next, action.partial, action.isLoadingRecent);
|
||||||
case TIMELINE_UPDATE:
|
case TIMELINE_UPDATE:
|
||||||
return updateTimeline(state, action.timeline, fromJS(action.status));
|
return updateTimeline(state, action.timeline, action.statusId);
|
||||||
case TIMELINE_UPDATE_QUEUE:
|
case TIMELINE_UPDATE_QUEUE:
|
||||||
return updateTimelineQueue(state, action.timeline, fromJS(action.status));
|
return updateTimelineQueue(state, action.timeline, action.statusId);
|
||||||
case TIMELINE_DEQUEUE:
|
case TIMELINE_DEQUEUE:
|
||||||
return state.update(action.timeline, initialTimeline, map => map.withMutations(mMap => {
|
return state.update(action.timeline, initialTimeline, map => map.withMutations(mMap => {
|
||||||
mMap.set('queuedItems', ImmutableList());
|
mMap.set('queuedItems', ImmutableList());
|
||||||
|
|
Loading…
Reference in a new issue