Timelines: push pending statuses into queue
This commit is contained in:
parent
d677ef7cdf
commit
f290b78636
1 changed files with 16 additions and 13 deletions
|
@ -236,17 +236,16 @@ const getTimelinesByVisibility = visibility => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const replaceItem = (state, timelineId, oldId, newId) => {
|
// Given an OrderedSet of IDs, replace oldId with newId maintaining its position
|
||||||
return state.updateIn([timelineId, 'items'], ids => {
|
const replaceId = (ids, oldId, newId) => {
|
||||||
const list = ImmutableList(ids);
|
const list = ImmutableList(ids);
|
||||||
const index = list.indexOf(oldId);
|
const index = list.indexOf(oldId);
|
||||||
|
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
return ImmutableOrderedSet(list.set(index, newId));
|
return ImmutableOrderedSet(list.set(index, newId));
|
||||||
} else {
|
} else {
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const importPendingStatus = (state, params, idempotencyKey) => {
|
const importPendingStatus = (state, params, idempotencyKey) => {
|
||||||
|
@ -256,7 +255,7 @@ const importPendingStatus = (state, params, idempotencyKey) => {
|
||||||
const timelineIds = getTimelinesByVisibility(params.visibility);
|
const timelineIds = getTimelinesByVisibility(params.visibility);
|
||||||
|
|
||||||
timelineIds.forEach(timelineId => {
|
timelineIds.forEach(timelineId => {
|
||||||
updateTimeline(state, timelineId, statusId);
|
updateTimelineQueue(state, timelineId, statusId);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
@ -264,8 +263,12 @@ const importPendingStatus = (state, params, idempotencyKey) => {
|
||||||
const replacePendingStatus = (state, idempotencyKey, newId) => {
|
const replacePendingStatus = (state, idempotencyKey, newId) => {
|
||||||
const oldId = `末pending-${idempotencyKey}`;
|
const oldId = `末pending-${idempotencyKey}`;
|
||||||
|
|
||||||
state.keySeq().forEach(timelineId => {
|
// Loop through timelines and replace the pending status with the real one
|
||||||
return replaceItem(state, timelineId, oldId, newId);
|
return state.withMutations(state => {
|
||||||
|
state.keySeq().forEach(timelineId => {
|
||||||
|
state.updateIn([timelineId, 'items'], ids => replaceId(ids, oldId, newId));
|
||||||
|
state.updateIn([timelineId, 'queuedItems'], ids => replaceId(ids, oldId, newId));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue