mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-03-26 17:52:18 +01:00
fix bug with reactions not showing loading
This commit is contained in:
parent
59e61844a8
commit
fba7ef3a2e
@ -16,7 +16,7 @@ export function useAddReaction(event: NostrEvent, grouped: ReactionGroup[]) {
|
||||
|
||||
const draft = draftEventReaction(event, emoji, url);
|
||||
|
||||
publish("Reaction", draft);
|
||||
await publish("Reaction", draft);
|
||||
},
|
||||
[grouped, account, publish],
|
||||
);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { useMemo } from "react";
|
||||
import { useMemo, useState } from "react";
|
||||
|
||||
import { NostrEvent } from "../../types/nostr-event";
|
||||
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 addReaction = useAddReaction(event, grouped);
|
||||
const [loading, setLoading] = useState<string>();
|
||||
|
||||
if (grouped.length === 0) return null;
|
||||
|
||||
@ -27,7 +28,11 @@ export default function EventReactionButtons({ event, max }: { event: NostrEvent
|
||||
emoji={group.emoji}
|
||||
url={group.url}
|
||||
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}
|
||||
/>
|
||||
))}
|
||||
|
@ -87,9 +87,6 @@ export class NostrConnectClient {
|
||||
"#p": [this.publicKey],
|
||||
}),
|
||||
);
|
||||
|
||||
this.log("Secret Key:", this.secretKey);
|
||||
this.log("Public Key:", this.publicKey);
|
||||
}
|
||||
|
||||
async open() {
|
||||
@ -119,11 +116,11 @@ export class NostrConnectClient {
|
||||
try {
|
||||
const responseStr = await nip04.decrypt(this.secretKey, event.pubkey, event.content);
|
||||
const response = JSON.parse(responseStr);
|
||||
this.log("Got Response", response);
|
||||
if (response.id) {
|
||||
const p = this.requests.get(response.id);
|
||||
if (!p) return;
|
||||
if (response.error) {
|
||||
this.log("Got Error", response.id, response.result, response.error);
|
||||
if (response.result === "auth_url") {
|
||||
try {
|
||||
await this.handleAuthURL(response.error);
|
||||
@ -132,7 +129,7 @@ export class NostrConnectClient {
|
||||
}
|
||||
} else p.reject(response);
|
||||
} else if (response.result) {
|
||||
this.log(response.id, response.result);
|
||||
this.log("Got Response", response.id, response.result);
|
||||
p.resolve(response.result);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user