mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-19 11:43:35 +00:00
Add canPublish
This commit is contained in:
parent
50e57676a1
commit
474cadfe42
@ -22,6 +22,7 @@
|
||||
|
||||
# More
|
||||
|
||||
- [ ] Clean up person detail actions, maybe click one circle and show the rest
|
||||
- [ ] Hover badge to view profile like twitter
|
||||
- [ ] Show created date as bitcoin block height (add a setting?)
|
||||
- [ ] Support relay auth
|
||||
|
@ -1,6 +1,6 @@
|
||||
import type {Person} from 'src/util/types'
|
||||
import type {Readable} from 'svelte/store'
|
||||
import {last, pipe, assoc, whereEq, when, concat, reject, nth, map} from 'ramda'
|
||||
import {last, prop, find, pipe, assoc, whereEq, when, concat, reject, nth, map} from 'ramda'
|
||||
import {synced} from 'src/util/misc'
|
||||
import {derived} from 'svelte/store'
|
||||
import database from 'src/agent/database'
|
||||
@ -52,6 +52,12 @@ const relays = derived(
|
||||
$profile?.relays || $anonRelays
|
||||
)
|
||||
|
||||
const canPublish = derived(
|
||||
[keys.pubkey, relays],
|
||||
([$pubkey, $relays]) =>
|
||||
keys.canSign() && find(prop('write'), relays)
|
||||
)
|
||||
|
||||
// Keep our copies up to date
|
||||
|
||||
settings.subscribe($settings => {
|
||||
@ -81,6 +87,7 @@ const user = {
|
||||
// Profile
|
||||
|
||||
profile,
|
||||
canPublish,
|
||||
getProfile: () => profileCopy,
|
||||
getPubkey: () => profileCopy?.pubkey,
|
||||
|
||||
|
@ -1,14 +1,13 @@
|
||||
<script lang="ts">
|
||||
import keys from 'src/agent/keys'
|
||||
import user from 'src/agent/user'
|
||||
import {modal} from "src/app/ui"
|
||||
|
||||
export let pubkey = null
|
||||
|
||||
const {relays} = user
|
||||
const {canPublish} = user
|
||||
</script>
|
||||
|
||||
{#if keys.canSign() && $relays.length > 0}
|
||||
{#if $canPublish}
|
||||
<div class="fixed bottom-0 right-0 m-8">
|
||||
<button
|
||||
class="rounded-full bg-accent color-white w-16 h-16 flex justify-center
|
||||
|
@ -19,7 +19,7 @@
|
||||
let showStatus = false
|
||||
let joined = false
|
||||
|
||||
const {relays} = user
|
||||
const {relays, canPublish} = user
|
||||
|
||||
$: joined = find(propEq('url', relay.url), $relays)
|
||||
|
||||
@ -93,7 +93,7 @@
|
||||
{#if relay.description}
|
||||
<p>{relay.description}</p>
|
||||
{/if}
|
||||
{#if joined && showControls}
|
||||
{#if joined && showControls && $canPublish}
|
||||
<div class="border-b border-solid border-medium -mx-6" />
|
||||
<div class="flex justify-between gap-2">
|
||||
<span>Publish to this relay?</span>
|
||||
|
@ -19,7 +19,6 @@
|
||||
import user from "src/agent/user"
|
||||
import {sampleRelays, getPubkeyWriteRelays} from "src/agent/relays"
|
||||
import network from "src/agent/network"
|
||||
import keys from "src/agent/keys"
|
||||
import database from "src/agent/database"
|
||||
import {routes, modal} from "src/app/ui"
|
||||
|
||||
@ -28,7 +27,7 @@
|
||||
export let relays = []
|
||||
|
||||
const interpolate = (a, b) => t => a + Math.round((b - a) * t)
|
||||
const {petnamePubkeys} = user
|
||||
const {petnamePubkeys, canPublish} = user
|
||||
|
||||
let pubkey = toHex(npub)
|
||||
let following = false
|
||||
@ -127,9 +126,9 @@
|
||||
{/if}
|
||||
</div>
|
||||
<div class="whitespace-nowrap flex gap-3 items-center flex-wrap">
|
||||
{#if user.getPubkey() === pubkey && keys.canSign()}
|
||||
{#if user.getPubkey() === pubkey && $canPublish}
|
||||
<Anchor href="/profile"><i class="fa-solid fa-edit" /> Edit profile</Anchor>
|
||||
{:else if user.getProfile() && keys.canSign()}
|
||||
{:else if $canPublish}
|
||||
<Anchor type="button-circle" on:click={openAdvanced}>
|
||||
<i class="fa fa-sliders" />
|
||||
</Anchor>
|
||||
|
@ -29,7 +29,7 @@
|
||||
</p>
|
||||
<div class="flex gap-2">
|
||||
<div class="flex-grow">
|
||||
<Input bind:value={nsec} placeholder="nsec...">
|
||||
<Input type="password" bind:value={nsec} placeholder="nsec...">
|
||||
<i slot="before" class="fa fa-key" />
|
||||
</Input>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user