Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renew bootstrap relays #89

Merged
merged 3 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"preview": "vite preview",
"lint": "run-p type-check lint:*",
"lint:eslint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
"lint:prettier": "prettier --check --loglevel warn src/**/*.{ts,tsx}",
"lint:prettier": "prettier --check --log-level warn src/**/*.{ts,tsx}",
"fix": "run-s fix:*",
"fix:eslint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0 --fix",
"fix:prettier": "prettier --check --loglevel warn src/**/*.{ts,tsx} --write",
"fix:prettier": "prettier --check --log-level warn src/**/*.{ts,tsx} --write",
"i18n-extract": "i18next src/**/*.tsx --config i18next-parser.config.js"
},
"dependencies": {
Expand Down Expand Up @@ -64,6 +64,7 @@
"eslint-plugin-react-refresh": "^0.4.3",
"i18next-parser": "^8.9.0",
"npm-run-all2": "^6.1.0",
"prettier": "^3.1.1",
"tsx": "^4.7.0",
"typescript": "^5.0.2",
"vite": "^5.0.10"
Expand Down
2 changes: 1 addition & 1 deletion src/components/ShareMusicDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const musicDataLoadableAtom = loadable(
return Promise.resolve(undefined);
}
return fetchMusicData(musicLink);
})
}),
);

type ShareMusicDialogProps = {
Expand Down
2 changes: 1 addition & 1 deletion src/components/UserStatusList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const UserStatusList = forwardRef<UserStatusListHandle>(function UserStat
},
};
},
[]
[],
);

const { t } = useTranslation();
Expand Down
2 changes: 1 addition & 1 deletion src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ import "./index.css";
ReactDOM.createRoot(document.getElementById("root")!).render(
<React.StrictMode>
<App />
</React.StrictMode>
</React.StrictMode>,
);
21 changes: 10 additions & 11 deletions src/states/nostr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export const userProfileAtomFamily = atomFamily((pubkey: string) => {
},
(a, b) => {
return a.srcEventId === b.srcEventId;
}
},
);
});

Expand All @@ -170,7 +170,7 @@ export const userStatusAtomFamily = atomFamily((pubkey: string) => {
return a === b;
}
return UserStatus.contentId(a) === UserStatus.contentId(b);
}
},
);
});

Expand Down Expand Up @@ -223,12 +223,11 @@ const pubkeyInNostrExtAtomBase = loadable(
return window.nostr.getPublicKey();
}
return Promise.resolve(undefined);
})
}),
);

const pubkeyInNostrExtAtom = atom((get) => {
const pkLoadable = get(pubkeyInNostrExtAtomBase);
console.log(pkLoadable);
return pkLoadable.state === "hasData" ? pkLoadable.data : undefined;
});

Expand All @@ -250,7 +249,7 @@ const bootstrapFetcher = NostrFetcher.init();
const rxNostr = createRxNostr();
const fetcherOnRxNostr = NostrFetcher.withCustomPool(rxNostrAdapter(rxNostr));

const defaultBootstrapRelays = ["wss://relay.nostr.band", "wss://relayable.org", "wss://directory.yabu.me"];
const defaultBootstrapRelays = ["wss://relay.nostr.band", "wss://directory.yabu.me", "wss://purplepag.es"];

const fallbackRelayList: RelayList = {
"wss://relay.nostr.band": { read: true, write: true },
Expand Down Expand Up @@ -303,9 +302,9 @@ export const fetchAccountData = async (pubkey: string): Promise<AccountMetadata>
authors: [pubkey],
kinds: [kind],
},
{ connectTimeoutMs: 3000 }
)
)
{ connectTimeoutMs: 3000 },
),
),
);
if (!isDefault && (k0 === undefined || [k3, k10002].every((ev) => ev === undefined))) {
// if some of event are not found in relays from NIP-07 ext, fallback to default relays
Expand Down Expand Up @@ -453,7 +452,7 @@ jotaiStore.sub(bootstrapFinishedAtom, async () => {
const iter = fetcherOnRxNostr.fetchLastEventPerAuthor(
{ authors: cacheMissPubkeys, relayUrls: readRelays },
{ kinds: [0] },
{ abortSignal: fetchProfilesAbortCtrl.signal, connectTimeoutMs: 3000 }
{ abortSignal: fetchProfilesAbortCtrl.signal, connectTimeoutMs: 3000 },
);

const newProfiles: UserProfile[] = [];
Expand Down Expand Up @@ -661,14 +660,14 @@ const fetchPastStatuses = async (
pubkeys: string[],
readRelays: string[],
since: number | undefined,
myPubkey: string
myPubkey: string,
): Promise<boolean> => {
fetchPastStatusesAbortCtrl = new AbortController();
const pastStatusEvIter = fetcherOnRxNostr.allEventsIterator(
readRelays,
{ kinds: [30315], authors: pubkeys, "#d": ["general", "music"] },
{ since },
{ abortSignal: fetchPastStatusesAbortCtrl.signal, connectTimeoutMs: 3000 }
{ abortSignal: fetchPastStatusesAbortCtrl.signal, connectTimeoutMs: 3000 },
);

// save statuses cache periodically
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3635,6 +3635,11 @@ prettier@^2.8.8:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.8.tgz#e8c5d7e98a4305ffe3de2e1fc4aca1a71c28b1da"
integrity sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==

prettier@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.1.1.tgz#6ba9f23165d690b6cbdaa88cb0807278f7019848"
integrity sha512-22UbSzg8luF4UuZtzgiUOfcGM8s4tjBv6dJRT7j275NXsy2jb4aJa4NNveul5x4eqlF1wuhuR2RElK71RvmVaw==

process-nextick-args@~2.0.0:
version "2.0.1"
resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2"
Expand Down