mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-18 19:23:40 +00:00
Merge branch 'master' of github.com:coracle-social/coracle
This commit is contained in:
commit
6b6fcb5dc0
@ -8,10 +8,13 @@
|
||||
const {canPublish} = user
|
||||
|
||||
const createNote = () => {
|
||||
const matches = $location.pathname.match(/people\/(npub1[0-9a-z]+)/)
|
||||
const pubkey = matches ? nip19.decode(matches[1]).data : null
|
||||
const pubkeyMatch = $location.pathname.match(/people\/(npub1[0-9a-z]+)/)
|
||||
const pubkey = pubkeyMatch ? nip19.decode(pubkeyMatch[1]).data : null
|
||||
const relayMatch = $location.pathname.match(/relays\/(.+)/)
|
||||
const relay = relayMatch ? relayMatch[1] : null
|
||||
const relays = relay ? [relay] : null
|
||||
|
||||
modal.push({type: "note/create", pubkey})
|
||||
modal.push({type: "note/create", pubkey, relays})
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
<NoteDetail {...m} invertColors />
|
||||
{/key}
|
||||
{:else if m.type === "note/create"}
|
||||
<NoteCreate pubkey={m.pubkey} nevent={m.nevent} />
|
||||
<NoteCreate pubkey={m.pubkey} nevent={m.nevent} writeTo={m.relays} />
|
||||
{:else if m.type === "note/zap"}
|
||||
<NoteZap note={m.note} />
|
||||
{:else if m.type === "relay/add"}
|
||||
|
@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {Route} from "svelte-routing"
|
||||
import {onReady} from "src/agent/db"
|
||||
import {base64DecodeOrPlainWebSocketURL} from "src/util/misc"
|
||||
import EnsureData from "src/app/EnsureData.svelte"
|
||||
import Notifications from "src/app/views/Notifications.svelte"
|
||||
import Bech32Entity from "src/app/views/Bech32Entity.svelte"
|
||||
@ -71,9 +72,9 @@
|
||||
</Route>
|
||||
<Route path="/keys" component={UserKeys} />
|
||||
<Route path="/relays" component={RelayList} />
|
||||
<Route path="/relays/:b64url" let:params>
|
||||
<Route path="/relays/:b64OrUrl" let:params>
|
||||
{#key params.b64url}
|
||||
<RelayDetail url={atob(params.b64url)} />
|
||||
<RelayDetail url={base64DecodeOrPlainWebSocketURL(params.b64OrUrl)} />
|
||||
{/key}
|
||||
</Route>
|
||||
<Route path="/profile" component={UserProfile} />
|
||||
|
@ -4,7 +4,7 @@
|
||||
import {between} from "hurdak/lib/hurdak"
|
||||
import {onMount} from "svelte"
|
||||
import {fly} from "svelte/transition"
|
||||
import {poll, stringToHue, hsl} from "src/util/misc"
|
||||
import {poll, stringToHue, hsl, webSocketURLToPlainOrBase64} from "src/util/misc"
|
||||
import Toggle from "src/partials/Toggle.svelte"
|
||||
import Anchor from "src/partials/Anchor.svelte"
|
||||
import pool from "src/agent/pool"
|
||||
@ -55,7 +55,7 @@
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<div class="flex items-center gap-2 text-xl">
|
||||
<i class={relay.url.startsWith("wss") ? "fa fa-lock" : "fa fa-unlock"} />
|
||||
<Anchor type="unstyled" href={`/relays/${btoa(relay.url)}`}>
|
||||
<Anchor type="unstyled" href={`/relays/${webSocketURLToPlainOrBase64(relay.url)}`}>
|
||||
{last(relay.url.split("://"))}
|
||||
</Anchor>
|
||||
{#if showStatus}
|
||||
|
@ -2,6 +2,7 @@
|
||||
import {onMount} from "svelte"
|
||||
import {between} from "hurdak/lib/hurdak"
|
||||
import {displayRelay} from "src/util/nostr"
|
||||
import {webSocketURLToPlainOrBase64} from "src/util/misc"
|
||||
import {poll, stringToHue, hsl} from "src/util/misc"
|
||||
import Anchor from "src/partials/Anchor.svelte"
|
||||
import pool from "src/agent/pool"
|
||||
@ -23,7 +24,7 @@
|
||||
<i class={relay.url.startsWith("wss") ? "fa fa-lock" : "fa fa-unlock"} />
|
||||
<Anchor
|
||||
type="unstyled"
|
||||
href={`/relays/${btoa(relay.url)}`}
|
||||
href={`/relays/${webSocketURLToPlainOrBase64(relay.url)}`}
|
||||
class="border-b border-solid"
|
||||
style={`border-color: ${hsl(stringToHue(relay.url))}`}>
|
||||
{displayRelay(relay)}
|
||||
|
@ -1,7 +1,6 @@
|
||||
<script>
|
||||
import {onMount} from "svelte"
|
||||
import {nip19} from "nostr-tools"
|
||||
import {quantify} from "hurdak/lib/hurdak"
|
||||
import {last, reject, pluck, propEq} from "ramda"
|
||||
import {fly} from "svelte/transition"
|
||||
import {writable} from "svelte/store"
|
||||
@ -25,12 +24,13 @@
|
||||
|
||||
export let pubkey = null
|
||||
export let nevent = null
|
||||
export let writeTo = null
|
||||
|
||||
let q = ""
|
||||
let image = null
|
||||
let compose = null
|
||||
let showSettings = false
|
||||
let relays = writable(getUserWriteRelays())
|
||||
let relays = writable(writeTo ? writeTo.map(url => ({url, score: 1})) : getUserWriteRelays())
|
||||
|
||||
const onSubmit = async () => {
|
||||
let {content, mentions, topics} = compose.parse()
|
||||
@ -122,7 +122,13 @@
|
||||
on:click={() => {
|
||||
showSettings = true
|
||||
}}>
|
||||
<span>Publishing to {quantify($relays.length, "relay")}</span>
|
||||
<span>
|
||||
Publishing to {#if $relays?.length === 1}
|
||||
{last($relays[0].url.split("//"))}
|
||||
{:else}
|
||||
{$relays.length} relays
|
||||
{/if}
|
||||
</span>
|
||||
<i class="fa fa-edit" />
|
||||
</small>
|
||||
</div>
|
||||
|
@ -394,3 +394,27 @@ export const shadeColor = (color, percent) => {
|
||||
|
||||
return "#" + RR + GG + BB
|
||||
}
|
||||
|
||||
export const base64DecodeOrPlainWebSocketURL = (data: string): string => {
|
||||
try {
|
||||
return atob(data)
|
||||
} catch (err) {
|
||||
if (data.startsWith("ws://") || data.startsWith("wss://")) {
|
||||
return data
|
||||
}
|
||||
return "wss://" + data
|
||||
}
|
||||
}
|
||||
|
||||
export const webSocketURLToPlainOrBase64 = (url: string): string => {
|
||||
if (url.startsWith("ws://")) {
|
||||
return btoa(url)
|
||||
}
|
||||
if (url.startsWith("wss://")) {
|
||||
url = url.slice(6)
|
||||
}
|
||||
if (url.includes("/")) {
|
||||
return btoa(url)
|
||||
}
|
||||
return url
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user