diff --git a/lib/shared/ancestor-threads.js b/lib/shared/ancestor-threads.js index dcc1ef101..f84c8e523 100644 --- a/lib/shared/ancestor-threads.js +++ b/lib/shared/ancestor-threads.js @@ -1,24 +1,29 @@ // @flow import genesis from '../facts/genesis'; import { threadInfoSelector, ancestorThreadInfos, } from '../selectors/thread-selectors'; import { threadIsPending } from '../shared/thread-utils'; import { type ThreadInfo } from '../types/thread-types'; import { useSelector } from '../utils/redux-utils'; function useAncestorThreads( threadInfo: ThreadInfo, ): $ReadOnlyArray { return useSelector(state => { if (!threadIsPending(threadInfo.id)) { - return ancestorThreadInfos(threadInfo.id)(state).slice(0, -1); + const ancestorThreads = ancestorThreadInfos(threadInfo.id)(state); + if (ancestorThreads.length > 1) { + return ancestorThreads.slice(0, -1); + } + + return ancestorThreads; } const genesisThreadInfo = threadInfoSelector(state)[genesis.id]; return genesisThreadInfo ? [genesisThreadInfo] : []; }); } export { useAncestorThreads };