diff --git a/src/app/MenuDesktop.svelte b/src/app/MenuDesktop.svelte index a1be934c..5297ca85 100644 --- a/src/app/MenuDesktop.svelte +++ b/src/app/MenuDesktop.svelte @@ -1,5 +1,4 @@ -
+
{/if}
- {#if $user} + {#if $pubkey} setSubMenu("account")}>
diff --git a/src/app/shared/NoteActions.svelte b/src/app/shared/NoteActions.svelte index 35370a26..a880c3e7 100644 --- a/src/app/shared/NoteActions.svelte +++ b/src/app/shared/NoteActions.svelte @@ -179,19 +179,21 @@ $: { actions = [] - actions.push({label: "Quote", icon: "quote-left", onClick: quote}) + if ($canSign) { + actions.push({label: "Quote", icon: "quote-left", onClick: quote}) - if (!note.wrap && $env.ENABLE_GROUPS && ($groupOptions.length > 0 || address)) { - actions.push({label: "Cross-post", icon: "shuffle", onClick: () => setView("cross-post")}) - } + if (!note.wrap && $env.ENABLE_GROUPS && ($groupOptions.length > 0 || address)) { + actions.push({label: "Cross-post", icon: "shuffle", onClick: () => setView("cross-post")}) + } - actions.push({label: "Tag", icon: "tag", onClick: label}) - //actions.push({label: "Report", icon: "triangle-exclamation", onClick: report}) + actions.push({label: "Tag", icon: "tag", onClick: label}) + //actions.push({label: "Report", icon: "triangle-exclamation", onClick: report}) - if ($muted) { - actions.push({label: "Unmute", icon: "microphone", onClick: unmuteNote}) - } else { - actions.push({label: "Mute", icon: "microphone-slash", onClick: muteNote}) + if ($muted) { + actions.push({label: "Unmute", icon: "microphone", onClick: unmuteNote}) + } else { + actions.push({label: "Mute", icon: "microphone-slash", onClick: muteNote}) + } } if ($env.FORCE_RELAYS.length === 0 && !note.wrap) { diff --git a/src/engine/groups/commands.ts b/src/engine/groups/commands.ts index 861dcf7e..185aa91b 100644 --- a/src/engine/groups/commands.ts +++ b/src/engine/groups/commands.ts @@ -24,6 +24,7 @@ import { deriveMembershipLevel, deriveAdminKeyForGroup, deriveSharedKeyForGroup, + shouldPostPrivatelyToGroup, } from "./utils" // Key state management @@ -197,22 +198,10 @@ export const publishToZeroOrMoreGroups = async ( return [await Publisher.publish({relays, event})] } - const [wrap, nowrap] = partition(a => { - const access = deriveGroupAccess(a).get() - const membershipLevel = deriveMembershipLevel(a).get() - - if (membershipLevel === MembershipLevel.Private) { - if (access === GroupAccess.Closed) { - return true - } - - if (access === GroupAccess.Hybrid) { - return shouldWrap - } - } - - return false - }, addresses) + const [wrap, nowrap] = partition( + address => shouldPostPrivatelyToGroup(address, shouldWrap), + addresses, + ) const pubs = [] diff --git a/src/engine/groups/utils.ts b/src/engine/groups/utils.ts index 90c2b3c7..9fea1456 100644 --- a/src/engine/groups/utils.ts +++ b/src/engine/groups/utils.ts @@ -102,3 +102,20 @@ export const deriveMembershipLevel = address => 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 +} diff --git a/src/engine/people/commands.ts b/src/engine/people/commands.ts index ddf5d0cf..8a64790d 100644 --- a/src/engine/people/commands.ts +++ b/src/engine/people/commands.ts @@ -25,7 +25,7 @@ export const follow = (type: string, 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[][]) => { updateStore(people.key(stateKey.get()), now(), {mutes: $mutes}) @@ -37,9 +37,9 @@ export const publishMutes = ($mutes: string[][]) => { export const mute = (type: string, pubkey: string) => publishMutes([ - ...reject((t: string[]) => t[1] === pubkey, user.get().mutes || []), + ...reject((t: string[]) => t[1] === pubkey, user.get()?.mutes || []), [type, pubkey], ]) 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 || [])) diff --git a/src/engine/session/commands.ts b/src/engine/session/commands.ts index 0a40b877..8cd1e457 100644 --- a/src/engine/session/commands.ts +++ b/src/engine/session/commands.ts @@ -2,12 +2,14 @@ import {omit, assoc} from "ramda" import {generatePrivateKey, getPublicKey} from "nostr-tools" import {appDataKeys} from "src/util/nostr" import {createAndPublish} from "src/engine/network/utils" +import {people} from "src/engine/people/state" import type {Session} from "./model" import {sessions, pubkey} from "./state" import {canSign, nip04, session} from "./derived" const addSession = (s: Session) => { sessions.update(assoc(s.pubkey, s)) + people.key(s.pubkey).update($p => ({...$p, pubkey: s.pubkey})) pubkey.set(s.pubkey) } diff --git a/src/partials/FlexColumn.svelte b/src/partials/FlexColumn.svelte index b28eead4..57d86479 100644 --- a/src/partials/FlexColumn.svelte +++ b/src/partials/FlexColumn.svelte @@ -4,10 +4,10 @@ export let small = false export let large = false - const className = cx('flex flex-col m-auto', $$props.class, { - 'gap-2': small, - 'gap-4': !small && !large, - 'gap-6': large, + const className = cx("flex flex-col m-auto min-w-0 w-full", $$props.class, { + "gap-2": small, + "gap-4": !small && !large, + "gap-6": large, })