mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-10-05 17:55:01 +02:00
fix bug with reactions not showing loading
This commit is contained in:
@@ -16,7 +16,7 @@ export function useAddReaction(event: NostrEvent, grouped: ReactionGroup[]) {
|
|||||||
|
|
||||||
const draft = draftEventReaction(event, emoji, url);
|
const draft = draftEventReaction(event, emoji, url);
|
||||||
|
|
||||||
publish("Reaction", draft);
|
await publish("Reaction", draft);
|
||||||
},
|
},
|
||||||
[grouped, account, publish],
|
[grouped, account, publish],
|
||||||
);
|
);
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
import { useMemo } from "react";
|
import { useMemo, useState } from "react";
|
||||||
|
|
||||||
import { NostrEvent } from "../../types/nostr-event";
|
import { NostrEvent } from "../../types/nostr-event";
|
||||||
import useEventReactions from "../../hooks/use-event-reactions";
|
import useEventReactions from "../../hooks/use-event-reactions";
|
||||||
@@ -13,6 +13,7 @@ export default function EventReactionButtons({ event, max }: { event: NostrEvent
|
|||||||
const grouped = useMemo(() => groupReactions(reactions), [reactions]);
|
const grouped = useMemo(() => groupReactions(reactions), [reactions]);
|
||||||
|
|
||||||
const addReaction = useAddReaction(event, grouped);
|
const addReaction = useAddReaction(event, grouped);
|
||||||
|
const [loading, setLoading] = useState<string>();
|
||||||
|
|
||||||
if (grouped.length === 0) return null;
|
if (grouped.length === 0) return null;
|
||||||
|
|
||||||
@@ -27,7 +28,11 @@ export default function EventReactionButtons({ event, max }: { event: NostrEvent
|
|||||||
emoji={group.emoji}
|
emoji={group.emoji}
|
||||||
url={group.url}
|
url={group.url}
|
||||||
count={group.pubkeys.length}
|
count={group.pubkeys.length}
|
||||||
onClick={() => addReaction(group.emoji, group.url)}
|
isLoading={loading === group.emoji}
|
||||||
|
onClick={() => {
|
||||||
|
setLoading(group.emoji);
|
||||||
|
addReaction(group.emoji, group.url).finally(() => setLoading(undefined));
|
||||||
|
}}
|
||||||
colorScheme={account && group.pubkeys.includes(account?.pubkey) ? "primary" : undefined}
|
colorScheme={account && group.pubkeys.includes(account?.pubkey) ? "primary" : undefined}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
@@ -87,9 +87,6 @@ export class NostrConnectClient {
|
|||||||
"#p": [this.publicKey],
|
"#p": [this.publicKey],
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.log("Secret Key:", this.secretKey);
|
|
||||||
this.log("Public Key:", this.publicKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async open() {
|
async open() {
|
||||||
@@ -119,11 +116,11 @@ export class NostrConnectClient {
|
|||||||
try {
|
try {
|
||||||
const responseStr = await nip04.decrypt(this.secretKey, event.pubkey, event.content);
|
const responseStr = await nip04.decrypt(this.secretKey, event.pubkey, event.content);
|
||||||
const response = JSON.parse(responseStr);
|
const response = JSON.parse(responseStr);
|
||||||
this.log("Got Response", response);
|
|
||||||
if (response.id) {
|
if (response.id) {
|
||||||
const p = this.requests.get(response.id);
|
const p = this.requests.get(response.id);
|
||||||
if (!p) return;
|
if (!p) return;
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
|
this.log("Got Error", response.id, response.result, response.error);
|
||||||
if (response.result === "auth_url") {
|
if (response.result === "auth_url") {
|
||||||
try {
|
try {
|
||||||
await this.handleAuthURL(response.error);
|
await this.handleAuthURL(response.error);
|
||||||
@@ -132,7 +129,7 @@ export class NostrConnectClient {
|
|||||||
}
|
}
|
||||||
} else p.reject(response);
|
} else p.reject(response);
|
||||||
} else if (response.result) {
|
} else if (response.result) {
|
||||||
this.log(response.id, response.result);
|
this.log("Got Response", response.id, response.result);
|
||||||
p.resolve(response.result);
|
p.resolve(response.result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user