diff --git a/src/components/status.css b/src/components/status.css
index 9d5f7560..2c50b04a 100644
--- a/src/components/status.css
+++ b/src/components/status.css
@@ -149,7 +149,7 @@
margin: 4px 0 0 0;
gap: 4px;
align-items: center;
- color: var(--reply-to-color);
+ color: var(--reply-to-text-color);
background: var(--bg-color);
border: 1px solid var(--reply-to-color);
border-radius: 4px;
diff --git a/src/components/status.jsx b/src/components/status.jsx
index a6bb7f3f..2b246b80 100644
--- a/src/components/status.jsx
+++ b/src/components/status.jsx
@@ -270,30 +270,32 @@ function Status({
))}
- {!!inReplyToId &&
- !!inReplyToAccountId &&
- !withinContext &&
- size !== 's' && (
- <>
- {inReplyToAccountId === status.account.id ? (
-
-
- Thread
+ {!withinContext && size !== 's' && (
+ <>
+ {inReplyToAccountId === status.account?.id ||
+ !!snapStates.statusThreadNumber[id] ? (
+
+
+ Thread
+ {snapStates.statusThreadNumber[id]
+ ? ` ${snapStates.statusThreadNumber[id]}/X`
+ : ''}
+
+ ) : (
+ !!inReplyToId &&
+ !!inReplyToAccount &&
+ (!!spoilerText ||
+ !mentions.find((mention) => {
+ return mention.id === inReplyToAccountId;
+ })) && (
+
+ {' '}
+
- ) : (
- !!inReplyToAccount &&
- (!!spoilerText ||
- !mentions.find((mention) => {
- return mention.id === inReplyToAccountId;
- })) && (
-
- {' '}
-
-
- )
- )}
- >
- )}
+ )
+ )}
+ >
+ )}
{
+ threadifyStatus(status);
+ });
+ }
+}
+
+function threadifyStatus(status) {
+ // Return all statuses in the thread, via inReplyToId, if inReplyToAccountId === account.id
+ let fetchIndex = 0;
+ async function traverse(status, index = 0) {
+ const { inReplyToId, inReplyToAccountId } = status;
+ if (!inReplyToId || inReplyToAccountId !== status.account.id) {
+ return [status];
+ }
+ if (inReplyToId && inReplyToAccountId !== status.account.id) {
+ throw 'Not a thread';
+ // Possibly thread of replies by multiple people?
+ }
+ let prevStatus = states.statuses[inReplyToId];
+ if (!prevStatus) {
+ if (fetchIndex++ > 3) throw 'Too many fetches for thread'; // Some people revive old threads
+ await new Promise((r) => setTimeout(r, 500 * fetchIndex)); // Be nice to rate limits
+ prevStatus = await masto.v1.statuses.fetch(inReplyToId);
+ saveStatus(prevStatus, { skipThreading: true });
+ }
+ // Prepend so that first status in thread will be index 0
+ return [...(await traverse(prevStatus, ++index)), status];
+ }
+ return traverse(status)
+ .then((statuses) => {
+ if (statuses.length > 1) {
+ console.debug('THREAD', statuses);
+ statuses.forEach((status, index) => {
+ states.statusThreadNumber[status.id] = index + 1;
+ });
+ }
+ })
+ .catch((e) => {
+ console.error(e, status);
+ });
}