Fix wrong sort

Why is this so complicated
This commit is contained in:
Lim Chee Aun 2024-10-31 22:31:15 +08:00
parent 163c98df01
commit 41c1ceeeff
2 changed files with 42 additions and 33 deletions

64
src/locales/en.po generated
View file

@ -118,7 +118,7 @@ msgstr ""
#: src/pages/hashtag.jsx:199
#: src/pages/list.jsx:157
#: src/pages/public.jsx:114
#: src/pages/status.jsx:1198
#: src/pages/status.jsx:1207
#: src/pages/trending.jsx:471
msgid "More"
msgstr ""
@ -185,8 +185,8 @@ msgstr ""
#: src/pages/catchup.jsx:71
#: src/pages/catchup.jsx:1445
#: src/pages/catchup.jsx:2056
#: src/pages/status.jsx:921
#: src/pages/status.jsx:1543
#: src/pages/status.jsx:930
#: src/pages/status.jsx:1552
msgid "Replies"
msgstr ""
@ -427,7 +427,7 @@ msgstr ""
#: src/pages/notifications.jsx:868
#: src/pages/notifications.jsx:1082
#: src/pages/settings.jsx:76
#: src/pages/status.jsx:1285
#: src/pages/status.jsx:1294
msgid "Close"
msgstr ""
@ -967,7 +967,7 @@ msgstr ""
#: src/pages/list.jsx:293
#: src/pages/notifications.jsx:848
#: src/pages/search.jsx:454
#: src/pages/status.jsx:1318
#: src/pages/status.jsx:1327
msgid "Show more…"
msgstr ""
@ -1358,7 +1358,7 @@ msgstr ""
#: src/components/nav-menu.jsx:363
#: src/pages/login.jsx:189
#: src/pages/status.jsx:821
#: src/pages/status.jsx:830
#: src/pages/welcome.jsx:64
msgid "Log in"
msgstr ""
@ -1548,8 +1548,8 @@ msgstr ""
#: src/components/poll.jsx:205
#: src/components/poll.jsx:207
#: src/pages/status.jsx:1187
#: src/pages/status.jsx:1210
#: src/pages/status.jsx:1196
#: src/pages/status.jsx:1219
msgid "Refresh"
msgstr ""
@ -2317,8 +2317,8 @@ msgstr ""
#: src/components/timeline.jsx:554
#: src/pages/home.jsx:213
#: src/pages/notifications.jsx:824
#: src/pages/status.jsx:974
#: src/pages/status.jsx:1347
#: src/pages/status.jsx:983
#: src/pages/status.jsx:1356
msgid "Try again"
msgstr ""
@ -3566,85 +3566,85 @@ msgid "NOTE: Push notifications only work for <0>one account</0>."
msgstr ""
#. js-lingui-explicit-id
#: src/pages/status.jsx:583
#: src/pages/status.jsx:1117
#: src/pages/status.jsx:592
#: src/pages/status.jsx:1126
msgid "post.title"
msgstr "Post"
#: src/pages/status.jsx:808
#: src/pages/status.jsx:817
msgid "You're not logged in. Interactions (reply, boost, etc) are not possible."
msgstr ""
#: src/pages/status.jsx:828
#: src/pages/status.jsx:837
msgid "This post is from another instance (<0>{instance}</0>). Interactions (reply, boost, etc) are not possible."
msgstr ""
#: src/pages/status.jsx:856
#: src/pages/status.jsx:865
msgid "Error: {e}"
msgstr ""
#: src/pages/status.jsx:863
#: src/pages/status.jsx:872
msgid "Switch to my instance to enable interactions"
msgstr ""
#: src/pages/status.jsx:965
#: src/pages/status.jsx:974
msgid "Unable to load replies."
msgstr ""
#: src/pages/status.jsx:1077
#: src/pages/status.jsx:1086
msgid "Back"
msgstr ""
#: src/pages/status.jsx:1108
#: src/pages/status.jsx:1117
msgid "Go to main post"
msgstr ""
#: src/pages/status.jsx:1131
#: src/pages/status.jsx:1140
msgid "{0} posts above Go to top"
msgstr ""
#: src/pages/status.jsx:1174
#: src/pages/status.jsx:1237
#: src/pages/status.jsx:1183
#: src/pages/status.jsx:1246
msgid "Switch to Side Peek view"
msgstr ""
#: src/pages/status.jsx:1238
#: src/pages/status.jsx:1247
msgid "Switch to Full view"
msgstr ""
#: src/pages/status.jsx:1256
#: src/pages/status.jsx:1265
msgid "Show all sensitive content"
msgstr ""
#: src/pages/status.jsx:1261
#: src/pages/status.jsx:1270
msgid "Experimental"
msgstr ""
#: src/pages/status.jsx:1270
#: src/pages/status.jsx:1279
msgid "Unable to switch"
msgstr ""
#: src/pages/status.jsx:1277
#: src/pages/status.jsx:1286
msgid "Switch to post's instance ({0})"
msgstr ""
#: src/pages/status.jsx:1280
#: src/pages/status.jsx:1289
msgid "Switch to post's instance"
msgstr ""
#: src/pages/status.jsx:1338
#: src/pages/status.jsx:1347
msgid "Unable to load post"
msgstr ""
#: src/pages/status.jsx:1473
#: src/pages/status.jsx:1482
msgid "{0, plural, one {# reply} other {<0>{1}</0> replies}}"
msgstr ""
#: src/pages/status.jsx:1491
#: src/pages/status.jsx:1500
msgid "{totalComments, plural, one {# comment} other {<0>{0}</0> comments}}"
msgstr ""
#: src/pages/status.jsx:1513
#: src/pages/status.jsx:1522
msgid "View post with its replies"
msgstr ""

View file

@ -323,7 +323,7 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
// Sort oldest first
ancestors.sort((a, b) => a.createdAt - b.createdAt);
descendants.sort((a, b) => a.createdAt - b.createdAt);
// descendants.sort((a, b) => a.createdAt - b.createdAt);
totalDescendants.current = descendants?.length || 0;
@ -388,6 +388,15 @@ function StatusThread({ id, closeLink = '/', instance: propInstance }) {
}
});
nestedDescendants.sort((a, b) => {
// sort hero author to top
const heroAccountID = heroStatus.account.id;
if (a.account.id === heroAccountID) return -1;
if (b.account.id === heroAccountID) return 1;
// sort by createdAt (oldest first)
return a.createdAt - b.createdAt;
});
console.log({ ancestors, descendants, nestedDescendants });
if (missingStatuses.size) {
console.error('Missing statuses', [...missingStatuses]);