mirror of
https://github.com/hzrd149/nostrudel.git
synced 2025-09-20 21:12:38 +02:00
small fixes
This commit is contained in:
@@ -14,10 +14,12 @@ export default class PersistentSubscription {
|
|||||||
relay: Relay;
|
relay: Relay;
|
||||||
filters: Filter[];
|
filters: Filter[];
|
||||||
closed = true;
|
closed = true;
|
||||||
eosed = false;
|
|
||||||
params: Partial<SubscriptionParams>;
|
params: Partial<SubscriptionParams>;
|
||||||
|
|
||||||
subscription: Subscription | null = null;
|
subscription: Subscription | null = null;
|
||||||
|
get eosed() {
|
||||||
|
return !!this.subscription?.eosed;
|
||||||
|
}
|
||||||
|
|
||||||
constructor(relay: AbstractRelay, params?: Partial<SubscriptionParams>) {
|
constructor(relay: AbstractRelay, params?: Partial<SubscriptionParams>) {
|
||||||
this.id = nanoid(8);
|
this.id = nanoid(8);
|
||||||
@@ -40,17 +42,10 @@ export default class PersistentSubscription {
|
|||||||
|
|
||||||
if (!(await relayPoolService.waitForOpen(this.relay))) return;
|
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
|
// check if its possible to subscribe to this relay
|
||||||
if (!relayPoolService.canSubscribe(this.relay)) return;
|
if (!relayPoolService.canSubscribe(this.relay)) return;
|
||||||
|
|
||||||
this.closed = false;
|
this.closed = false;
|
||||||
this.eosed = false;
|
|
||||||
this.process.active = true;
|
this.process.active = true;
|
||||||
|
|
||||||
// recreate the subscription if its closed since nostr-tools cant reopen a sub
|
// 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.subscription = this.relay.subscribe(this.filters, {
|
||||||
...this.params,
|
...this.params,
|
||||||
oneose: () => {
|
oneose: () => {
|
||||||
this.eosed = true;
|
|
||||||
this.params.oneose?.();
|
this.params.oneose?.();
|
||||||
},
|
},
|
||||||
onclose: (reason) => {
|
onclose: (reason) => {
|
||||||
if (!this.closed) {
|
if (!this.closed) {
|
||||||
// unexpected close, reconnect?
|
|
||||||
// console.log("Unexpected closed", this.relay, reason);
|
|
||||||
|
|
||||||
relayPoolService.handleRelayNotice(this.relay, reason);
|
relayPoolService.handleRelayNotice(this.relay, reason);
|
||||||
|
|
||||||
this.closed = true;
|
this.closed = true;
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
import { useDisclosure } from "@chakra-ui/react";
|
import { useDisclosure } from "@chakra-ui/react";
|
||||||
import { useLocalStorage } from "react-use";
|
import { useLocalStorage } from "react-use";
|
||||||
|
|
||||||
export default function useLocalStorageDisclosure(name: string) {
|
export default function useLocalStorageDisclosure(name: string, defaultIsOpen?: boolean) {
|
||||||
const [value, setValue] = useLocalStorage<boolean>(name);
|
const [value, setValue] = useLocalStorage<boolean>(name, defaultIsOpen);
|
||||||
|
|
||||||
return useDisclosure({
|
return useDisclosure({
|
||||||
isOpen: value,
|
isOpen: value,
|
||||||
onOpen: () => setValue(true),
|
onOpen: () => setValue(true),
|
||||||
|
@@ -95,11 +95,11 @@ const NotificationsTimeline = memo(
|
|||||||
function NotificationsPage() {
|
function NotificationsPage() {
|
||||||
const { timeline } = useNotifications();
|
const { timeline } = useNotifications();
|
||||||
|
|
||||||
const showReplies = useLocalStorageDisclosure("notifications-show-replies");
|
const showReplies = useLocalStorageDisclosure("notifications-show-replies", true);
|
||||||
const showMentions = useLocalStorageDisclosure("notifications-show-mentions");
|
const showMentions = useLocalStorageDisclosure("notifications-show-mentions", true);
|
||||||
const showZaps = useLocalStorageDisclosure("notifications-show-zaps");
|
const showZaps = useLocalStorageDisclosure("notifications-show-zaps", true);
|
||||||
const showReposts = useLocalStorageDisclosure("notifications-show-reposts");
|
const showReposts = useLocalStorageDisclosure("notifications-show-reposts", true);
|
||||||
const showReactions = useLocalStorageDisclosure("notifications-show-reactions");
|
const showReactions = useLocalStorageDisclosure("notifications-show-reactions", true);
|
||||||
|
|
||||||
const today = dayjs().format(DATE_FORMAT);
|
const today = dayjs().format(DATE_FORMAT);
|
||||||
const { value: day, setValue: setDay } = useRouteSearchValue(
|
const { value: day, setValue: setDay } = useRouteSearchValue(
|
||||||
|
Reference in New Issue
Block a user