improve diff filters

fix tests
expander/compressor filter mangler
This commit is contained in:
2023-06-01 22:03:28 +01:00
parent 25e7f68dce
commit ae6618f0ed
39 changed files with 504 additions and 261 deletions

View File

@ -1,5 +1,5 @@
import { FormattedMessage } from "react-intl";
import { RawEvent } from "System";
import { NostrEvent } from "System";
import { findTag, NostrLink } from "SnortUtils";
import useEventFeed from "Feed/EventFeed";
@ -14,7 +14,7 @@ export default function NostrFileHeader({ link }: { link: NostrLink }) {
return <NostrFileElement ev={ev.data} />;
}
export function NostrFileElement({ ev }: { ev: RawEvent }) {
export function NostrFileElement({ ev }: { ev: NostrEvent }) {
// assume image or embed which can be rendered by the hypertext kind
// todo: make use of hash
// todo: use magnet or other links if present

View File

@ -1,7 +1,7 @@
import "./NoteReaction.css";
import { Link } from "react-router-dom";
import { useMemo } from "react";
import { EventKind, RawEvent, TaggedRawEvent, NostrPrefix } from "System";
import { EventKind, NostrEvent, TaggedRawEvent, NostrPrefix } from "System";
import Note from "Element/Note";
import ProfileImage from "Element/ProfileImage";
@ -43,7 +43,7 @@ export default function NoteReaction(props: NoteReactionProps) {
function extractRoot() {
if (ev?.kind === EventKind.Repost && ev.content.length > 0 && ev.content !== "#[0]") {
try {
const r: RawEvent = JSON.parse(ev.content);
const r: NostrEvent = JSON.parse(ev.content);
return r as TaggedRawEvent;
} catch (e) {
console.error("Could not load reposted content", e);

View File

@ -1,8 +1,8 @@
import { RawEvent } from "System";
import { NostrEvent } from "System";
import { dedupe } from "SnortUtils";
import FollowListBase from "./FollowListBase";
export default function PubkeyList({ ev, className }: { ev: RawEvent; className?: string }) {
export default function PubkeyList({ ev, className }: { ev: NostrEvent; className?: string }) {
const ids = dedupe(ev.tags.filter(a => a[0] === "p").map(a => a[1]));
return <FollowListBase pubkeys={ids} showAbout={true} className={className} />;
}

View File

@ -2,7 +2,7 @@ import "./SendSats.css";
import React, { useEffect, useMemo, useState } from "react";
import { useIntl, FormattedMessage } from "react-intl";
import { HexKey, RawEvent } from "System";
import { HexKey, NostrEvent } from "System";
import { System } from "index";
import { formatShort } from "Number";
import Icon from "Icons/Icon";
@ -125,7 +125,7 @@ export default function SendSats(props: SendSatsProps) {
async function loadInvoice() {
if (!amount || !handler || !publisher) return null;
let zap: RawEvent | undefined;
let zap: NostrEvent | undefined;
if (author && zapType !== ZapType.NonZap) {
const relays = Object.keys(login.relays.item);

View File

@ -5,7 +5,7 @@ import useRelayState from "Feed/RelayState";
import Tabs, { Tab } from "Element/Tabs";
import { unwrap } from "SnortUtils";
import useSystemState from "Hooks/useSystemState";
import { RawReqFilter } from "System";
import { ReqFilter } from "System";
import { useCopy } from "useCopy";
import { System } from "index";
@ -18,7 +18,7 @@ function Queries() {
const qs = useSystemState();
const { copy } = useCopy();
function countElements(filters: Array<RawReqFilter>) {
function countElements(filters: Array<ReqFilter>) {
let total = 0;
for (const f of filters) {
for (const v of Object.values(f)) {
@ -30,12 +30,7 @@ function Queries() {
return total;
}
function queryInfo(q: {
id: string;
filters: Array<RawReqFilter>;
closing: boolean;
subFilters: Array<RawReqFilter>;
}) {
function queryInfo(q: { id: string; filters: Array<ReqFilter>; closing: boolean; subFilters: Array<ReqFilter> }) {
return (
<div key={q.id}>
{q.closing ? <s>{q.id}</s> : <>{q.id}</>}

View File

@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { RawEvent, TaggedRawEvent } from "System";
import { NostrEvent, TaggedRawEvent } from "System";
import { FormattedMessage } from "react-intl";
import PageSpinner from "Element/PageSpinner";
@ -7,7 +7,7 @@ import Note from "Element/Note";
import NostrBandApi from "External/NostrBand";
export default function TrendingNotes() {
const [posts, setPosts] = useState<Array<RawEvent>>();
const [posts, setPosts] = useState<Array<NostrEvent>>();
async function loadTrendingNotes() {
const api = new NostrBandApi();

View File

@ -1,4 +1,4 @@
import { encodeTLV, NostrPrefix, RawEvent } from "System";
import { encodeTLV, NostrPrefix, NostrEvent } from "System";
import useEventPublisher from "Feed/EventPublisher";
import Icon from "Icons/Icon";
import Spinner from "Icons/Spinner";
@ -11,7 +11,7 @@ export default function WriteDm({ chatPubKey }: { chatPubKey: string }) {
const [msg, setMsg] = useState("");
const [sending, setSending] = useState(false);
const [uploading, setUploading] = useState(false);
const [otherEvents, setOtherEvents] = useState<Array<RawEvent>>([]);
const [otherEvents, setOtherEvents] = useState<Array<NostrEvent>>([]);
const [error, setError] = useState("");
const publisher = useEventPublisher();
const uploader = useFileUpload();

View File

@ -1,12 +1,12 @@
import "./ZapstrEmbed.css";
import { Link } from "react-router-dom";
import { encodeTLV, NostrPrefix, RawEvent } from "System";
import { encodeTLV, NostrPrefix, NostrEvent } from "System";
import { ProxyImg } from "Element/ProxyImg";
import ProfileImage from "Element/ProfileImage";
import { FormattedMessage } from "react-intl";
export default function ZapstrEmbed({ ev }: { ev: RawEvent }) {
export default function ZapstrEmbed({ ev }: { ev: NostrEvent }) {
const media = ev.tags.find(a => a[0] === "media");
const cover = ev.tags.find(a => a[0] === "cover");
const subject = ev.tags.find(a => a[0] === "subject");