Wholistic context import (builds tree from anywhere in the thread)
This commit is contained in:
parent
cc278f7ca6
commit
cc6d2599cb
|
@ -38,16 +38,23 @@ const insertTombstone = (state, ancestorId, descendantId) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const normalizeContext = (state, id, ancestors, descendants) => state.withMutations(state => {
|
const importBranch = (state, statuses, rootId) => {
|
||||||
importStatuses(state, ancestors);
|
return state.withMutations(state => {
|
||||||
|
statuses.forEach((status, i) => {
|
||||||
|
const lastId = rootId && i === 0 ? rootId : (statuses[i - 1] || {}).id;
|
||||||
|
|
||||||
descendants.forEach(status => {
|
if (status.in_reply_to_id) {
|
||||||
if (status.in_reply_to_id) {
|
importStatus(state, status);
|
||||||
importStatus(state, status);
|
} else if (lastId) {
|
||||||
} else {
|
insertTombstone(state, lastId, status.id);
|
||||||
insertTombstone(state, id, status.id);
|
}
|
||||||
}
|
});
|
||||||
});
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const normalizeContext = (state, id, ancestors, descendants) => state.withMutations(state => {
|
||||||
|
importBranch(state, ancestors);
|
||||||
|
importBranch(state, descendants, id);
|
||||||
|
|
||||||
if (ancestors.length > 0 && !state.getIn(['inReplyTos', id])) {
|
if (ancestors.length > 0 && !state.getIn(['inReplyTos', id])) {
|
||||||
insertTombstone(state, ancestors[ancestors.length - 1].id, id);
|
insertTombstone(state, ancestors[ancestors.length - 1].id, id);
|
||||||
|
|
Loading…
Reference in New Issue