mirror of
https://github.com/coracle-social/coracle.git
synced 2024-09-30 00:41:12 +00:00
Fix a few bugs
This commit is contained in:
parent
b0d02a41c2
commit
46d1c93a58
@ -1,5 +1,4 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import cx from "classnames"
|
|
||||||
import {randomId} from "hurdak"
|
import {randomId} from "hurdak"
|
||||||
import {toggleTheme} from "src/partials/state"
|
import {toggleTheme} from "src/partials/state"
|
||||||
import MenuItem from "src/partials/MenuItem.svelte"
|
import MenuItem from "src/partials/MenuItem.svelte"
|
||||||
@ -14,9 +13,9 @@
|
|||||||
import {
|
import {
|
||||||
env,
|
env,
|
||||||
user,
|
user,
|
||||||
|
pubkey,
|
||||||
hasNewMessages,
|
hasNewMessages,
|
||||||
hasNewNotifications,
|
hasNewNotifications,
|
||||||
pubkey,
|
|
||||||
sessions,
|
sessions,
|
||||||
displayPerson,
|
displayPerson,
|
||||||
displayPubkey,
|
displayPubkey,
|
||||||
@ -52,7 +51,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={cx("fixed bottom-0 left-0 top-0 w-60 bg-cocoa transition-colors")}>
|
<div class="fixed bottom-0 left-0 top-0 z-nav w-60 bg-cocoa transition-colors">
|
||||||
<Anchor
|
<Anchor
|
||||||
class="mb-4 flex h-16 items-center gap-1 px-6"
|
class="mb-4 flex h-16 items-center gap-1 px-6"
|
||||||
external
|
external
|
||||||
@ -154,7 +153,7 @@
|
|||||||
</MenuDesktopSecondary>
|
</MenuDesktopSecondary>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="cursor-pointer border-t border-solid border-mid px-7 pb-4 pt-3">
|
<div class="cursor-pointer border-t border-solid border-mid px-7 pb-4 pt-3">
|
||||||
{#if $user}
|
{#if $pubkey}
|
||||||
<Anchor class="flex items-center gap-2" on:click={() => setSubMenu("account")}>
|
<Anchor class="flex items-center gap-2" on:click={() => setSubMenu("account")}>
|
||||||
<PersonCircle class="h-10 w-10" pubkey={$pubkey} />
|
<PersonCircle class="h-10 w-10" pubkey={$pubkey} />
|
||||||
<div class="flex min-w-0 flex-col">
|
<div class="flex min-w-0 flex-col">
|
||||||
|
@ -179,6 +179,7 @@
|
|||||||
$: {
|
$: {
|
||||||
actions = []
|
actions = []
|
||||||
|
|
||||||
|
if ($canSign) {
|
||||||
actions.push({label: "Quote", icon: "quote-left", onClick: quote})
|
actions.push({label: "Quote", icon: "quote-left", onClick: quote})
|
||||||
|
|
||||||
if (!note.wrap && $env.ENABLE_GROUPS && ($groupOptions.length > 0 || address)) {
|
if (!note.wrap && $env.ENABLE_GROUPS && ($groupOptions.length > 0 || address)) {
|
||||||
@ -193,6 +194,7 @@
|
|||||||
} else {
|
} else {
|
||||||
actions.push({label: "Mute", icon: "microphone-slash", onClick: muteNote})
|
actions.push({label: "Mute", icon: "microphone-slash", onClick: muteNote})
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($env.FORCE_RELAYS.length === 0 && !note.wrap) {
|
if ($env.FORCE_RELAYS.length === 0 && !note.wrap) {
|
||||||
actions.push({label: "Broadcast", icon: "rss", onClick: broadcast})
|
actions.push({label: "Broadcast", icon: "rss", onClick: broadcast})
|
||||||
|
@ -24,6 +24,7 @@ import {
|
|||||||
deriveMembershipLevel,
|
deriveMembershipLevel,
|
||||||
deriveAdminKeyForGroup,
|
deriveAdminKeyForGroup,
|
||||||
deriveSharedKeyForGroup,
|
deriveSharedKeyForGroup,
|
||||||
|
shouldPostPrivatelyToGroup,
|
||||||
} from "./utils"
|
} from "./utils"
|
||||||
|
|
||||||
// Key state management
|
// Key state management
|
||||||
@ -197,22 +198,10 @@ export const publishToZeroOrMoreGroups = async (
|
|||||||
return [await Publisher.publish({relays, event})]
|
return [await Publisher.publish({relays, event})]
|
||||||
}
|
}
|
||||||
|
|
||||||
const [wrap, nowrap] = partition(a => {
|
const [wrap, nowrap] = partition(
|
||||||
const access = deriveGroupAccess(a).get()
|
address => shouldPostPrivatelyToGroup(address, shouldWrap),
|
||||||
const membershipLevel = deriveMembershipLevel(a).get()
|
addresses,
|
||||||
|
)
|
||||||
if (membershipLevel === MembershipLevel.Private) {
|
|
||||||
if (access === GroupAccess.Closed) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
if (access === GroupAccess.Hybrid) {
|
|
||||||
return shouldWrap
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false
|
|
||||||
}, addresses)
|
|
||||||
|
|
||||||
const pubs = []
|
const pubs = []
|
||||||
|
|
||||||
|
@ -102,3 +102,20 @@ export const deriveMembershipLevel = address =>
|
|||||||
|
|
||||||
return MembershipLevel.None
|
return MembershipLevel.None
|
||||||
})
|
})
|
||||||
|
|
||||||
|
export const shouldPostPrivatelyToGroup = (address, preference) => {
|
||||||
|
const access = deriveGroupAccess(address).get()
|
||||||
|
const membershipLevel = deriveMembershipLevel(address).get()
|
||||||
|
|
||||||
|
if (membershipLevel === MembershipLevel.Private) {
|
||||||
|
if (access === GroupAccess.Closed) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
if (access === GroupAccess.Hybrid) {
|
||||||
|
return preference
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
@ -25,7 +25,7 @@ export const follow = (type: string, value: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const unfollow = (value: string) =>
|
export const unfollow = (value: string) =>
|
||||||
publishPetnames(reject((t: string[]) => t[1] === value, user.get().petnames || []))
|
publishPetnames(reject((t: string[]) => t[1] === value, user.get()?.petnames || []))
|
||||||
|
|
||||||
export const publishMutes = ($mutes: string[][]) => {
|
export const publishMutes = ($mutes: string[][]) => {
|
||||||
updateStore(people.key(stateKey.get()), now(), {mutes: $mutes})
|
updateStore(people.key(stateKey.get()), now(), {mutes: $mutes})
|
||||||
@ -37,9 +37,9 @@ export const publishMutes = ($mutes: string[][]) => {
|
|||||||
|
|
||||||
export const mute = (type: string, pubkey: string) =>
|
export const mute = (type: string, pubkey: string) =>
|
||||||
publishMutes([
|
publishMutes([
|
||||||
...reject((t: string[]) => t[1] === pubkey, user.get().mutes || []),
|
...reject((t: string[]) => t[1] === pubkey, user.get()?.mutes || []),
|
||||||
[type, pubkey],
|
[type, pubkey],
|
||||||
])
|
])
|
||||||
|
|
||||||
export const unmute = (value: string) =>
|
export const unmute = (value: string) =>
|
||||||
publishMutes(reject((t: string[]) => t[1] === value, user.get().mutes || []))
|
publishMutes(reject((t: string[]) => t[1] === value, user.get()?.mutes || []))
|
||||||
|
@ -2,12 +2,14 @@ import {omit, assoc} from "ramda"
|
|||||||
import {generatePrivateKey, getPublicKey} from "nostr-tools"
|
import {generatePrivateKey, getPublicKey} from "nostr-tools"
|
||||||
import {appDataKeys} from "src/util/nostr"
|
import {appDataKeys} from "src/util/nostr"
|
||||||
import {createAndPublish} from "src/engine/network/utils"
|
import {createAndPublish} from "src/engine/network/utils"
|
||||||
|
import {people} from "src/engine/people/state"
|
||||||
import type {Session} from "./model"
|
import type {Session} from "./model"
|
||||||
import {sessions, pubkey} from "./state"
|
import {sessions, pubkey} from "./state"
|
||||||
import {canSign, nip04, session} from "./derived"
|
import {canSign, nip04, session} from "./derived"
|
||||||
|
|
||||||
const addSession = (s: Session) => {
|
const addSession = (s: Session) => {
|
||||||
sessions.update(assoc(s.pubkey, s))
|
sessions.update(assoc(s.pubkey, s))
|
||||||
|
people.key(s.pubkey).update($p => ({...$p, pubkey: s.pubkey}))
|
||||||
pubkey.set(s.pubkey)
|
pubkey.set(s.pubkey)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
export let small = false
|
export let small = false
|
||||||
export let large = false
|
export let large = false
|
||||||
|
|
||||||
const className = cx('flex flex-col m-auto', $$props.class, {
|
const className = cx("flex flex-col m-auto min-w-0 w-full", $$props.class, {
|
||||||
'gap-2': small,
|
"gap-2": small,
|
||||||
'gap-4': !small && !large,
|
"gap-4": !small && !large,
|
||||||
'gap-6': large,
|
"gap-6": large,
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user