feat: list feed rendering

This commit is contained in:
Kieran 2023-10-12 16:28:30 +01:00
parent 01af3a3a58
commit f5aa898631
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
4 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,36 @@
import { dedupe, unwrap } from "@snort/shared";
import { EventKind, parseNostrLink } from "@snort/system";
import { Hour } from "Const";
import Timeline from "Element/Feed/Timeline";
import PageSpinner from "Element/PageSpinner";
import { useEventFeed } from "Feed/EventFeed";
import { FormattedMessage } from "react-intl";
import { useParams } from "react-router-dom";
export function ListFeedPage() {
const { id } = useParams();
const link = parseNostrLink(unwrap(id));
const { data } = useEventFeed(link);
if (!data) return <PageSpinner />;
if (data.kind !== EventKind.ContactList && data.kind !== EventKind.PubkeyLists) {
return (
<b>
<FormattedMessage defaultMessage="Must be a contact list or pubkey list" />
</b>
);
}
const pubkeys = dedupe(data.tags.filter(a => a[0] === "p").map(a => a[1]));
return (
<Timeline
subject={{
type: "pubkey",
items: pubkeys,
discriminator: "list-feed",
}}
postsOnly={true}
method="TIME_RANGE"
window={Hour * 12}
/>
);
}

View File

@ -20,6 +20,7 @@ import {
PowWorker,
} from "@snort/system";
import { SnortContext } from "@snort/system-react";
import { removeUndefined } from "@snort/shared";
import * as serviceWorkerRegistration from "serviceWorkerRegistration";
import { IntlProvider } from "IntlProvider";
@ -48,7 +49,7 @@ import { preload, RelayMetrics, SystemDb, UserCache, UserRelays } from "Cache";
import { LoginStore } from "Login";
import { SnortDeckLayout } from "Pages/DeckLayout";
import FreeNostrAddressPage from "./Pages/FreeNostrAddressPage";
import { removeUndefined } from "@snort/shared";
import { ListFeedPage } from "Pages/ListFeedPage";
const WasmQueryOptimizer = {
expandFilter: (f: ReqFilter) => {
@ -221,6 +222,10 @@ export const router = createBrowserRouter([
path: "/zap-pool",
element: <ZapPoolPage />,
},
{
path: "/list-feed/:id",
element: <ListFeedPage />,
},
...NewUserRoutes,
...WalletRoutes,
...(CONFIG.features.subscriptions ? SubscribeRoutes : []),

View File

@ -1410,6 +1410,9 @@
"v8lolG": {
"defaultMessage": "Start chat"
},
"vB3oQ/": {
"defaultMessage": "Must be a contact list or pubkey list"
},
"vOKedj": {
"defaultMessage": "{n,plural,=1{& {n} other} other{& {n} others}}"
},

View File

@ -462,6 +462,7 @@
"usAvMr": "Edit Profile",
"ut+2Cd": "Get a partner identifier",
"v8lolG": "Start chat",
"vB3oQ/": "Must be a contact list or pubkey list",
"vOKedj": "{n,plural,=1{& {n} other} other{& {n} others}}",
"vZ4quW": "NIP-05 is a DNS based verification spec which helps to validate you as a real user.",
"vhlWFg": "Poll Options",