Timelines: push pending statuses into queue

draftjs
Alex Gleason 2021-10-23 15:08:21 -05:00
rodzic d677ef7cdf
commit f290b78636
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
1 zmienionych plików z 16 dodań i 13 usunięć

Wyświetl plik

@ -236,8 +236,8 @@ const getTimelinesByVisibility = visibility => {
}
};
const replaceItem = (state, timelineId, oldId, newId) => {
return state.updateIn([timelineId, 'items'], ids => {
// Given an OrderedSet of IDs, replace oldId with newId maintaining its position
const replaceId = (ids, oldId, newId) => {
const list = ImmutableList(ids);
const index = list.indexOf(oldId);
@ -246,7 +246,6 @@ const replaceItem = (state, timelineId, oldId, newId) => {
} else {
return ids;
}
});
};
const importPendingStatus = (state, params, idempotencyKey) => {
@ -256,7 +255,7 @@ const importPendingStatus = (state, params, idempotencyKey) => {
const timelineIds = getTimelinesByVisibility(params.visibility);
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 oldId = `末pending-${idempotencyKey}`;
// Loop through timelines and replace the pending status with the real one
return state.withMutations(state => {
state.keySeq().forEach(timelineId => {
return replaceItem(state, timelineId, oldId, newId);
state.updateIn([timelineId, 'items'], ids => replaceId(ids, oldId, newId));
state.updateIn([timelineId, 'queuedItems'], ids => replaceId(ids, oldId, newId));
});
});
};