diff --git a/package-lock.json b/package-lock.json index 688ee10..2ece450 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "nostiger", + "name": "rabbit", "version": "0.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { - "name": "nostiger", + "name": "rabbit", "version": "0.0.0", "license": "AGPL-3.0-or-later", "dependencies": { @@ -16,7 +16,9 @@ "@tanstack/react-query-persist-client": "^4.24.10", "@tanstack/solid-query": "^4.24.10", "@thisbeyond/solid-dnd": "^0.7.3", + "@types/lodash": "^4.14.191", "heroicons": "^2.0.15", + "lodash": "^4.17.21", "nostr-tools": "^1.3.2", "solid-js": "^1.6.9", "tailwindcss": "^3.2.4", @@ -1492,6 +1494,11 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "node_modules/@types/lodash": { + "version": "4.14.191", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.191.tgz", + "integrity": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==" + }, "node_modules/@types/mocha": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz", @@ -5281,6 +5288,11 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, "node_modules/lodash.flattendeep": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", @@ -9532,6 +9544,11 @@ "integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==", "dev": true }, + "@types/lodash": { + "version": "4.14.191", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.191.tgz", + "integrity": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==" + }, "@types/mocha": { "version": "10.0.1", "resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz", @@ -12263,6 +12280,11 @@ "p-locate": "^5.0.0" } }, + "lodash": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + }, "lodash.flattendeep": { "version": "4.4.0", "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", diff --git a/package.json b/package.json index 7ca1762..b3782ce 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,9 @@ "@tanstack/react-query-persist-client": "^4.24.10", "@tanstack/solid-query": "^4.24.10", "@thisbeyond/solid-dnd": "^0.7.3", + "@types/lodash": "^4.14.191", "heroicons": "^2.0.15", + "lodash": "^4.17.21", "nostr-tools": "^1.3.2", "solid-js": "^1.6.9", "tailwindcss": "^3.2.4", diff --git a/src/clients/useCommands.ts b/src/clients/useCommands.ts index fddc9a2..92f873b 100644 --- a/src/clients/useCommands.ts +++ b/src/clients/useCommands.ts @@ -46,16 +46,33 @@ const useCommands = () => { relayUrls, pubkey, content, + notifyPubkeys, + rootEventId, + mentionEventIds, + replyEventId, }: { relayUrls: string[]; pubkey: string; content: string; + notifyPubkeys?: string[]; + rootEventId?: string; + mentionEventIds?: string[]; + replyEventId?: string; }): Promise[]> { + const pTags = notifyPubkeys?.map((p) => ['p', p]) ?? []; + const eTags = []; + if (rootEventId != null) eTags.push(['e', rootEventId, '', 'root']); + if (mentionEventIds != null) + mentionEventIds.forEach((id) => eTags.push(['e', id, '', 'mention'])); + if (replyEventId != null) eTags.push(['e', replyEventId, '', 'reply']); + + const tags = [...pTags, ...eTags]; + const preSignedEvent: NostrEvent = { kind: 1, pubkey, created_at: currentDate(), - tags: [], + tags, content, }; return publishEvent(relayUrls, preSignedEvent); diff --git a/src/clients/useDeprecatedReposts.ts b/src/clients/useDeprecatedReposts.ts index d2ffa06..4b81785 100644 --- a/src/clients/useDeprecatedReposts.ts +++ b/src/clients/useDeprecatedReposts.ts @@ -31,6 +31,7 @@ const { exec } = useBatchedEvents(() => ({ const useDeprecatedReposts = ( propsProvider: () => UseDeprecatedRepostsProps, ): UseDeprecatedReposts => { + const queryClient = useQueryClient(); const props = createMemo(propsProvider); const queryKey = createMemo(() => ['useDeprecatedReposts', props()] as const); @@ -55,10 +56,8 @@ const useDeprecatedReposts = ( const isRepostedBy = (pubkey: string): boolean => reposts().findIndex((event) => event.pubkey === pubkey) !== -1; - const invalidateDeprecatedReposts = (): Promise => { - const queryClient = useQueryClient(); - return queryClient.invalidateQueries(queryKey()); - }; + const invalidateDeprecatedReposts = (): Promise => + queryClient.invalidateQueries(queryKey()); return { reposts, isRepostedBy, invalidateDeprecatedReposts, query }; }; diff --git a/src/clients/useReactions.ts b/src/clients/useReactions.ts index f5a1965..87ab369 100644 --- a/src/clients/useReactions.ts +++ b/src/clients/useReactions.ts @@ -30,6 +30,7 @@ const { exec } = useBatchedEvents(() => ({ })); const useReactions = (propsProvider: () => UseReactionsProps): UseReactions => { + const queryClient = useQueryClient(); const props = createMemo(propsProvider); const queryKey = createMemo(() => ['useReactions', props()] as const); @@ -61,10 +62,7 @@ const useReactions = (propsProvider: () => UseReactionsProps): UseReactions => { const isReactedBy = (pubkey: string): boolean => reactions().findIndex((event) => event.pubkey === pubkey) !== -1; - const invalidateReactions = (): Promise => { - const queryClient = useQueryClient(); - return queryClient.invalidateQueries(queryKey()); - }; + const invalidateReactions = (): Promise => queryClient.invalidateQueries(queryKey()); return { reactions, reactionsGroupedByContent, isReactedBy, invalidateReactions, query }; }; diff --git a/src/components/ColumnItem.tsx b/src/components/ColumnItem.tsx index 16f0a24..8a60bdd 100644 --- a/src/components/ColumnItem.tsx +++ b/src/components/ColumnItem.tsx @@ -5,9 +5,7 @@ type ColumnItemProps = { }; const ColumnItem: Component = (props) => { - return ( -
{props.children}
- ); + return
{props.children}
; }; export default ColumnItem; diff --git a/src/components/DeprecatedRepost.tsx b/src/components/DeprecatedRepost.tsx index c69d9c2..964e3cd 100644 --- a/src/components/DeprecatedRepost.tsx +++ b/src/components/DeprecatedRepost.tsx @@ -7,7 +7,7 @@ import useConfig from '@/clients/useConfig'; import useEvent from '@/clients/useEvent'; import useProfile from '@/clients/useProfile'; -import UserNameDisplay from '@/components/UserNameDisplay'; +import UserDisplayName from '@/components/UserDisplayName'; import TextNote from '@/components/TextNote'; export type DeprecatedRepostProps = { @@ -32,7 +32,7 @@ const DeprecatedRepost: Component = (props) => {
- + {' Reposted'}
diff --git a/src/components/NotePostForm.tsx b/src/components/NotePostForm.tsx index 64d7a5d..1b7051e 100644 --- a/src/components/NotePostForm.tsx +++ b/src/components/NotePostForm.tsx @@ -25,7 +25,7 @@ const NotePostForm: Component = (props) => { return (
-
+