|
|
|
@ -5,7 +5,7 @@ import { |
|
|
|
relayFilterIncludesSocialKindBlockedKind |
|
|
|
relayFilterIncludesSocialKindBlockedKind |
|
|
|
} from '@/constants' |
|
|
|
} from '@/constants' |
|
|
|
import type { TFeedSubRequest } from '@/types' |
|
|
|
import type { TFeedSubRequest } from '@/types' |
|
|
|
import { normalizeUrl } from '@/lib/url' |
|
|
|
import { normalizeAnyRelayUrl, normalizeUrl } from '@/lib/url' |
|
|
|
import { |
|
|
|
import { |
|
|
|
buildPrioritizedReadRelayUrls, |
|
|
|
buildPrioritizedReadRelayUrls, |
|
|
|
buildReadRelayPriorityLayers, |
|
|
|
buildReadRelayPriorityLayers, |
|
|
|
@ -14,10 +14,9 @@ import { |
|
|
|
mergeRelayPriorityLayers, |
|
|
|
mergeRelayPriorityLayers, |
|
|
|
relayUrlsLocalsFirst |
|
|
|
relayUrlsLocalsFirst |
|
|
|
} from '@/lib/relay-url-priority' |
|
|
|
} from '@/lib/relay-url-priority' |
|
|
|
import { normalizeAnyRelayUrl } from '@/lib/url' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const blockedSet = (blockedRelays: string[]) => |
|
|
|
const blockedSet = (blockedRelays: string[]) => |
|
|
|
new Set(blockedRelays.map((b) => normalizeUrl(b) || b)) |
|
|
|
new Set(blockedRelays.map((b) => normalizeAnyRelayUrl(b) || b)) |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Logged-in user’s favorite relays (kind 10012 `relay` tags via {@link useFavoriteRelays}, plus bootstrap defaults |
|
|
|
* Logged-in user’s favorite relays (kind 10012 `relay` tags via {@link useFavoriteRelays}, plus bootstrap defaults |
|
|
|
@ -42,14 +41,14 @@ export function getFavoritesFeedRelayUrls( |
|
|
|
): string[] { |
|
|
|
): string[] { |
|
|
|
const blocked = blockedSet(blockedRelays) |
|
|
|
const blocked = blockedSet(blockedRelays) |
|
|
|
const visible = favoriteRelays.filter((r) => { |
|
|
|
const visible = favoriteRelays.filter((r) => { |
|
|
|
const k = normalizeUrl(r) || r |
|
|
|
const k = normalizeAnyRelayUrl(r) || r |
|
|
|
return k && !blocked.has(k) |
|
|
|
return k && !blocked.has(k) |
|
|
|
}) |
|
|
|
}) |
|
|
|
const base = visible.length > 0 ? visible : DEFAULT_FAVORITE_RELAYS |
|
|
|
const base = visible.length > 0 ? visible : DEFAULT_FAVORITE_RELAYS |
|
|
|
const seen = new Set<string>() |
|
|
|
const seen = new Set<string>() |
|
|
|
const out: string[] = [] |
|
|
|
const out: string[] = [] |
|
|
|
for (const u of base) { |
|
|
|
for (const u of base) { |
|
|
|
const k = normalizeUrl(u) || u |
|
|
|
const k = normalizeAnyRelayUrl(u) || u |
|
|
|
if (!k || seen.has(k)) continue |
|
|
|
if (!k || seen.has(k)) continue |
|
|
|
seen.add(k) |
|
|
|
seen.add(k) |
|
|
|
out.push(k) |
|
|
|
out.push(k) |
|
|
|
@ -66,7 +65,7 @@ export function mergeRelayUrlLayers(layers: string[][], blockedRelays: string[]) |
|
|
|
const out: string[] = [] |
|
|
|
const out: string[] = [] |
|
|
|
for (const layer of layers) { |
|
|
|
for (const layer of layers) { |
|
|
|
for (const u of layer) { |
|
|
|
for (const u of layer) { |
|
|
|
const k = normalizeUrl(u) || u |
|
|
|
const k = normalizeAnyRelayUrl(u) || u |
|
|
|
if (!k || blocked.has(k) || seen.has(k)) continue |
|
|
|
if (!k || blocked.has(k) || seen.has(k)) continue |
|
|
|
seen.add(k) |
|
|
|
seen.add(k) |
|
|
|
out.push(k) |
|
|
|
out.push(k) |
|
|
|
@ -80,11 +79,17 @@ export function mergeRelayUrlLayers(layers: string[][], blockedRelays: string[]) |
|
|
|
* stripped. Used for profile pins + Medien before {@link buildProfileAugmentedReadRelayUrls}. |
|
|
|
* stripped. Used for profile pins + Medien before {@link buildProfileAugmentedReadRelayUrls}. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
export function buildAuthorInboxOutboxRelayUrls( |
|
|
|
export function buildAuthorInboxOutboxRelayUrls( |
|
|
|
authorRelayList: { read: string[]; write: string[] }, |
|
|
|
authorRelayList: { read: string[]; write: string[]; httpRead?: string[]; httpWrite?: string[] }, |
|
|
|
blockedRelays: string[] |
|
|
|
blockedRelays: string[] |
|
|
|
): string[] { |
|
|
|
): string[] { |
|
|
|
const inboxLayer = relayUrlsLocalsFirst(authorRelayList.read ?? []) |
|
|
|
const inboxLayer = relayUrlsLocalsFirst([ |
|
|
|
const outboxLayer = relayUrlsLocalsFirst(authorRelayList.write ?? []) |
|
|
|
...(authorRelayList.httpRead ?? []), |
|
|
|
|
|
|
|
...(authorRelayList.read ?? []) |
|
|
|
|
|
|
|
]) |
|
|
|
|
|
|
|
const outboxLayer = relayUrlsLocalsFirst([ |
|
|
|
|
|
|
|
...(authorRelayList.httpWrite ?? []), |
|
|
|
|
|
|
|
...(authorRelayList.write ?? []) |
|
|
|
|
|
|
|
]) |
|
|
|
return mergeRelayUrlLayers([inboxLayer, outboxLayer], blockedRelays) |
|
|
|
return mergeRelayUrlLayers([inboxLayer, outboxLayer], blockedRelays) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -161,15 +166,15 @@ export const PROFILE_PAGE_PINS_RESOLVE_LIMIT = 10 |
|
|
|
export function buildProfilePageReadRelayUrls( |
|
|
|
export function buildProfilePageReadRelayUrls( |
|
|
|
favoriteRelays: string[], |
|
|
|
favoriteRelays: string[], |
|
|
|
blockedRelays: string[], |
|
|
|
blockedRelays: string[], |
|
|
|
authorRelayList: { read: string[]; write: string[] }, |
|
|
|
authorRelayList: { read: string[]; write: string[]; httpRead?: string[]; httpWrite?: string[] }, |
|
|
|
kindsIncludeSocialBlockedKind: boolean |
|
|
|
kindsIncludeSocialBlockedKind: boolean |
|
|
|
): string[] { |
|
|
|
): string[] { |
|
|
|
return getRelayUrlsWithFavoritesFastReadAndInbox( |
|
|
|
return getRelayUrlsWithFavoritesFastReadAndInbox( |
|
|
|
favoriteRelays, |
|
|
|
favoriteRelays, |
|
|
|
blockedRelays, |
|
|
|
blockedRelays, |
|
|
|
authorRelayList.read ?? [], |
|
|
|
[...(authorRelayList.httpRead ?? []), ...(authorRelayList.read ?? [])], |
|
|
|
{ |
|
|
|
{ |
|
|
|
userWriteRelays: authorRelayList.write ?? [], |
|
|
|
userWriteRelays: [...(authorRelayList.httpWrite ?? []), ...(authorRelayList.write ?? [])], |
|
|
|
authorWriteRelays: [], |
|
|
|
authorWriteRelays: [], |
|
|
|
maxRelays: PROFILE_PAGE_FEED_MAX_RELAYS, |
|
|
|
maxRelays: PROFILE_PAGE_FEED_MAX_RELAYS, |
|
|
|
applySocialKindBlockedFilter: kindsIncludeSocialBlockedKind |
|
|
|
applySocialKindBlockedFilter: kindsIncludeSocialBlockedKind |
|
|
|
|