mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 10:57:04 +00:00
Fix conversation sync
This commit is contained in:
@@ -283,7 +283,7 @@ export const checkRelayAccess = async (url: string, claim = "") => {
|
||||
result[url].message?.replace(/^.*: /, "") ||
|
||||
"join request rejected"
|
||||
|
||||
return `Failed to join relay: ${message}`
|
||||
return `Failed to join relay (${message})`
|
||||
}
|
||||
}
|
||||
|
||||
@@ -309,11 +309,12 @@ export const checkRelayAuth = async (url: string) => {
|
||||
const connection = ctx.net.pool.get(url)
|
||||
const okStatuses = [AuthStatus.None, AuthStatus.Ok]
|
||||
|
||||
await connection.auth.attempt(5000)
|
||||
await connection.auth.attempt(30_000)
|
||||
|
||||
if (!okStatuses.includes(connection.auth.status)) {
|
||||
console.log(connection.auth.status, connection)
|
||||
return `Failed to authenticate: "${connection.auth.message}"`
|
||||
// Only raise an error if it's not a timeout.
|
||||
// If it is, odds are the problem is with our signer, not the relay
|
||||
if (!okStatuses.includes(connection.auth.status) && connection.auth.message) {
|
||||
return `Failed to authenticate (${connection.auth.message})`
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {derived} from "svelte/store"
|
||||
import {page} from "$app/stores"
|
||||
import {remove} from "@welshman/lib"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {pubkey, inboxRelaySelectionsByPubkey, loadInboxRelaySelections} from "@welshman/app"
|
||||
import {pubkey, loadInboxRelaySelections} from "@welshman/app"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import ProfileName from "@app/components/ProfileName.svelte"
|
||||
import ProfileCircle from "@app/components/ProfileCircle.svelte"
|
||||
import ProfileCircles from "@app/components/ProfileCircles.svelte"
|
||||
@@ -19,7 +17,6 @@
|
||||
const message = messages[0]
|
||||
const others = remove($pubkey!, pubkeys)
|
||||
const active = $page.params.chat === id
|
||||
const missingInbox = derived(inboxRelaySelectionsByPubkey, $m => others.some(pk => !$m.has(pk)))
|
||||
|
||||
onMount(() => {
|
||||
for (const pk of others) {
|
||||
@@ -47,9 +44,6 @@
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
{#if $missingInbox}
|
||||
<Icon icon="danger" class="text-error" />
|
||||
{/if}
|
||||
</div>
|
||||
<p class="overflow-hidden text-ellipsis whitespace-nowrap text-sm">
|
||||
{message.content}
|
||||
|
||||
@@ -88,13 +88,21 @@
|
||||
</p>
|
||||
{#if getNip07()}
|
||||
<Button disabled={loading} on:click={loginWithNip07} class="btn btn-primary">
|
||||
<Icon icon="widget" />
|
||||
{#if loading}
|
||||
<span class="loading loading-spinner mr-3" />
|
||||
{:else}
|
||||
<Icon icon="widget" />
|
||||
{/if}
|
||||
Log in with Extension
|
||||
</Button>
|
||||
{/if}
|
||||
{#each signers as app}
|
||||
<Button disabled={loading} class="btn btn-neutral" on:click={() => loginWithSigner(app)}>
|
||||
<img src={app.iconUrl} alt={app.name} width="48" height="48" />
|
||||
{#if loading}
|
||||
<span class="loading loading-spinner mr-3" />
|
||||
{:else}
|
||||
<img src={app.iconUrl} alt={app.name} width="48" height="48" />
|
||||
{/if}
|
||||
Log in with {app.name}
|
||||
</Button>
|
||||
{/each}
|
||||
@@ -107,6 +115,7 @@
|
||||
</Button>
|
||||
<Link
|
||||
external
|
||||
disabled={loading}
|
||||
href="https://nostrapps.com#signers"
|
||||
class="btn {hasNativeSigner ? '' : 'btn-neutral'}">
|
||||
<Icon icon="compass" />
|
||||
|
||||
@@ -26,8 +26,9 @@
|
||||
|
||||
<form class="column gap-4" on:submit|preventDefault={logout}>
|
||||
<ModalHeader>
|
||||
<div slot="title">Are you sure you want to log out?</div>
|
||||
<div slot="title">Are you sure you<br />want to log out?</div>
|
||||
</ModalHeader>
|
||||
<p>Your local database will be cleared.</p>
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" on:click={back}>
|
||||
<Icon icon="alt-arrow-left" />
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script lang="ts">
|
||||
import "@src/app.css"
|
||||
import {onMount} from "svelte"
|
||||
import {get} from "svelte/store"
|
||||
import {get, derived} from "svelte/store"
|
||||
import {dev} from "$app/environment"
|
||||
import {ctx, uniq, sleep, take, sortBy, ago, now, HOUR, WEEK} from "@welshman/lib"
|
||||
import {identity, uniq, sleep, take, sortBy, ago, now, HOUR, WEEK, Worker} from "@welshman/lib"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {
|
||||
PROFILE,
|
||||
@@ -33,9 +33,12 @@
|
||||
session,
|
||||
signer,
|
||||
dropSession,
|
||||
getRelayUrls,
|
||||
userInboxRelaySelections,
|
||||
} from "@welshman/app"
|
||||
import * as lib from "@welshman/lib"
|
||||
import * as util from "@welshman/util"
|
||||
import * as net from "@welshman/net"
|
||||
import * as app from "@welshman/app"
|
||||
import AppContainer from "@app/components/AppContainer.svelte"
|
||||
import ModalContainer from "@app/components/ModalContainer.svelte"
|
||||
@@ -47,6 +50,7 @@
|
||||
getMembershipUrls,
|
||||
getMembershipRooms,
|
||||
userMembership,
|
||||
ensureUnwrapped,
|
||||
MEMBERSHIPS,
|
||||
MESSAGE,
|
||||
COMMENT,
|
||||
@@ -62,8 +66,8 @@
|
||||
|
||||
let ready: Promise<unknown> = Promise.resolve()
|
||||
|
||||
onMount(() => {
|
||||
Object.assign(window, {get, ...lib, ...util, ...app, ...state})
|
||||
onMount(async () => {
|
||||
Object.assign(window, {get, ...lib, ...util, ...net, ...app, ...state})
|
||||
|
||||
const getScoreEvent = () => {
|
||||
const ALWAYS_KEEP = Infinity
|
||||
@@ -140,6 +144,29 @@
|
||||
tracker: storageAdapters.fromTracker(tracker, {throttle: 1000}),
|
||||
}).then(() => sleep(300))
|
||||
|
||||
// Unwrap gift wraps as they come in, but throttled
|
||||
const unwrapper = new Worker<TrustedEvent>({chunkSize: 10})
|
||||
|
||||
unwrapper.addGlobalHandler(ensureUnwrapped)
|
||||
|
||||
repository.on("update", ({added}) => {
|
||||
for (const event of added) {
|
||||
if (event.kind === WRAP) {
|
||||
unwrapper.push(event)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Load relay info
|
||||
for (const url of INDEXER_RELAYS) {
|
||||
loadRelay(url)
|
||||
}
|
||||
|
||||
// Load user data
|
||||
if ($pubkey) {
|
||||
await loadUserData($pubkey)
|
||||
}
|
||||
|
||||
let unsubRooms: any
|
||||
|
||||
userMembership.subscribe($membership => {
|
||||
@@ -165,33 +192,18 @@
|
||||
|
||||
let unsubChats: any
|
||||
|
||||
pubkey.subscribe($pubkey => {
|
||||
unsubChats?.()
|
||||
derived([pubkey, userInboxRelaySelections], identity).subscribe(
|
||||
([$pubkey, $userInboxRelaySelections]) => {
|
||||
unsubChats?.()
|
||||
|
||||
if ($pubkey) {
|
||||
unsubChats = subscribePersistent({
|
||||
filters: [{kinds: [WRAP], "#p": [$pubkey], since: ago(WEEK)}],
|
||||
relays: ctx.app.router.UserInbox().getUrls(),
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
// Unwrap gift wraps as they come in
|
||||
repository.on("update", ({added}) => {
|
||||
for (const event of added) {
|
||||
state.ensureUnwrapped(event)
|
||||
}
|
||||
})
|
||||
|
||||
// Load relay info
|
||||
for (const url of INDEXER_RELAYS) {
|
||||
loadRelay(url)
|
||||
}
|
||||
|
||||
// Load user data
|
||||
if ($pubkey) {
|
||||
loadUserData($pubkey)
|
||||
}
|
||||
if ($pubkey) {
|
||||
unsubChats = subscribePersistent({
|
||||
filters: [{kinds: [WRAP], "#p": [$pubkey], since: ago(WEEK, 2)}],
|
||||
relays: getRelayUrls($userInboxRelaySelections),
|
||||
})
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {page} from "$app/stores"
|
||||
import {WEEK, ctx, ago} from "@welshman/lib"
|
||||
import {ctx} from "@welshman/lib"
|
||||
import {WRAP} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {pubkey, repository} from "@welshman/app"
|
||||
@@ -20,7 +20,7 @@
|
||||
const startChat = () => pushModal(ChatStart)
|
||||
|
||||
const promise = pullConservatively({
|
||||
filters: [{kinds: [WRAP], "#p": [$pubkey!], until: ago(WEEK)}],
|
||||
filters: [{kinds: [WRAP], "#p": [$pubkey!]}],
|
||||
relays: ctx.app.router.UserInbox().getUrls(),
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user