From 5c6c9a43f2855f4d9c40651527bc94596e0b51ce Mon Sep 17 00:00:00 2001
From: Lim Chee Aun <cheeaun@gmail.com>
Date: Sun, 19 Feb 2023 21:16:23 +0800
Subject: [PATCH] Fix regression: threadify stopped working

This is due to status key changed with extra instance string
---
 src/components/status.jsx | 6 +++---
 src/utils/states.js       | 6 ++++--
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/components/status.jsx b/src/components/status.jsx
index bc52ccce..d32fd7df 100644
--- a/src/components/status.jsx
+++ b/src/components/status.jsx
@@ -294,12 +294,12 @@ function Status({
         {!withinContext && (
           <>
             {inReplyToAccountId === status.account?.id ||
-            !!snapStates.statusThreadNumber[id] ? (
+            !!snapStates.statusThreadNumber[sKey] ? (
               <div class="status-thread-badge">
                 <Icon icon="thread" size="s" />
                 Thread
-                {snapStates.statusThreadNumber[id]
-                  ? ` ${snapStates.statusThreadNumber[id]}/X`
+                {snapStates.statusThreadNumber[sKey]
+                  ? ` ${snapStates.statusThreadNumber[sKey]}/X`
                   : ''}
               </div>
             ) : (
diff --git a/src/utils/states.js b/src/utils/states.js
index f58b9742..432f7df2 100644
--- a/src/utils/states.js
+++ b/src/utils/states.js
@@ -124,7 +124,8 @@ export function threadifyStatus(status, propInstance) {
       throw 'Not a thread';
       // Possibly thread of replies by multiple people?
     }
-    let prevStatus = states.statuses[inReplyToId];
+    const key = statusKey(inReplyToId, instance);
+    let prevStatus = states.statuses[key];
     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
@@ -139,7 +140,8 @@ export function threadifyStatus(status, propInstance) {
       if (statuses.length > 1) {
         console.debug('THREAD', statuses);
         statuses.forEach((status, index) => {
-          states.statusThreadNumber[status.id] = index + 1;
+          const key = statusKey(status.id, instance);
+          states.statusThreadNumber[key] = index + 1;
         });
       }
     })