fix thread ordering

This commit is contained in:
smolgrrr 2023-11-27 19:14:42 +11:00
parent 7df3e9f24a
commit f3773d7ea4
5 changed files with 17 additions and 9 deletions

View File

@ -4,7 +4,7 @@ import {
export default function Header() {
return (
<header className="mx-auto max-w-7xl px-4 sm:px-6 lg:px-8">
<header className="mx-auto px-4 sm:px-6 lg:px-8">
<div className="flex justify-between items-center h-16">
<a href="/">
<div className="flex items-center gap-2">

View File

@ -73,7 +73,7 @@ const Home = () => {
</div>
</label>
</div>
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4">
<div className="grid grid-cols-1 md:grid-cols-3 lg:grid-cols-4 gap-4 p-4">
{sortedEvents.map((event) => (
<PostCard
key={event.id}

View File

@ -1,7 +1,7 @@
const Placeholder = () => {
return (
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4">
<div className="mx-auto grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 p-4">
<div className="border border-blue-300 shadow rounded-md p-4 max-w-sm w-full mx-auto">
<div className="animate-pulse flex space-x-4">
<div className="rounded-full bg-slate-700 h-10 w-10"></div>

View File

@ -84,20 +84,26 @@ const Thread = () => {
.filter(event =>
event.kind === 1 &&
preOPEvents.includes(event.id)
)
.sort((a, b) => (b.created_at as any) - (a.created_at as any));
).sort((a, b) => (b.created_at as any) - (a.created_at as any));
const toggleSort = () => {
setSortByTime(prev => !prev);
};
const eventsSortedByTime = [...uniqEvents].slice(1).filter(event => event.kind === 1).sort((a, b) => a.created_at - b.created_at);
const eventsSortedByTime = [...uniqEvents].slice(1)
.filter(event =>
event.kind === 1 &&
!earlierEvents.map(e => e.id).includes(event.id) &&
(OPEvent ? OPEvent.id !== event.id : true)
).sort((a, b) => a.created_at - b.created_at);
// Events sorted by PoW (assuming `getPow` returns a numerical representation of the PoW)
const eventsSortedByPow = [...uniqEvents].slice(1)
.filter((event) =>
getPow(event.id) > Number(filterDifficulty) &&
event.kind === 1
event.kind === 1 &&
!earlierEvents.map(e => e.id).includes(event.id) &&
(OPEvent ? OPEvent.id !== event.id : true)
).sort((a, b) => getPow(b.id) - getPow(a.id));
const displayedEvents = sortByTime ? eventsSortedByTime : eventsSortedByPow;

View File

@ -98,3 +98,5 @@ addRelay('wss://nostr.mom');
addRelay('wss://relay.nostr.bg');
addRelay('wss://nos.lol');
addRelay('wss://powrelay.xyz');
addRelay('wss://relay.damus.io');
addRelay('wss://nostr.mutinywallet.com');