mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 10:57:04 +00:00
Wait for auth before requesting stuff
This commit is contained in:
@@ -52,8 +52,7 @@ export const updateList = async (kind: number, modifyTags: ModifyTags) => {
|
||||
const $pk = pk.get()!
|
||||
const $signer = signer.get()!
|
||||
const [prev] = repository.query([{kinds: [kind], authors: [$pk]}])
|
||||
const userRelays = getRelaySelectionsByPubkey().get($pk)
|
||||
const relays = [...INDEXER_RELAYS, ...getWriteRelayUrls(userRelays)]
|
||||
const relays = getWriteRelayUrls(getRelaySelectionsByPubkey().get($pk))
|
||||
|
||||
// Preserve content if we have it
|
||||
const event = prev
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
['fuchsia', twColors.fuchsia[600]],
|
||||
['green', twColors.green[600]],
|
||||
['indigo', twColors.indigo[600]],
|
||||
['lightBlue', twColors.lightBlue[600]],
|
||||
['sky', twColors.sky[600]],
|
||||
['lime', twColors.lime[600]],
|
||||
['orange', twColors.orange[600]],
|
||||
['pink', twColors.pink[600]],
|
||||
|
||||
@@ -36,8 +36,8 @@ import {
|
||||
GROUP_ADD_USER,
|
||||
} from "@welshman/util"
|
||||
import type {SignedEvent, HashedEvent, EventTemplate, TrustedEvent, PublishedProfile, PublishedList} from "@welshman/util"
|
||||
import type {SubscribeRequest, PublishRequest, PublishStatus} from "@welshman/net"
|
||||
import {publish as basePublish, subscribe as baseSubscribe} from "@welshman/net"
|
||||
import type {SubscribeRequest, PublishRequest} from "@welshman/net"
|
||||
import {publish as basePublish, subscribe as baseSubscribe, PublishStatus} from "@welshman/net"
|
||||
import {decrypt, stamp, own, hash} from "@welshman/signer"
|
||||
import {deriveEvents, deriveEventsMapped, getter, withGetter} from "@welshman/store"
|
||||
import {createSearch} from "@lib/util"
|
||||
@@ -143,9 +143,19 @@ thunkWorker.addGlobalHandler(async ({event, relays}: Thunk) => {
|
||||
savedEvent.sig = signedEvent.sig
|
||||
}
|
||||
|
||||
const failures = new Set<string>()
|
||||
|
||||
// Watch for failures
|
||||
pub.emitter.on('*', (status: PublishStatus, url: string) => {
|
||||
console.log('pub status', status, url)
|
||||
|
||||
if ([PublishStatus.Failure, PublishStatus.Timeout].includes(status)) {
|
||||
failures.add(url)
|
||||
}
|
||||
|
||||
if (failures.size === relays.length) {
|
||||
console.warn("Failed to publish", pub)
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -172,7 +182,7 @@ export const publishThunk = (thunk: Thunk) => {
|
||||
// Subscribe
|
||||
|
||||
export const subscribe = (request: SubscribeRequest) => {
|
||||
const sub = baseSubscribe({delay: 50, ...request})
|
||||
const sub = baseSubscribe({delay: 50, authTimeout: 3000, ...request})
|
||||
|
||||
sub.emitter.on("event", (url: string, e: SignedEvent) => repository.publish(e))
|
||||
|
||||
|
||||
@@ -41,14 +41,6 @@
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
for (const url of DEFAULT_RELAYS) {
|
||||
loadRelay(url)
|
||||
}
|
||||
|
||||
if ($pk) {
|
||||
loadUserData($pk)
|
||||
}
|
||||
|
||||
ready = initStorage({
|
||||
events: {
|
||||
keyPath: "id",
|
||||
@@ -69,6 +61,16 @@
|
||||
clearModal()
|
||||
}
|
||||
})
|
||||
|
||||
ready.then(() => {
|
||||
for (const url of DEFAULT_RELAYS) {
|
||||
loadRelay(url)
|
||||
}
|
||||
|
||||
if ($pk) {
|
||||
loadUserData($pk)
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user