diff --git a/package.json b/package.json index a24ef0b..fe8eec7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@welshman", "private": true, - "version": "0.8.8", + "version": "0.8.9", "workspaces": [ "packages/*" ], diff --git a/packages/app/package.json b/packages/app/package.json index 681fbe2..87d0f6b 100644 --- a/packages/app/package.json +++ b/packages/app/package.json @@ -1,6 +1,6 @@ { "name": "@welshman/app", - "version": "0.8.8", + "version": "0.8.9", "author": "hodlbod", "license": "MIT", "description": "A collection of svelte stores for use in building nostr client applications.", diff --git a/packages/app/src/commands.ts b/packages/app/src/commands.ts index 41c490e..94e78e5 100644 --- a/packages/app/src/commands.ts +++ b/packages/app/src/commands.ts @@ -1,5 +1,5 @@ import {get} from "svelte/store" -import {uniq, now, nthNe, removeUndefined, nthEq} from "@welshman/lib" +import {uniq, reject, nth, now, nthNe, removeUndefined, nthEq} from "@welshman/lib" import { sendManagementRequest, ManagementRequest, @@ -104,6 +104,34 @@ export const setRelays = async (tags: string[][]) => { return publishThunk({event, relays}) } +export const setReadRelays = async (urls: string[]) => { + await forceLoadUserRelayList([]) + + const list = get(userRelayList) || makeList({kind: RELAYS}) + const writeRelays = reject(nthEq(2, RelayMode.Read), getRelayTags(getListTags(list))).map(nth(1)) + const writeTags = writeRelays.map(url => ["r", url, RelayMode.Write]) + const readTags = urls.map(url => ["r", url, RelayMode.Read]) + const tags = [...writeTags, ...readTags] + const event = {kind: list.kind, content: list.event?.content || "", tags} + const relays = Router.get().FromUser().policy(addMaximalFallbacks).getUrls() + + return publishThunk({event, relays}) +} + +export const setWriteRelays = async (urls: string[]) => { + await forceLoadUserRelayList([]) + + const list = get(userRelayList) || makeList({kind: RELAYS}) + const readRelays = reject(nthEq(2, RelayMode.Write), getRelayTags(getListTags(list))).map(nth(1)) + const readTags = readRelays.map(url => ["r", url, RelayMode.Read]) + const writeTags = urls.map(url => ["r", url, RelayMode.Write]) + const tags = [...readTags, ...writeTags] + const event = {kind: list.kind, content: list.event?.content || "", tags} + const relays = Router.get().FromUser().policy(addMaximalFallbacks).getUrls() + + return publishThunk({event, relays}) +} + // NIP 17 export const removeMessagingRelay = async (url: string) => { @@ -133,7 +161,7 @@ export const setMessagingRelays = async (urls: string[]) => { return publishThunk({event, relays}) } -// NIP 51 +// Blocked Relays export const removeBlockedRelay = async (url: string) => { await forceLoadUserBlockedRelayList([]) @@ -162,6 +190,8 @@ export const setBlockedRelays = async (urls: string[]) => { return publishThunk({event, relays}) } +// Search Relays + export const removeSearchRelay = async (url: string) => { await forceLoadUserSearchRelayList([]) diff --git a/packages/content/package.json b/packages/content/package.json index 3469bd6..38455cd 100644 --- a/packages/content/package.json +++ b/packages/content/package.json @@ -1,6 +1,6 @@ { "name": "@welshman/content", - "version": "0.8.8", + "version": "0.8.9", "author": "hodlbod", "license": "MIT", "description": "A collection of utilities for parsing nostr note content.", diff --git a/packages/editor/package.json b/packages/editor/package.json index f05aadc..04f1a1d 100644 --- a/packages/editor/package.json +++ b/packages/editor/package.json @@ -1,6 +1,6 @@ { "name": "@welshman/editor", - "version": "0.8.8", + "version": "0.8.9", "author": "hodlbod", "license": "MIT", "description": "A batteries-included nostr editor.", diff --git a/packages/feeds/package.json b/packages/feeds/package.json index 79c56ae..fd85f2f 100644 --- a/packages/feeds/package.json +++ b/packages/feeds/package.json @@ -1,6 +1,6 @@ { "name": "@welshman/feeds", - "version": "0.8.8", + "version": "0.8.9", "author": "hodlbod", "license": "MIT", "description": "Utilities for building dynamic nostr feeds.", diff --git a/packages/lib/package.json b/packages/lib/package.json index dcd175e..f5f2759 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -1,6 +1,6 @@ { "name": "@welshman/lib", - "version": "0.8.8", + "version": "0.8.9", "author": "hodlbod", "license": "MIT", "description": "A collection of utilities.", diff --git a/packages/net/package.json b/packages/net/package.json index b711cc2..652a238 100644 --- a/packages/net/package.json +++ b/packages/net/package.json @@ -1,6 +1,6 @@ { "name": "@welshman/net", - "version": "0.8.8", + "version": "0.8.9", "author": "hodlbod", "license": "MIT", "description": "Utilities for connecting with nostr relays.", diff --git a/packages/router/package.json b/packages/router/package.json index 2bdfc1b..34177b2 100644 --- a/packages/router/package.json +++ b/packages/router/package.json @@ -1,6 +1,6 @@ { "name": "@welshman/router", - "version": "0.8.8", + "version": "0.8.9", "author": "hodlbod", "license": "MIT", "description": "A collection of utilities for nostr relay selection.", diff --git a/packages/signer/package.json b/packages/signer/package.json index 474602f..9e11fc8 100644 --- a/packages/signer/package.json +++ b/packages/signer/package.json @@ -1,6 +1,6 @@ { "name": "@welshman/signer", - "version": "0.8.8", + "version": "0.8.9", "author": "hodlbod", "license": "MIT", "description": "A nostr signer implemenation supporting several login methods.", diff --git a/packages/store/package.json b/packages/store/package.json index 950fe09..2f20adb 100644 --- a/packages/store/package.json +++ b/packages/store/package.json @@ -1,6 +1,6 @@ { "name": "@welshman/store", - "version": "0.8.8", + "version": "0.8.9", "author": "hodlbod", "license": "MIT", "description": "A collection of utilities based on svelte/store for use with welshman", diff --git a/packages/util/package.json b/packages/util/package.json index 481be7a..77b4737 100644 --- a/packages/util/package.json +++ b/packages/util/package.json @@ -1,6 +1,6 @@ { "name": "@welshman/util", - "version": "0.8.8", + "version": "0.8.9", "author": "hodlbod", "license": "MIT", "description": "A collection of nostr-related utilities.",