mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-04-05 02:20:26 +02:00
Fix follow and mute button not updating when switching accounts
This commit is contained in:
parent
af973af93e
commit
d5a50d0c6f
5
.changeset/wet-plants-joke.md
Normal file
5
.changeset/wet-plants-joke.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"nostrudel": patch
|
||||
---
|
||||
|
||||
Fix follow and mute button not updating when switching accounts
|
@ -34,7 +34,6 @@ import useUserContactList from "../hooks/use-user-contact-list";
|
||||
import replaceableEventLoaderService from "../services/replaceable-event-requester";
|
||||
import useAsyncErrorHandler from "../hooks/use-async-error-handler";
|
||||
import NewListModal from "../views/lists/components/new-list-modal";
|
||||
import useUserMuteList from "../hooks/use-user-mute-list";
|
||||
import useUserMuteFunctions from "../hooks/use-user-mute-functions";
|
||||
|
||||
function UsersLists({ pubkey }: { pubkey: string }) {
|
||||
@ -129,13 +128,13 @@ export const UserFollowButton = ({ pubkey, showLists, ...props }: UserFollowButt
|
||||
const signed = await requestSignature(draft);
|
||||
const pub = new NostrPublishAction("Follow", clientRelaysService.getWriteUrls(), signed);
|
||||
replaceableEventLoaderService.handleEvent(signed);
|
||||
});
|
||||
}, [contacts, requestSignature]);
|
||||
const handleUnfollow = useAsyncErrorHandler(async () => {
|
||||
const draft = draftRemovePerson(contacts || createEmptyContactList(), pubkey);
|
||||
const signed = await requestSignature(draft);
|
||||
const pub = new NostrPublishAction("Unfollow", clientRelaysService.getWriteUrls(), signed);
|
||||
replaceableEventLoaderService.handleEvent(signed);
|
||||
});
|
||||
}, [contacts, requestSignature]);
|
||||
|
||||
if (showLists) {
|
||||
return (
|
||||
|
@ -3,7 +3,7 @@ import { DependencyList, useCallback } from "react";
|
||||
|
||||
export default function useAsyncErrorHandler<T = any>(
|
||||
fn: () => Promise<T>,
|
||||
deps: DependencyList = [],
|
||||
deps: DependencyList,
|
||||
): () => Promise<T | undefined> {
|
||||
const toast = useToast();
|
||||
|
||||
|
@ -19,13 +19,13 @@ export default function useUserMuteFunctions(pubkey: string) {
|
||||
const signed = await requestSignature(draft);
|
||||
new NostrPublishAction("Mute", clientRelaysService.getWriteUrls(), signed);
|
||||
replaceableEventLoaderService.handleEvent(signed);
|
||||
});
|
||||
}, [requestSignature, muteList]);
|
||||
const unmute = useAsyncErrorHandler(async () => {
|
||||
const draft = draftRemovePerson(muteList || createEmptyMuteList(), pubkey);
|
||||
const signed = await requestSignature(draft);
|
||||
new NostrPublishAction("Unmute", clientRelaysService.getWriteUrls(), signed);
|
||||
replaceableEventLoaderService.handleEvent(signed);
|
||||
});
|
||||
}, [requestSignature, muteList]);
|
||||
|
||||
return { isMuted, mute, unmute };
|
||||
}
|
||||
|
@ -26,6 +26,7 @@ import RelaySelectionProvider, { useRelaySelectionRelays } from "../../providers
|
||||
import useRelaysChanged from "../../hooks/use-relays-changed";
|
||||
import TimelinePage, { useTimelinePageEventFilter } from "../../components/timeline-page";
|
||||
import TimelineViewTypeButtons from "../../components/timeline-page/timeline-view-type";
|
||||
import useClientSideMuteFilter from "../../hooks/use-client-side-mute-filter";
|
||||
|
||||
function EditableControls() {
|
||||
const { isEditing, getSubmitButtonProps, getCancelButtonProps, getEditButtonProps } = useEditableControls();
|
||||
@ -52,12 +53,14 @@ function HashTagPage() {
|
||||
const { isOpen: showReplies, onToggle } = useDisclosure();
|
||||
|
||||
const timelinePageEventFilter = useTimelinePageEventFilter();
|
||||
const muteFilter = useClientSideMuteFilter();
|
||||
const eventFilter = useCallback(
|
||||
(event: NostrEvent) => {
|
||||
if (muteFilter(event)) return false;
|
||||
if (!showReplies && isReply(event)) return false;
|
||||
return timelinePageEventFilter(event);
|
||||
},
|
||||
[showReplies],
|
||||
[showReplies, muteFilter, timelinePageEventFilter],
|
||||
);
|
||||
const timeline = useTimelineLoader(
|
||||
`${hashtag}-hashtag`,
|
||||
|
@ -26,7 +26,7 @@ export default function UserCard({ pubkey, relay, list, ...props }: UserCardProp
|
||||
const draft = draftRemovePerson(list, pubkey);
|
||||
const signed = await requestSignature(draft);
|
||||
const pub = new NostrPublishAction("Remove from list", clientRelaysService.getWriteUrls(), signed);
|
||||
}, [list]);
|
||||
}, [list, requestSignature]);
|
||||
|
||||
return (
|
||||
<Card>
|
||||
|
Loading…
x
Reference in New Issue
Block a user