Browse Source

Merge branch 'issue#173-events-and-lightning' of ssh://onedev.gitcitadel.eu:6611/Alexandria/gc-alexandria into issue#173-events-and-lightning

master
Silberengel 10 months ago
parent
commit
1d3eb36f89
  1. 7402
      package-lock.json
  2. 2
      src/lib/components/Navigation.svelte
  3. 10
      src/lib/consts.ts
  4. 6
      src/lib/ndk.ts
  5. 8
      src/lib/utils/nostrUtils.ts

7402
package-lock.json generated

File diff suppressed because it is too large Load Diff

2
src/lib/components/Navigation.svelte

@ -24,9 +24,9 @@ @@ -24,9 +24,9 @@
</div>
<NavUl class="ul-leather">
<NavLi href="/">Publications</NavLi>
<NavLi href="/events">Events</NavLi>
<NavLi href="/visualize">Visualize</NavLi>
<NavLi href="/start">Getting Started</NavLi>
<NavLi href="/events">Events</NavLi>
<NavLi href="/about">About</NavLi>
<NavLi href="/contact">Contact</NavLi>
<NavLi>

10
src/lib/consts.ts

@ -1,8 +1,16 @@ @@ -1,8 +1,16 @@
export const wikiKind = 30818;
export const indexKind = 30040;
export const zettelKinds = [ 30041, 30818 ];
export const communityRelay = [ 'wss://theforest.nostr1.com' ];
export const standardRelays = [ 'wss://thecitadel.nostr1.com', 'wss://theforest.nostr1.com' ];
export const bootstrapRelays = [ 'wss://purplepag.es', 'wss://relay.noswhere.com' , 'wss://relay.damus.io', 'wss://relay.nostr.band'];
export const fallbackRelays = [
'wss://purplepag.es',
'wss://indexer.coracle.social',
'wss://relay.noswhere.com',
'wss://relay.damus.io',
'wss://relay.nostr.band',
'wss://relay.lumina.rocks'
];
export enum FeedType {
StandardRelays = 'standard',

6
src/lib/ndk.ts

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
import NDK, { NDKNip07Signer, NDKRelay, NDKRelayAuthPolicies, NDKRelaySet, NDKUser } from '@nostr-dev-kit/ndk';
import { get, writable, type Writable } from 'svelte/store';
import { bootstrapRelays, FeedType, loginStorageKey, standardRelays } from './consts';
import { fallbackRelays, FeedType, loginStorageKey, standardRelays } from './consts';
import { feedType } from './stores';
export const ndkInstance: Writable<NDK> = writable();
@ -199,7 +199,7 @@ export function logout(user: NDKUser): void { @@ -199,7 +199,7 @@ export function logout(user: NDKUser): void {
async function getUserPreferredRelays(
ndk: NDK,
user: NDKUser,
bootstraps: readonly string[] = bootstrapRelays
fallbacks: readonly string[] = fallbackRelays
): Promise<[Set<NDKRelay>, Set<NDKRelay>]> {
const relayList = await ndk.fetchEvent(
{
@ -211,7 +211,7 @@ async function getUserPreferredRelays( @@ -211,7 +211,7 @@ async function getUserPreferredRelays(
skipVerification: false,
skipValidation: false,
},
NDKRelaySet.fromRelayUrls(bootstraps, ndk),
NDKRelaySet.fromRelayUrls(fallbacks, ndk),
);
const inboxRelays = new Set<NDKRelay>();

8
src/lib/utils/nostrUtils.ts

@ -4,7 +4,7 @@ import { ndkInstance } from '$lib/ndk'; @@ -4,7 +4,7 @@ import { ndkInstance } from '$lib/ndk';
import { npubCache } from './npubCache';
import NDK, { NDKEvent, NDKRelaySet, NDKUser } from "@nostr-dev-kit/ndk";
import type { NDKFilter, NDKKind } from "@nostr-dev-kit/ndk";
import { standardRelays, bootstrapRelays } from "$lib/consts";
import { standardRelays, fallbackRelays } from "$lib/consts";
const badgeCheckSvg = '<svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 2c-.791 0-1.55.314-2.11.874l-.893.893a.985.985 0 0 1-.696.288H7.04A2.984 2.984 0 0 0 4.055 7.04v1.262a.986.986 0 0 1-.288.696l-.893.893a2.984 2.984 0 0 0 0 4.22l.893.893a.985.985 0 0 1 .288.696v1.262a2.984 2.984 0 0 0 2.984 2.984h1.262c.261 0 .512.104.696.288l.893.893a2.984 2.984 0 0 0 4.22 0l.893-.893a.985.985 0 0 1 .696-.288h1.262a2.984 2.984 0 0 0 2.984-2.984V15.7c0-.261.104-.512.288-.696l.893-.893a2.984 2.984 0 0 0 0-4.22l-.893-.893a.985.985 0 0 1-.288-.696V7.04a2.984 2.984 0 0 0-2.984-2.984h-1.262a.985.985 0 0 1-.696-.288l-.893-.893A2.984 2.984 0 0 0 12 2Zm3.683 7.73a1 1 0 1 0-1.414-1.413l-4.253 4.253-1.277-1.277a1 1 0 0 0-1.415 1.414l1.985 1.984a1 1 0 0 0 1.414 0l4.96-4.96Z" clip-rule="evenodd"/></svg>'
@ -306,7 +306,7 @@ export async function fetchEventWithFallback( @@ -306,7 +306,7 @@ export async function fetchEventWithFallback(
const relaySets = [
NDKRelaySet.fromRelayUrls(standardRelays, ndk), // 1. Standard relays
NDKRelaySet.fromRelayUrls(userRelays, ndk), // 2. User relays (if logged in)
NDKRelaySet.fromRelayUrls(bootstrapRelays, ndk) // 3. Bootstrap relays (last resort)
NDKRelaySet.fromRelayUrls(fallbackRelays, ndk) // 3. fallback relays (last resort)
];
try {
@ -331,7 +331,7 @@ export async function fetchEventWithFallback( @@ -331,7 +331,7 @@ export async function fetchEventWithFallback(
for (const [index, relaySet] of relaySets.entries()) {
const setName = index === 0 ? 'standard relays' :
index === 1 ? 'user relays' :
'bootstrap relays';
'fallback relays';
found = await tryFetchFromRelaySet(relaySet, setName);
if (found) break;
@ -342,7 +342,7 @@ export async function fetchEventWithFallback( @@ -342,7 +342,7 @@ export async function fetchEventWithFallback(
const relayUrls = relaySets.map((set, i) => {
const setName = i === 0 ? 'standard relays' :
i === 1 ? 'user relays' :
'bootstrap relays';
'fallback relays';
const urls = Array.from(set.relays).map(r => r.url);
return urls.length > 0 ? `${setName} (${urls.join(', ')})` : null;
}).filter(Boolean).join(', then ');

Loading…
Cancel
Save