1
0
Fork 0

Add check for "missing" statuses in context

This commit is contained in:
Lim Chee Aun 2023-05-18 23:42:49 +08:00
parent 104665cafe
commit 1f7912d6b8

View file

@ -248,10 +248,17 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
totalDescendants.current = descendants?.length || 0;
const missingStatuses = new Set();
ancestors.forEach((status) => {
saveStatus(status, instance, {
skipThreading: true,
});
if (
status.inReplyToId &&
!ancestors.find((s) => s.id === status.inReplyToId)
) {
missingStatuses.add(status.inReplyToId);
}
});
const ancestorsIsThread = ancestors.every(
(s) => s.account.id === heroStatus.account.id,
@ -261,6 +268,14 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
saveStatus(status, instance, {
skipThreading: true,
});
if (
status.inReplyToId &&
!descendants.find((s) => s.id === status.inReplyToId)
) {
missingStatuses.add(status.inReplyToId);
}
if (status.inReplyToAccountId === status.account.id) {
// If replying to self, it's part of the thread, level 1
nestedDescendants.push(status);
@ -290,6 +305,9 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
});
console.log({ ancestors, descendants, nestedDescendants });
if (missingStatuses.size) {
console.error('Missing statuses', [...missingStatuses]);
}
function expandReplies(_replies) {
return _replies?.map((_r) => ({