mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 10:57:04 +00:00
Use welshman kinds
This commit is contained in:
@@ -10,6 +10,8 @@ import {
|
||||
AUTH_JOIN,
|
||||
GROUP_JOIN,
|
||||
GROUP_LEAVE,
|
||||
GROUPS,
|
||||
COMMENT,
|
||||
isSignedEvent,
|
||||
createEvent,
|
||||
displayProfile,
|
||||
@@ -53,10 +55,8 @@ import {
|
||||
} from "@welshman/app"
|
||||
import type {Relay} from "@welshman/app"
|
||||
import {
|
||||
COMMENT,
|
||||
tagRoom,
|
||||
userMembership,
|
||||
MEMBERSHIPS,
|
||||
INDEXER_RELAYS,
|
||||
NIP46_PERMS,
|
||||
loadMembership,
|
||||
@@ -239,7 +239,7 @@ export const nip29 = {
|
||||
// List updates
|
||||
|
||||
export const addSpaceMembership = async (url: string) => {
|
||||
const list = get(userMembership) || makeList({kind: MEMBERSHIPS})
|
||||
const list = get(userMembership) || makeList({kind: GROUPS})
|
||||
const event = await addToListPublicly(list, ["r", url]).reconcile(nip44EncryptToSelf)
|
||||
const relays = uniq([...ctx.app.router.FromUser().getUrls(), ...getRelayTagValues(event.tags)])
|
||||
|
||||
@@ -247,7 +247,7 @@ export const addSpaceMembership = async (url: string) => {
|
||||
}
|
||||
|
||||
export const removeSpaceMembership = async (url: string) => {
|
||||
const list = get(userMembership) || makeList({kind: MEMBERSHIPS})
|
||||
const list = get(userMembership) || makeList({kind: GROUPS})
|
||||
const pred = (t: string[]) => t[t[0] === "r" ? 1 : 2] === url
|
||||
const event = await removeFromListByPredicate(list, pred).reconcile(nip44EncryptToSelf)
|
||||
const relays = uniq([
|
||||
@@ -260,7 +260,7 @@ export const removeSpaceMembership = async (url: string) => {
|
||||
}
|
||||
|
||||
export const addRoomMembership = async (url: string, room: string) => {
|
||||
const list = get(userMembership) || makeList({kind: MEMBERSHIPS})
|
||||
const list = get(userMembership) || makeList({kind: GROUPS})
|
||||
const event = await addToListPublicly(list, ["r", url], ["group", room, url]).reconcile(
|
||||
nip44EncryptToSelf,
|
||||
)
|
||||
@@ -270,7 +270,7 @@ export const addRoomMembership = async (url: string, room: string) => {
|
||||
}
|
||||
|
||||
export const removeRoomMembership = async (url: string, room: string) => {
|
||||
const list = get(userMembership) || makeList({kind: MEMBERSHIPS})
|
||||
const list = get(userMembership) || makeList({kind: GROUPS})
|
||||
const pred = (t: string[]) => equals(["group", room, url], t)
|
||||
const event = await removeFromListByPredicate(list, pred).reconcile(nip44EncryptToSelf)
|
||||
const relays = uniq([
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
import {goto} from "$app/navigation"
|
||||
import {ctx, nthEq} from "@welshman/lib"
|
||||
import {tracker, repository} from "@welshman/app"
|
||||
import {Address, DIRECT_MESSAGE} from "@welshman/util"
|
||||
import {Address, DIRECT_MESSAGE, MESSAGE, THREAD} from "@welshman/util"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import NoteCard from "@app/components/NoteCard.svelte"
|
||||
import {deriveEvent, entityLink, ROOM, MESSAGE, THREAD} from "@app/state"
|
||||
import {deriveEvent, entityLink, ROOM} from "@app/state"
|
||||
import {makeThreadPath, makeRoomPath} from "@app/routes"
|
||||
|
||||
export let value
|
||||
|
||||
@@ -2,19 +2,13 @@
|
||||
import {page} from "$app/stores"
|
||||
import {derived} from "svelte/store"
|
||||
import {max} from "@welshman/lib"
|
||||
import {matchFilter} from "@welshman/util"
|
||||
import {matchFilter, MESSAGE} from "@welshman/util"
|
||||
import {pubkey} from "@welshman/app"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import MenuSpace from "@app/components/MenuSpace.svelte"
|
||||
import {checked, getNotification, deriveNotification, THREAD_FILTERS} from "@app/notifications"
|
||||
import {
|
||||
userMembership,
|
||||
getMembershipRoomsByUrl,
|
||||
deriveEventsForUrl,
|
||||
MESSAGE,
|
||||
GENERAL,
|
||||
} from "@app/state"
|
||||
import {userMembership, getMembershipRoomsByUrl, deriveEventsForUrl, GENERAL} from "@app/state"
|
||||
import {makeRoomPath, makeSpacePath} from "@app/routes"
|
||||
import {pushDrawer} from "@app/modal"
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
import {max} from "@welshman/lib"
|
||||
import {deriveEvents, deriveIsDeleted} from "@welshman/store"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {COMMENT} from "@welshman/util"
|
||||
import {thunks, load, pubkey, repository, formatTimestampRelative} from "@welshman/app"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Tippy from "@lib/components/Tippy.svelte"
|
||||
@@ -16,7 +17,7 @@
|
||||
import {publishDelete, publishReaction} from "@app/commands"
|
||||
import {deriveNotification} from "@app/notifications"
|
||||
import {makeSpacePath} from "@app/routes"
|
||||
import {COMMENT, PROTECTED} from "@app/state"
|
||||
import {PROTECTED} from "@app/state"
|
||||
|
||||
export let url
|
||||
export let event
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import {onMount} from "svelte"
|
||||
import type {Readable} from "svelte/store"
|
||||
import {createEditor, type Editor, EditorContent} from "svelte-tiptap"
|
||||
import {createEvent} from "@welshman/util"
|
||||
import {createEvent, THREAD} from "@welshman/util"
|
||||
import {publishThunk} from "@welshman/app"
|
||||
import {isMobile} from "@lib/html"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
@@ -11,7 +11,7 @@
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import {pushToast} from "@app/toast"
|
||||
import {THREAD, GENERAL, tagRoom, PROTECTED} from "@app/state"
|
||||
import {GENERAL, tagRoom, PROTECTED} from "@app/state"
|
||||
import {getPubkeyHints} from "@app/commands"
|
||||
import {getEditorOptions, getEditorTags} from "@lib/editor"
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {COMMENT} from "@welshman/util"
|
||||
import {pubkey} from "@welshman/app"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
@@ -6,7 +7,6 @@
|
||||
import ThreadShare from "@app/components/ThreadShare.svelte"
|
||||
import ConfirmDelete from "@app/components/ConfirmDelete.svelte"
|
||||
import {pushModal} from "@app/modal"
|
||||
import {COMMENT} from "@app/state"
|
||||
|
||||
export let url
|
||||
export let event
|
||||
|
||||
@@ -4,17 +4,9 @@ import {deriveEvents} from "@welshman/store"
|
||||
import {repository, pubkey} from "@welshman/app"
|
||||
import {prop, max, sortBy, assoc, lt, now} from "@welshman/lib"
|
||||
import type {Filter, TrustedEvent} from "@welshman/util"
|
||||
import {DIRECT_MESSAGE} from "@welshman/util"
|
||||
import {DIRECT_MESSAGE, MESSAGE, THREAD, COMMENT} from "@welshman/util"
|
||||
import {makeSpacePath} from "@app/routes"
|
||||
import {
|
||||
MESSAGE,
|
||||
THREAD,
|
||||
LEGACY_THREAD,
|
||||
COMMENT,
|
||||
deriveEventsForUrl,
|
||||
getMembershipUrls,
|
||||
userMembership,
|
||||
} from "@app/state"
|
||||
import {LEGACY_THREAD, deriveEventsForUrl, getMembershipUrls, userMembership} from "@app/state"
|
||||
|
||||
// Checked state
|
||||
|
||||
|
||||
@@ -27,6 +27,10 @@ import {
|
||||
ZAP_RESPONSE,
|
||||
DIRECT_MESSAGE,
|
||||
GROUP_META,
|
||||
MESSAGE,
|
||||
GROUPS,
|
||||
THREAD,
|
||||
COMMENT,
|
||||
getGroupTags,
|
||||
getRelayTagValues,
|
||||
getPubkeyTagValues,
|
||||
@@ -71,18 +75,10 @@ export const GENERAL = "_"
|
||||
|
||||
export const PROTECTED = ["-"]
|
||||
|
||||
export const MESSAGE = 9
|
||||
|
||||
export const LEGACY_MESSAGE = 209
|
||||
|
||||
export const THREAD = 11
|
||||
|
||||
export const LEGACY_THREAD = 309
|
||||
|
||||
export const COMMENT = 1111
|
||||
|
||||
export const MEMBERSHIPS = 10009
|
||||
|
||||
export const INDEXER_RELAYS = [
|
||||
"wss://purplepag.es/",
|
||||
"wss://relay.damus.io/",
|
||||
@@ -115,7 +111,7 @@ export const REACTION_KINDS = [REACTION, ZAP_RESPONSE]
|
||||
|
||||
export const NIP46_PERMS =
|
||||
"nip04_encrypt,nip04_decrypt,nip44_encrypt,nip44_decrypt," +
|
||||
[CLIENT_AUTH, AUTH_JOIN, MESSAGE, THREAD, COMMENT, MEMBERSHIPS, WRAP, REACTION]
|
||||
[CLIENT_AUTH, AUTH_JOIN, MESSAGE, THREAD, COMMENT, GROUPS, WRAP, REACTION]
|
||||
.map(k => `sign_event:${k}`)
|
||||
.join(",")
|
||||
|
||||
@@ -372,7 +368,7 @@ export const getMembershipRoomsByUrl = (url: string, list?: List) =>
|
||||
)
|
||||
|
||||
export const memberships = deriveEventsMapped<PublishedList>(repository, {
|
||||
filters: [{kinds: [MEMBERSHIPS]}],
|
||||
filters: [{kinds: [GROUPS]}],
|
||||
itemToEvent: item => item.event,
|
||||
eventToItem: (event: TrustedEvent) => readList(asDecryptedEvent(event)),
|
||||
})
|
||||
@@ -388,7 +384,7 @@ export const {
|
||||
load: (pubkey: string, request: Partial<SubscribeRequestWithHandlers> = {}) =>
|
||||
load({
|
||||
...request,
|
||||
filters: [{kinds: [MEMBERSHIPS], authors: [pubkey]}],
|
||||
filters: [{kinds: [GROUPS], authors: [pubkey]}],
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
RELAYS,
|
||||
INBOX_RELAYS,
|
||||
WRAP,
|
||||
MESSAGE,
|
||||
COMMENT,
|
||||
THREAD,
|
||||
getPubkeyTagValues,
|
||||
getListTags,
|
||||
} from "@welshman/util"
|
||||
@@ -55,9 +58,6 @@
|
||||
userMembership,
|
||||
ensureUnwrapped,
|
||||
canDecrypt,
|
||||
MESSAGE,
|
||||
COMMENT,
|
||||
THREAD,
|
||||
GENERAL,
|
||||
} from "@app/state"
|
||||
import {loadUserData, subscribePersistent} from "@app/commands"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import {page} from "$app/stores"
|
||||
import {now} from "@welshman/lib"
|
||||
import {subscribe} from "@welshman/app"
|
||||
import {DELETE, REACTION} from "@welshman/util"
|
||||
import {DELETE, REACTION, GROUPS} from "@welshman/util"
|
||||
import Page from "@lib/components/Page.svelte"
|
||||
import SecondaryNav from "@lib/components/SecondaryNav.svelte"
|
||||
import MenuSpace from "@app/components/MenuSpace.svelte"
|
||||
@@ -12,7 +12,7 @@
|
||||
import {pushModal} from "@app/modal"
|
||||
import {setChecked} from "@app/notifications"
|
||||
import {checkRelayConnection, checkRelayAuth, checkRelayAccess} from "@app/commands"
|
||||
import {decodeRelay, MEMBERSHIPS} from "@app/state"
|
||||
import {decodeRelay} from "@app/state"
|
||||
import {deriveNotification, SPACE_FILTERS} from "@app/notifications"
|
||||
|
||||
const url = decodeRelay($page.params.relay)
|
||||
@@ -47,7 +47,7 @@
|
||||
|
||||
const sub = subscribe({
|
||||
relays: [url],
|
||||
filters: [{kinds: [MEMBERSHIPS]}, {kinds: [DELETE, REACTION], since: now()}],
|
||||
filters: [{kinds: [GROUPS]}, {kinds: [DELETE, REACTION], since: now()}],
|
||||
})
|
||||
|
||||
return () => {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
import {sleep, now, ctx} from "@welshman/lib"
|
||||
import type {TrustedEvent, EventContent} from "@welshman/util"
|
||||
import {throttled} from "@welshman/store"
|
||||
import {createEvent, DELETE} from "@welshman/util"
|
||||
import {createEvent, DELETE, MESSAGE} from "@welshman/util"
|
||||
import {PublishStatus} from "@welshman/net"
|
||||
import {formatTimestampAsDate, load, publishThunk, deriveRelay} from "@welshman/app"
|
||||
import {slide} from "@lib/transition"
|
||||
@@ -30,7 +30,6 @@
|
||||
deriveChannelMessages,
|
||||
GENERAL,
|
||||
tagRoom,
|
||||
MESSAGE,
|
||||
LEGACY_MESSAGE,
|
||||
getMembershipRoomsByUrl,
|
||||
} from "@app/state"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import {derived} from "svelte/store"
|
||||
import {page} from "$app/stores"
|
||||
import {sortBy, min, nthEq, sleep} from "@welshman/lib"
|
||||
import {getListTags, getPubkeyTagValues} from "@welshman/util"
|
||||
import {getListTags, getPubkeyTagValues, THREAD, COMMENT} from "@welshman/util"
|
||||
import {throttled} from "@welshman/store"
|
||||
import {feedsFromFilters, makeIntersectionFeed, makeRelayFeed} from "@welshman/feeds"
|
||||
import {createFeedController, userMutes} from "@welshman/app"
|
||||
@@ -16,7 +16,7 @@
|
||||
import MenuSpaceButton from "@app/components/MenuSpaceButton.svelte"
|
||||
import ThreadItem from "@app/components/ThreadItem.svelte"
|
||||
import ThreadCreate from "@app/components/ThreadCreate.svelte"
|
||||
import {THREAD, LEGACY_THREAD, COMMENT, decodeRelay, deriveEventsForUrl} from "@app/state"
|
||||
import {LEGACY_THREAD, decodeRelay, deriveEventsForUrl} from "@app/state"
|
||||
import {THREAD_FILTERS, setChecked} from "@app/notifications"
|
||||
import {pushModal} from "@app/modal"
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {sortBy, nthEq, sleep} from "@welshman/lib"
|
||||
import {page} from "$app/stores"
|
||||
import {sortBy, nthEq, sleep} from "@welshman/lib"
|
||||
import {COMMENT} from "@welshman/util"
|
||||
import {repository} from "@welshman/app"
|
||||
import {deriveEvents} from "@welshman/store"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
@@ -13,7 +14,7 @@
|
||||
import MenuSpaceButton from "@app/components/MenuSpaceButton.svelte"
|
||||
import ThreadActions from "@app/components/ThreadActions.svelte"
|
||||
import ThreadReply from "@app/components/ThreadReply.svelte"
|
||||
import {COMMENT, deriveEvent, decodeRelay} from "@app/state"
|
||||
import {deriveEvent, decodeRelay} from "@app/state"
|
||||
import {subscribePersistent} from "@app/commands"
|
||||
import {setChecked} from "@app/notifications"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user