forked from coracle/flotilla
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dee017b12b | |||
| 72b55c6bd1 | |||
| 20018e1788 | |||
| 9af6797c0b | |||
| df051d3c94 |
@@ -1,9 +1,9 @@
|
||||
<script lang="ts">
|
||||
import cx from "classnames"
|
||||
import {removeUndefined} from "@welshman/lib"
|
||||
import {deriveProfile} from "@welshman/app"
|
||||
import UserRounded from "@assets/icons/user-rounded.svg?dataurl"
|
||||
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
||||
import {deriveDedupedProfile} from "@app/core/state"
|
||||
|
||||
type Props = {
|
||||
pubkey?: string
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
const {pubkey, url, size = 7, ...props}: Props = $props()
|
||||
|
||||
const profile = deriveDedupedProfile(pubkey, removeUndefined([url]))
|
||||
const profile = deriveProfile(pubkey, removeUndefined([url]))
|
||||
</script>
|
||||
|
||||
<ImageIcon
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
import {onMount} from "svelte"
|
||||
import {removeUndefined} from "@welshman/lib"
|
||||
import {ManagementMethod} from "@welshman/util"
|
||||
import {manageRelay, displayProfileByPubkey, loadMessagingRelayList} from "@welshman/app"
|
||||
import {
|
||||
manageRelay,
|
||||
deriveProfile,
|
||||
displayProfileByPubkey,
|
||||
loadMessagingRelayList,
|
||||
} from "@welshman/app"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import Code2 from "@assets/icons/code-2.svg?dataurl"
|
||||
import Letter from "@assets/icons/letter-opened.svg?dataurl"
|
||||
@@ -23,12 +28,7 @@
|
||||
import ProfileInfo from "@app/components/ProfileInfo.svelte"
|
||||
import EventInfo from "@app/components/EventInfo.svelte"
|
||||
import ProfileBadges from "@app/components/ProfileBadges.svelte"
|
||||
import {
|
||||
pubkeyLink,
|
||||
deriveUserIsSpaceAdmin,
|
||||
deriveSpaceBannedPubkeyItems,
|
||||
deriveDedupedProfile,
|
||||
} from "@app/core/state"
|
||||
import {pubkeyLink, deriveUserIsSpaceAdmin, deriveSpaceBannedPubkeyItems} from "@app/core/state"
|
||||
import {addSpaceMembers} from "@app/core/commands"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
const {pubkey, url}: Props = $props()
|
||||
|
||||
const profile = deriveDedupedProfile(pubkey, removeUndefined([url]))
|
||||
const profile = deriveProfile(pubkey, removeUndefined([url]))
|
||||
|
||||
const userIsAdmin = deriveUserIsSpaceAdmin(url)
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import {removeUndefined} from "@welshman/lib"
|
||||
import {deriveDedupedProfile} from "@app/core/state"
|
||||
import {deriveProfile} from "@welshman/app"
|
||||
import ContentMinimal from "@app/components/ContentMinimal.svelte"
|
||||
|
||||
export type Props = {
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
const {pubkey, url}: Props = $props()
|
||||
|
||||
const profile = deriveDedupedProfile(pubkey, removeUndefined([url]))
|
||||
const profile = deriveProfile(pubkey, removeUndefined([url]))
|
||||
</script>
|
||||
|
||||
{#if $profile}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {throttled} from "@welshman/store"
|
||||
import {setKey, popKey} from "@lib/implicit"
|
||||
import {sleep} from "@welshman/lib"
|
||||
import {displayProfileByPubkey} from "@welshman/app"
|
||||
@@ -32,7 +31,7 @@
|
||||
const {url, h}: Props = $props()
|
||||
|
||||
const room = deriveRoom(url, h)
|
||||
const spaceMembers = throttled(300, deriveSpaceMembers(url))
|
||||
const spaceMembers = deriveSpaceMembers(url)
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {ManagementMethod} from "@welshman/util"
|
||||
import {throttled} from "@welshman/store"
|
||||
import {manageRelay, displayProfileByPubkey} from "@welshman/app"
|
||||
import MenuDots from "@assets/icons/menu-dots.svg?dataurl"
|
||||
import UserMinus from "@assets/icons/user-minus.svg?dataurl"
|
||||
@@ -37,7 +36,7 @@
|
||||
|
||||
const {url}: Props = $props()
|
||||
|
||||
const members = throttled(300, deriveSpaceMembers(url))
|
||||
const members = deriveSpaceMembers(url)
|
||||
const bans = deriveSpaceBannedPubkeyItems(url)
|
||||
const userIsAdmin = deriveUserIsSpaceAdmin(url)
|
||||
const supportedMethods = deriveSupportedMethods(url)
|
||||
@@ -116,6 +115,7 @@
|
||||
{#if $members === undefined}
|
||||
<div class="card2 bg-base-200 p-4">
|
||||
<span class="text-error">Member list not available from this space</span>
|
||||
<span class="text-error">Member list not available from this space</span>
|
||||
</div>
|
||||
{:else if $members.length === 0}
|
||||
<div class="card2 bg-base-200 p-4">
|
||||
|
||||
@@ -154,11 +154,7 @@
|
||||
</div>
|
||||
{#if $notificationSettings.push && !$shouldNotify}
|
||||
<Icon icon={BellOff} size={3} class="opacity-50" />
|
||||
{/if}
|
||||
</strong>
|
||||
<Icon icon={AltArrowDown} />
|
||||
</div>
|
||||
<span class="text-xs text-primary">{displayRelayUrl(url)}</span>
|
||||
View Members ({$members.length})
|
||||
</Button>
|
||||
{#if showMenu}
|
||||
<Popover hideOnClick onClose={toggleMenu}>
|
||||
@@ -182,6 +178,7 @@
|
||||
<Icon icon={UserRounded} />
|
||||
{#if $members === undefined}
|
||||
View Members
|
||||
View Members
|
||||
{:else}
|
||||
View Members ({$members.length})
|
||||
{/if}
|
||||
|
||||
@@ -32,7 +32,6 @@ import {
|
||||
ROOMS,
|
||||
COMMENT,
|
||||
APP_DATA,
|
||||
POLL_RESPONSE,
|
||||
isSignedEvent,
|
||||
makeEvent,
|
||||
normalizeRelayUrl,
|
||||
@@ -55,6 +54,7 @@ import {
|
||||
createProfile,
|
||||
ManagementMethod,
|
||||
} from "@welshman/util"
|
||||
import {PollResponse} from "nostr-tools/kinds"
|
||||
import {Pool, AuthStatus, SocketStatus} from "@welshman/net"
|
||||
import {Router} from "@welshman/router"
|
||||
import {
|
||||
@@ -389,7 +389,7 @@ export type PollResponseParams = {
|
||||
}
|
||||
|
||||
export const makePollResponse = ({event, selectedIds}: PollResponseParams) =>
|
||||
makeEvent(POLL_RESPONSE, {
|
||||
makeEvent(PollResponse, {
|
||||
content: "",
|
||||
tags: [["e", event.id], ...selectedIds.map(selectedId => ["response", selectedId])],
|
||||
})
|
||||
|
||||
+2
-22
@@ -92,7 +92,6 @@ import {
|
||||
THREAD,
|
||||
CLASSIFIED,
|
||||
WRAP,
|
||||
POLL,
|
||||
PROFILE,
|
||||
ZAP_GOAL,
|
||||
ZAP_REQUEST,
|
||||
@@ -147,34 +146,15 @@ import {
|
||||
makeUserData,
|
||||
makeUserLoader,
|
||||
manageRelay,
|
||||
deriveProfile,
|
||||
displayProfileByPubkey,
|
||||
getProfile,
|
||||
} from "@welshman/app"
|
||||
import {Poll} from "nostr-tools/kinds"
|
||||
import {checkRelayHasLivekit} from "$lib/livekit"
|
||||
import {readFeed} from "@lib/feeds"
|
||||
|
||||
export const fromCsv = (s: string) => (s || "").split(",").filter(identity)
|
||||
|
||||
const profileStoreCache = new Map<string, ReturnType<typeof deriveProfile>>()
|
||||
|
||||
export const deriveDedupedProfile = (
|
||||
...args: Parameters<typeof deriveProfile>
|
||||
): ReturnType<typeof deriveProfile> => {
|
||||
const key = JSON.stringify(args)
|
||||
const cached = profileStoreCache.get(key)
|
||||
|
||||
if (cached) {
|
||||
return cached
|
||||
}
|
||||
|
||||
const store = deriveProfile(...args)
|
||||
|
||||
profileStoreCache.set(key, store)
|
||||
|
||||
return store
|
||||
}
|
||||
|
||||
export const ROOM = "h"
|
||||
|
||||
export const PROTECTED = ["-"]
|
||||
@@ -347,7 +327,7 @@ if (ENABLE_ZAPS) {
|
||||
REACTION_KINDS.push(ZAP_RESPONSE)
|
||||
}
|
||||
|
||||
export const CONTENT_KINDS = [ZAP_GOAL, EVENT_TIME, THREAD, CLASSIFIED, POLL]
|
||||
export const CONTENT_KINDS = [ZAP_GOAL, EVENT_TIME, THREAD, CLASSIFIED, Poll]
|
||||
|
||||
export const DM_KINDS = [DIRECT_MESSAGE, DIRECT_MESSAGE_FILE]
|
||||
|
||||
|
||||
+39
-3
@@ -1,10 +1,11 @@
|
||||
import {page} from "$app/stores"
|
||||
import type {Unsubscriber} from "svelte/store"
|
||||
import {last, call, assoc, chunk, WEEK, ago} from "@welshman/lib"
|
||||
import {last, call, assoc, chunk, WEEK, ago, ifLet} from "@welshman/lib"
|
||||
import {merged} from "@welshman/store"
|
||||
import {
|
||||
getListTags,
|
||||
getRelayTagValues,
|
||||
getTagValue,
|
||||
WRAP,
|
||||
ROOM_META,
|
||||
ROOM_DELETE,
|
||||
@@ -19,10 +20,10 @@ import {
|
||||
RELAY_ADD_MEMBER,
|
||||
RELAY_REMOVE_MEMBER,
|
||||
MESSAGE,
|
||||
POLL_RESPONSE,
|
||||
isSignedEvent,
|
||||
unionFilters,
|
||||
} from "@welshman/util"
|
||||
import {PollResponse} from "nostr-tools/kinds"
|
||||
import type {Filter, List, PublishedList, TrustedEvent} from "@welshman/util"
|
||||
import {request, requestOne, Difference, DifferenceEvent} from "@welshman/net"
|
||||
import {
|
||||
@@ -269,7 +270,29 @@ const syncUserData = () => {
|
||||
|
||||
const syncSpace = (url: string) => {
|
||||
const since = ago(WEEK)
|
||||
const seen = new Set<string>()
|
||||
const controller = new AbortController()
|
||||
|
||||
const pullRoomContent = (room: string) => {
|
||||
if (!seen.has(room)) {
|
||||
seen.add(room)
|
||||
pullAndListen({
|
||||
url,
|
||||
signal: controller.signal,
|
||||
filters: [
|
||||
{kinds: [ROOM_META, ROOM_ADMINS, ROOM_MEMBERS], "#d": [room]},
|
||||
{kinds: [MESSAGE, ...CONTENT_KINDS], since, "#h": [room]},
|
||||
makeCommentFilter(CONTENT_KINDS, {since, "#h": [room]}),
|
||||
{
|
||||
kinds: [ROOM_DELETE, ROOM_JOIN, ROOM_LEAVE],
|
||||
"#h": [room],
|
||||
},
|
||||
{kinds: [PollResponse], since},
|
||||
],
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
const relayKinds = [RELAY_MEMBERS]
|
||||
const roomMetaKinds = [ROOM_META, ROOM_ADMINS, ROOM_MEMBERS, LIVEKIT_PARTICIPANTS]
|
||||
const roomDeleteKinds = [ROOM_DELETE, ROOM_JOIN, ROOM_LEAVE]
|
||||
@@ -280,10 +303,23 @@ const syncSpace = (url: string) => {
|
||||
filters: [
|
||||
{kinds: [...relayKinds, ...roomMetaKinds, ...roomDeleteKinds, ...CONTENT_KINDS, MESSAGE]},
|
||||
makeCommentFilter(CONTENT_KINDS, {since}),
|
||||
{kinds: [...REACTION_KINDS, POLL_RESPONSE], since},
|
||||
{kinds: [...REACTION_KINDS, PollResponse], since},
|
||||
],
|
||||
onEvent: event => {
|
||||
if (event.kind === ROOM_META) {
|
||||
ifLet(getTagValue("d", event.tags), pullRoomContent)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
listen({
|
||||
url,
|
||||
signal: controller.signal,
|
||||
filters: [{kinds: REACTION_KINDS}, {kinds: [PollResponse]}],
|
||||
})
|
||||
|
||||
return () => controller.abort()
|
||||
|
||||
return () => controller.abort()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user