Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
hzrd149 committed Nov 30, 2024
1 parent bff5286 commit 864ccc3
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"dev": "VITE_APP_VERSION=dev vite serve",
"build": "tsc --project tsconfig.json && vite build",
"format": "prettier --ignore-path .prettierignore -w .",
"analyze": "npx vite-bundle-visualizer -o ./stats.html",
"analyze": "pnpm dlx vite-bundle-visualizer -o ./stats.html",
"build-icons": "node ./scripts/build-icons.mjs"
},
"dependencies": {
Expand Down Expand Up @@ -152,5 +152,5 @@
"type": "lightning",
"url": "lightning:[email protected]"
},
"packageManager": "pnpm@9.6.0"
"packageManager": "pnpm@9.14.4"
}
10 changes: 7 additions & 3 deletions src/classes/notifications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { BehaviorSubject } from "rxjs";
import { map, throttleTime } from "rxjs/operators";
import { getZapPayment } from "applesauce-core/helpers";

import { getThreadReferences, isReply, isRepost } from "../helpers/nostr/event";
import { getContentPointers, getThreadReferences, isReply, isRepost } from "../helpers/nostr/event";
import singleEventService from "../services/single-event";
import RelaySet from "./relay-set";
import clientRelaysService from "../services/client-relays";
import { getPubkeysMentionedInContent } from "../helpers/nostr/post";
import { TORRENT_COMMENT_KIND } from "../helpers/nostr/torrents";
import { getPubkeysFromList } from "../helpers/nostr/lists";
import { eventStore, queryStore } from "../services/event-store";
import RelaySet from "./relay-set";

export const NotificationTypeSymbol = Symbol("notificationType");

Expand Down Expand Up @@ -79,7 +79,11 @@ export default class AccountNotifications {
) {
// is the pubkey mentioned in any way in the content
const isMentioned = getPubkeysMentionedInContent(event.content, true).includes(this.pubkey);
const isQuote = event.tags.some((t) => t[0] === "q" && t[3] === this.pubkey);
const isQuote =
event.tags.some((t) => t[0] === "q" && (t[1] === event.id || t[3] === this.pubkey)) ||
getContentPointers(event.content).some(
(p) => (p.type === "nevent" && p.data.id === event.id) || (p.type === "note" && p.data === event.id),
);

if (isMentioned) e[NotificationTypeSymbol] = NotificationType.Mention;
else if (isQuote) e[NotificationTypeSymbol] = NotificationType.Quote;
Expand Down
11 changes: 10 additions & 1 deletion src/components/debug-modal/pages/cache.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ export default function DebugEventCachePage({ event }: { event: NostrEvent }) {
const fields = Object.getOwnPropertySymbols(event);
const update = () => eventStore.update(event);

const renderValue = (field: symbol) => {
let value = Reflect.get(event, field);

if (value instanceof Map) return JSON.stringify(Object.fromEntries(value.entries()));
if (value instanceof Set) return JSON.stringify(Array.from(value));

return JSON.stringify(value);
};

return (
<Flex direction="column">
{fields.map((field) => (
Expand All @@ -17,7 +26,7 @@ export default function DebugEventCachePage({ event }: { event: NostrEvent }) {
{field.description}
</Text>
<Code fontFamily="monospace" isTruncated>
{JSON.stringify(Reflect.get(event, field))}
{renderValue(field)}
</Code>
<CloseButton
ml="auto"
Expand Down

0 comments on commit 864ccc3

Please sign in to comment.