Bump welshman
This commit is contained in:
+7
-21
@@ -11,7 +11,7 @@ import {PublishStatus} from "@welshman/net"
|
||||
import {
|
||||
pubkey,
|
||||
repository,
|
||||
loadOne,
|
||||
load,
|
||||
makeThunk,
|
||||
publishThunk,
|
||||
loadProfile,
|
||||
@@ -56,26 +56,12 @@ export const makeIMeta = (url: string, data: Record<string, string>) => [
|
||||
|
||||
// Loaders
|
||||
|
||||
export const loadUserData = async (pubkey: string, hints: string[] = []) => {
|
||||
const relaySelections = await loadRelaySelections(pubkey, INDEXER_RELAYS)
|
||||
const relays = uniq([
|
||||
...getRelayTagValues(relaySelections?.tags || []),
|
||||
...INDEXER_RELAYS,
|
||||
...hints,
|
||||
export const loadUserData = (pubkey: string, hints: string[] = []) =>
|
||||
Promise.all([
|
||||
loadProfile(pubkey),
|
||||
loadFollows(pubkey),
|
||||
loadMutes(pubkey),
|
||||
])
|
||||
const membership = await loadGroupMembership(pubkey, relays)
|
||||
const promises = [
|
||||
loadProfile(pubkey, relays),
|
||||
loadFollows(pubkey, relays),
|
||||
loadMutes(pubkey, relays),
|
||||
]
|
||||
|
||||
for (const [_, nom, url] of getGroupTags(membership?.event.tags || [])) {
|
||||
promises.push(loadGroup(nom, [url]))
|
||||
}
|
||||
|
||||
await Promise.all(promises)
|
||||
}
|
||||
|
||||
// Updates
|
||||
|
||||
@@ -110,7 +96,7 @@ export const sendJoinRequest = async (nom: string, url: string): Promise<[boolea
|
||||
|
||||
if (message.includes("already a member")) return [true, ""]
|
||||
if (status !== PublishStatus.Success) return [false, message]
|
||||
if (await loadOne({filters, relays})) return [true, ""]
|
||||
if (await load({filters, relays})) return [true, ""]
|
||||
|
||||
return [
|
||||
false,
|
||||
|
||||
+14
-3
@@ -1,7 +1,7 @@
|
||||
import type {FuseResult} from "fuse.js"
|
||||
import {get, derived} from "svelte/store"
|
||||
import type {Maybe} from "@welshman/lib"
|
||||
import {max, between, groupBy, pushToMapKey, nthEq, stripProtocol, indexBy} from "@welshman/lib"
|
||||
import {setContext, max, between, groupBy, pushToMapKey, nthEq, stripProtocol, indexBy} from "@welshman/lib"
|
||||
import {
|
||||
getIdFilters,
|
||||
getIdentifier,
|
||||
@@ -16,7 +16,6 @@ import {
|
||||
} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {
|
||||
env,
|
||||
pubkey,
|
||||
repository,
|
||||
createSearch,
|
||||
@@ -28,6 +27,9 @@ import {
|
||||
profilesByPubkey,
|
||||
loadRelaySelections,
|
||||
getWriteRelayUrls,
|
||||
getDefaultAppContext,
|
||||
getDefaultNetContext,
|
||||
makeRouter,
|
||||
} from "@welshman/app"
|
||||
import type {Relay} from "@welshman/app"
|
||||
import type {SubscribeRequest} from "@welshman/net"
|
||||
@@ -46,7 +48,16 @@ export const DUFFLEPUD_URL = "https://dufflepud.onrender.com"
|
||||
|
||||
export const REACTION_KINDS = [REACTION, ZAP_RESPONSE]
|
||||
|
||||
Object.assign(env, {DUFFLEPUD_URL})
|
||||
setContext({
|
||||
net: getDefaultNetContext(),
|
||||
app: getDefaultAppContext({
|
||||
dufflepudUrl: DUFFLEPUD_URL,
|
||||
indexerRelays: INDEXER_RELAYS,
|
||||
requestTimeout: 5000,
|
||||
router: makeRouter(),
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
export const deriveEvent = (idOrAddress: string, hints: string[] = []) => {
|
||||
let attempted = false
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
publishStatusData,
|
||||
plaintext,
|
||||
freshness,
|
||||
storageAdapters,
|
||||
} from "@welshman/app"
|
||||
import type {PublishStatusData, PublishStatusDataByUrlById} from "@welshman/app"
|
||||
import {createEventStore, adapter} from "@welshman/store"
|
||||
@@ -59,7 +60,7 @@
|
||||
onMount(() => {
|
||||
Object.assign(window, {get, state})
|
||||
|
||||
ready = initStorage(3, {
|
||||
ready = initStorage('flotilla', 3, {
|
||||
events: {
|
||||
keyPath: "id",
|
||||
store: createEventStore(repository),
|
||||
@@ -72,67 +73,9 @@
|
||||
keyPath: "nip05",
|
||||
store: handles,
|
||||
},
|
||||
publishStatus: {
|
||||
keyPath: "id",
|
||||
store: adapter({
|
||||
store: publishStatusData,
|
||||
forward: ($psd: PublishStatusDataByUrlById) => {
|
||||
const data = []
|
||||
|
||||
for (const itemsByUrl of Object.values($psd)) {
|
||||
for (const item of Object.values(itemsByUrl)) {
|
||||
data.push(item)
|
||||
}
|
||||
}
|
||||
|
||||
return data
|
||||
},
|
||||
backward: (data: PublishStatusData[]) => {
|
||||
const result: PublishStatusDataByUrlById = {}
|
||||
|
||||
for (const item of data) {
|
||||
result[item.id] = result[item.id] || {}
|
||||
result[item.id][item.url] = item
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
}),
|
||||
},
|
||||
freshness: {
|
||||
keyPath: "key",
|
||||
store: adapter({
|
||||
store: freshness,
|
||||
forward: ($freshness: Record<string, number>) =>
|
||||
Object.entries($freshness).map(([key, ts]) => ({key, ts})),
|
||||
backward: (data: any[]) => {
|
||||
const result: Record<string, number> = {}
|
||||
|
||||
for (const {key, ts} of data) {
|
||||
result[key] = ts
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
}),
|
||||
},
|
||||
plaintext: {
|
||||
keyPath: "id",
|
||||
store: adapter({
|
||||
store: plaintext,
|
||||
forward: ($plaintext: Record<string, string>) =>
|
||||
Object.entries($plaintext).map(([id, plaintext]) => ({id, plaintext})),
|
||||
backward: (data: any[]) => {
|
||||
const result: Record<string, string> = {}
|
||||
|
||||
for (const {id, plaintext} of data) {
|
||||
result[id] = plaintext
|
||||
}
|
||||
|
||||
return result
|
||||
},
|
||||
}),
|
||||
},
|
||||
publishStatus: storageAdapters.fromObjectStore(publishStatusData),
|
||||
freshness: storageAdapters.fromObjectStore(freshness),
|
||||
plaintext: storageAdapters.fromObjectStore(plaintext),
|
||||
}).then(() => sleep(300)) // Wait an extra few ms because of repository throttle
|
||||
|
||||
dialog.addEventListener("close", () => {
|
||||
|
||||
Reference in New Issue
Block a user