small fixes

This commit is contained in:
hzrd149 2024-08-04 10:02:27 -05:00
parent 1b7799dd7d
commit 9029bce7a2
3 changed files with 11 additions and 19 deletions

View File

@ -14,10 +14,12 @@ export default class PersistentSubscription {
relay: Relay;
filters: Filter[];
closed = true;
eosed = false;
params: Partial<SubscriptionParams>;
subscription: Subscription | null = null;
get eosed() {
return !!this.subscription?.eosed;
}
constructor(relay: AbstractRelay, params?: Partial<SubscriptionParams>) {
this.id = nanoid(8);
@ -40,17 +42,10 @@ export default class PersistentSubscription {
if (!(await relayPoolService.waitForOpen(this.relay))) return;
// recreate the subscription since nostream and other relays reject subscription updates
// if (this.subscription?.closed === false) {
// this.closed = true;
// this.subscription.close();
// }
// check if its possible to subscribe to this relay
if (!relayPoolService.canSubscribe(this.relay)) return;
this.closed = false;
this.eosed = false;
this.process.active = true;
// recreate the subscription if its closed since nostr-tools cant reopen a sub
@ -58,14 +53,10 @@ export default class PersistentSubscription {
this.subscription = this.relay.subscribe(this.filters, {
...this.params,
oneose: () => {
this.eosed = true;
this.params.oneose?.();
},
onclose: (reason) => {
if (!this.closed) {
// unexpected close, reconnect?
// console.log("Unexpected closed", this.relay, reason);
relayPoolService.handleRelayNotice(this.relay, reason);
this.closed = true;

View File

@ -1,8 +1,9 @@
import { useDisclosure } from "@chakra-ui/react";
import { useLocalStorage } from "react-use";
export default function useLocalStorageDisclosure(name: string) {
const [value, setValue] = useLocalStorage<boolean>(name);
export default function useLocalStorageDisclosure(name: string, defaultIsOpen?: boolean) {
const [value, setValue] = useLocalStorage<boolean>(name, defaultIsOpen);
return useDisclosure({
isOpen: value,
onOpen: () => setValue(true),

View File

@ -95,11 +95,11 @@ const NotificationsTimeline = memo(
function NotificationsPage() {
const { timeline } = useNotifications();
const showReplies = useLocalStorageDisclosure("notifications-show-replies");
const showMentions = useLocalStorageDisclosure("notifications-show-mentions");
const showZaps = useLocalStorageDisclosure("notifications-show-zaps");
const showReposts = useLocalStorageDisclosure("notifications-show-reposts");
const showReactions = useLocalStorageDisclosure("notifications-show-reactions");
const showReplies = useLocalStorageDisclosure("notifications-show-replies", true);
const showMentions = useLocalStorageDisclosure("notifications-show-mentions", true);
const showZaps = useLocalStorageDisclosure("notifications-show-zaps", true);
const showReposts = useLocalStorageDisclosure("notifications-show-reposts", true);
const showReactions = useLocalStorageDisclosure("notifications-show-reactions", true);
const today = dayjs().format(DATE_FORMAT);
const { value: day, setValue: setDay } = useRouteSearchValue(