forked from coracle/flotilla
Compare commits
46 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 1a2c83e49b | |||
| e6c7a675a9 | |||
| 69c04f29f4 | |||
| 04c6f9b4fe | |||
| 86ec12a9db | |||
| 72b3111c64 | |||
| 6709c91779 | |||
| bb6e7495f5 | |||
| df17929681 | |||
| e083719ceb | |||
| bfdc69f18c | |||
| e7ae20afb7 | |||
| 229d92055f | |||
| 64c77cfd13 | |||
| 3a63894562 | |||
| 1d272f8b37 | |||
| bac433b640 | |||
| 62f573eac0 | |||
| b3ea62c53c | |||
| b0731503a8 | |||
| 2421c02c24 | |||
| 25e868118d | |||
| 2880044e0e | |||
| 5300404b46 | |||
| d949d58076 | |||
| 997b223e95 | |||
| ba52a97e26 | |||
| cc4c7b5fe9 | |||
| 8e2ebd11fc | |||
| 9cae4da9f4 | |||
| c05d7e99e2 | |||
| 2390599e8f | |||
| 1a4d45fa9c | |||
| 57447e5bf4 | |||
| 8e411daaef | |||
| 183aebf841 | |||
| e3e500ccc2 | |||
| e7a2535ece | |||
| 761e369313 | |||
| 5248275d73 | |||
| cb033279dd | |||
| 41d50d8c28 | |||
| a52c2b4c3c | |||
| b5917cb184 | |||
| 57348472f8 | |||
| 4b6223dc00 |
@@ -1,5 +1,36 @@
|
||||
# Changelog
|
||||
|
||||
# 1.6.0
|
||||
|
||||
* Switch back to indexeddb to fix memory and performance
|
||||
* Add pay invoice functionality
|
||||
* Add space membership management and bans
|
||||
* Add event info to profile dialog
|
||||
* Add better room membership management
|
||||
* Refactor stores for performance
|
||||
* Hide nav when keyboard is open
|
||||
* Handle flotilla links in-app
|
||||
* Fix new messages indicator z-index
|
||||
* Fix some display bugs
|
||||
* Add date to chat items
|
||||
* Refine data synchronization
|
||||
* Hide nav when keyboard is open on mobile
|
||||
|
||||
# 1.5.3
|
||||
|
||||
* Add space edit form
|
||||
* Improve room syncing
|
||||
* Return better blossom errors
|
||||
* Fix access restricted bugs
|
||||
* Add room detail dialog
|
||||
* Fix broken link to self hosting
|
||||
* Tweak shadows
|
||||
* Always join spaces when visiting them
|
||||
|
||||
# 1.5.2
|
||||
|
||||
* Fix negentropy room syncing
|
||||
|
||||
# 1.5.1
|
||||
|
||||
* Fix chat path link
|
||||
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
# Flotilla - AI Assistant Context
|
||||
|
||||
## Project Overview
|
||||
|
||||
Flotilla is a Discord-like Nostr client based on the concept of "relays as groups". It's built with SvelteKit, TypeScript, and Capacitor for cross-platform support (web, Android, iOS).
|
||||
|
||||
On boot, please run `tree -I assets src` to get an idea of the project structure.
|
||||
|
||||
## Key Dependencies
|
||||
|
||||
`@welshman/*` libraries contain the majority of nostr-related functionality.
|
||||
`@app/core/*` contains additional app-specific data stores and commands.
|
||||
|
||||
When creating an import statement, first identify what functionality you need. Search the codebase for components with similar functionality, and imitate their imports.
|
||||
|
||||
## Dependency Graph (Acyclic)
|
||||
|
||||
The project follows a strict dependency hierarchy:
|
||||
1. **External libraries** (bottom layer)
|
||||
2. **`lib/`** - Only depends on external libraries
|
||||
3. **`app/core/`** and **`app/util/`** - Can depend on `lib` only
|
||||
4. **`app/components/`** - Can depend on anything in `app` or `lib`
|
||||
5. **`routes/`** - Can depend on anything (top layer)
|
||||
|
||||
**Import Ordering Convention:** Always sort imports by dependency level:
|
||||
1. Third-party libraries first
|
||||
2. Then `lib` imports
|
||||
3. Then `app` imports
|
||||
|
||||
## Development Conventions
|
||||
|
||||
When creating components related to a given space or room, parameterize them only with the entity's identifier (i.e., `url` and `h`). Only pass additional props if they can't be derived from the identifiers. For example, a room's `members` should be derived inside the child component, not passed in by the parent.
|
||||
|
||||
Do not use null, only undefined.
|
||||
@@ -7,8 +7,8 @@ android {
|
||||
applicationId "social.flotilla"
|
||||
minSdk rootProject.ext.minSdkVersion
|
||||
targetSdk rootProject.ext.targetSdkVersion
|
||||
versionCode 33
|
||||
versionName "1.5.2"
|
||||
versionCode 35
|
||||
versionName "1.6.0"
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
aaptOptions {
|
||||
// Files and dirs to omit from the packaged assets dir, modified to accommodate modern web apps.
|
||||
|
||||
@@ -358,14 +358,14 @@
|
||||
CODE_SIGN_ENTITLEMENTS = "Flotilla Chat.entitlements";
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 24;
|
||||
CURRENT_PROJECT_VERSION = 26;
|
||||
DEVELOPMENT_TEAM = S26U9DYW3A;
|
||||
INFOPLIST_FILE = App/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = "Flotilla Chat";
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
MARKETING_VERSION = 1.5.2;
|
||||
MARKETING_VERSION = 1.6.0;
|
||||
OTHER_SWIFT_FLAGS = "$(inherited) \"-D\" \"COCOAPODS\" \"-DDEBUG\"";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = social.flotilla;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
@@ -384,14 +384,14 @@
|
||||
CODE_SIGN_ENTITLEMENTS = "Flotilla Chat.entitlements";
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
CURRENT_PROJECT_VERSION = 24;
|
||||
CURRENT_PROJECT_VERSION = 26;
|
||||
DEVELOPMENT_TEAM = S26U9DYW3A;
|
||||
INFOPLIST_FILE = App/Info.plist;
|
||||
INFOPLIST_KEY_CFBundleDisplayName = "Flotilla Chat";
|
||||
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.social-networking";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 14.0;
|
||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
|
||||
MARKETING_VERSION = 1.5.2;
|
||||
MARKETING_VERSION = 1.6.0;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = social.flotilla;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
|
||||
+12
-11
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "flotilla",
|
||||
"version": "1.5.2",
|
||||
"version": "1.6.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite dev",
|
||||
@@ -51,6 +51,7 @@
|
||||
"@capacitor/push-notifications": "^7.0.3",
|
||||
"@capawesome/capacitor-android-dark-mode-support": "^7.0.0",
|
||||
"@capawesome/capacitor-badge": "^7.0.1",
|
||||
"@getalby/lightning-tools": "^6.0.0",
|
||||
"@getalby/sdk": "^5.1.2",
|
||||
"@poppanator/sveltekit-svg": "^4.2.1",
|
||||
"@sentry/browser": "^8.55.0",
|
||||
@@ -60,16 +61,16 @@
|
||||
"@types/throttle-debounce": "^5.0.2",
|
||||
"@vite-pwa/assets-generator": "^0.2.6",
|
||||
"@vite-pwa/sveltekit": "^0.6.8",
|
||||
"@welshman/app": "^0.6.5",
|
||||
"@welshman/content": "^0.6.5",
|
||||
"@welshman/editor": "^0.6.5",
|
||||
"@welshman/feeds": "^0.6.5",
|
||||
"@welshman/lib": "^0.6.5",
|
||||
"@welshman/net": "^0.6.5",
|
||||
"@welshman/router": "^0.6.5",
|
||||
"@welshman/signer": "^0.6.5",
|
||||
"@welshman/store": "^0.6.5",
|
||||
"@welshman/util": "^0.6.5",
|
||||
"@welshman/app": "^0.7.0",
|
||||
"@welshman/content": "^0.7.0",
|
||||
"@welshman/editor": "^0.7.0",
|
||||
"@welshman/feeds": "^0.7.0",
|
||||
"@welshman/lib": "^0.7.0",
|
||||
"@welshman/net": "^0.7.0",
|
||||
"@welshman/router": "^0.7.0",
|
||||
"@welshman/signer": "^0.7.0",
|
||||
"@welshman/store": "^0.7.0",
|
||||
"@welshman/util": "^0.7.0",
|
||||
"compressorjs": "^1.2.1",
|
||||
"daisyui": "^4.12.24",
|
||||
"date-picker-svelte": "^2.16.0",
|
||||
|
||||
Generated
+86
-76
@@ -44,6 +44,9 @@ importers:
|
||||
'@capawesome/capacitor-badge':
|
||||
specifier: ^7.0.1
|
||||
version: 7.0.1(@capacitor/core@7.4.3)
|
||||
'@getalby/lightning-tools':
|
||||
specifier: ^6.0.0
|
||||
version: 6.0.0
|
||||
'@getalby/sdk':
|
||||
specifier: ^5.1.2
|
||||
version: 5.1.2(typescript@5.9.3)
|
||||
@@ -72,35 +75,35 @@ importers:
|
||||
specifier: ^0.6.8
|
||||
version: 0.6.8(@sveltejs/kit@2.46.5(@sveltejs/vite-plugin-svelte@4.0.4(svelte@5.39.12)(vite@5.4.20(@types/node@24.7.2)(terser@5.44.0)))(svelte@5.39.12)(vite@5.4.20(@types/node@24.7.2)(terser@5.44.0)))(@vite-pwa/assets-generator@0.2.6)(vite-plugin-pwa@0.21.2(@vite-pwa/assets-generator@0.2.6)(vite@5.4.20(@types/node@24.7.2)(terser@5.44.0))(workbox-build@7.3.0)(workbox-window@7.3.0))
|
||||
'@welshman/app':
|
||||
specifier: ^0.6.5
|
||||
version: 0.6.5(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/content':
|
||||
specifier: ^0.6.5
|
||||
version: 0.6.5(typescript@5.9.3)
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0(typescript@5.9.3)
|
||||
'@welshman/editor':
|
||||
specifier: ^0.6.5
|
||||
version: 0.6.5(@tiptap/extension-image@2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3)))(@tiptap/extension-link@2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3))(@tiptap/pm@2.26.3))(linkifyjs@4.3.2)(prosemirror-markdown@1.13.2)(prosemirror-model@1.25.3)(prosemirror-state@1.4.3)(prosemirror-view@1.41.3)(tiptap-markdown@0.8.10(@tiptap/core@2.26.3(@tiptap/pm@2.26.3)))(typescript@5.9.3)
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0(@tiptap/extension-image@2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3)))(@tiptap/extension-link@2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3))(@tiptap/pm@2.26.3))(linkifyjs@4.3.2)(prosemirror-markdown@1.13.2)(prosemirror-model@1.25.3)(prosemirror-state@1.4.3)(prosemirror-view@1.41.3)(tiptap-markdown@0.8.10(@tiptap/core@2.26.3(@tiptap/pm@2.26.3)))(typescript@5.9.3)
|
||||
'@welshman/feeds':
|
||||
specifier: ^0.6.5
|
||||
version: 0.6.5(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/lib':
|
||||
specifier: ^0.6.5
|
||||
version: 0.6.5
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0
|
||||
'@welshman/net':
|
||||
specifier: ^0.6.5
|
||||
version: 0.6.5(typescript@5.9.3)(ws@8.18.3)
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/router':
|
||||
specifier: ^0.6.5
|
||||
version: 0.6.5(typescript@5.9.3)(ws@8.18.3)
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/signer':
|
||||
specifier: ^0.6.5
|
||||
version: 0.6.5(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/store':
|
||||
specifier: ^0.6.5
|
||||
version: 0.6.5(typescript@5.9.3)(ws@8.18.3)
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/util':
|
||||
specifier: ^0.6.5
|
||||
version: 0.6.5(typescript@5.9.3)
|
||||
specifier: ^0.7.0
|
||||
version: 0.7.0(typescript@5.9.3)
|
||||
compressorjs:
|
||||
specifier: ^1.2.1
|
||||
version: 1.2.1
|
||||
@@ -986,6 +989,10 @@ packages:
|
||||
resolution: {integrity: sha512-dxOmJLJAh6qJ8rsbA5/Bwj7MSI9X3RkxxqmCedl5rfP+yKwNSdfu8i4EiCZN/tk2hNBJb8GHSCcPRNZfwfmEHg==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
'@getalby/lightning-tools@6.0.0':
|
||||
resolution: {integrity: sha512-jpTO+7o1N1KhV5qT6qetPK+et6ZQshCzUMCRV8+Ek1NVlVU4ITIqOWRQ3kOrb0PhSxkbGN5G3d60HCi535hbDw==}
|
||||
engines: {node: '>=14'}
|
||||
|
||||
'@getalby/sdk@5.1.2':
|
||||
resolution: {integrity: sha512-yUF9LhuvdIFOwjV1aG0ryzfwDiGBFk/CRLkRvrrM9dsE38SUjKsf1FDga5jxsKMu80nWcPZR9TiGGASWedoYPA==}
|
||||
engines: {node: '>=14'}
|
||||
@@ -1692,38 +1699,38 @@ packages:
|
||||
'@vite-pwa/assets-generator':
|
||||
optional: true
|
||||
|
||||
'@welshman/app@0.6.5':
|
||||
resolution: {integrity: sha512-hk39kKzptldZxtFbYzgrEK8Y151o75GwV6P2sK5LlkyafWlhx3SwteAcuNelcJZitoAPXi7w06W34bbwRYPx+Q==}
|
||||
'@welshman/app@0.7.0':
|
||||
resolution: {integrity: sha512-g+LSfB+KOmz683DEBjXohLATi1FO+U24LMUCMgcElFPyxCdVShL8uBz+DZWMmMsfy0A+WlzwBNd9/L+8amdcTA==}
|
||||
|
||||
'@welshman/content@0.6.5':
|
||||
resolution: {integrity: sha512-QSlkuko+2r72q3VFlOXpnnoJ6GioCgan1ysHMlKqKarKNFTL4kfqdq1yxYrFRJdQou7WuB+f9iULO0AFWkXmXg==}
|
||||
'@welshman/content@0.7.0':
|
||||
resolution: {integrity: sha512-eJSdsTOQ0VpjvTEG1/mK06Tl2Bdd8iOkPup92/IhHwodXdNHjmauPSt/L7PbV8SQsIASQWTyS48UNQ+eG2KJKA==}
|
||||
|
||||
'@welshman/editor@0.6.5':
|
||||
resolution: {integrity: sha512-3sUnUFBeaVJbJgnkZlIqFqXv/NtnxXt3Pr6BkMYi2ocDMxHsMOIsOrCcyoXg8G5IYz7FzkWHtUtM3mhaDU7YVg==}
|
||||
'@welshman/editor@0.7.0':
|
||||
resolution: {integrity: sha512-iQbrFP/Q+d2E8eBcLKPgzK8sxHQzY8wa41UHjWLrZdjwj4yUFttoiKXeRcNJHJj9Wv2vBktHTF2LUCdP80dRgg==}
|
||||
|
||||
'@welshman/feeds@0.6.5':
|
||||
resolution: {integrity: sha512-IT1kSN+Xf/MaoHAOHJftORDwJZxl3UCLizc+mvJ4ktvOT/oVu9YX5zcb0YMwiJN2N4C4FpK/BIBjxivS6QIaRQ==}
|
||||
'@welshman/feeds@0.7.0':
|
||||
resolution: {integrity: sha512-A0FjnpfONXz15QXtsDCKwUUgGK3lKlGH6Jj2uJ/X0tf5KygDr3PFS3ZYtPn0LXFAYGPjV6YI6e7hYilmoTt8QQ==}
|
||||
|
||||
'@welshman/lib@0.6.5':
|
||||
resolution: {integrity: sha512-L6NQm1QNBOTQ+ymiSFPfL+TDiW1AP64AEp633Fh1ciopaU73JFbV0P6xpLxt3qJkQFZfJRxk7gWDMaVDo3Y24w==}
|
||||
'@welshman/lib@0.7.0':
|
||||
resolution: {integrity: sha512-bjkt69D5rQPk/q6Ny7R34wksoMY8jhyAQMsm2mLgv7v68unWDjhYaUy4Q5MQcLKit0pgySSx4tUh3xFlh5TCug==}
|
||||
engines: {node: '>=12.0.0'}
|
||||
|
||||
'@welshman/net@0.6.5':
|
||||
resolution: {integrity: sha512-JcmPdWzT0aUaOWytw4EJpl9EooOstm4LcJczc9pJYk1hQE4gDix1AfW6bqBiDlTnJ5fplOW/KLgXuV1rhsKEWA==}
|
||||
'@welshman/net@0.7.0':
|
||||
resolution: {integrity: sha512-9PNiMzNPtKIh5LTlyfYQOn6N3OkNSES0OdBedbGDYGX883C35gSwpPga8MXU2gg/EJDnbF77ozAhI1V0s6pGRw==}
|
||||
|
||||
'@welshman/router@0.6.5':
|
||||
resolution: {integrity: sha512-7ZxAkCg09ZIeYh49LUlL7nFRvU4880DsMstEu2KRQQIO/wg6VZuMJh8+uKGQq5arul09rtNl1bhg0/YUFiAc/A==}
|
||||
'@welshman/router@0.7.0':
|
||||
resolution: {integrity: sha512-UOsSw4aIMAD6Mkd4jecSD7/18zwFzAES/piegwYv/pWQvX0OAFXoaoPOAbBk19II1mzTX6FzGsoIMf35LO7ZXA==}
|
||||
|
||||
'@welshman/signer@0.6.5':
|
||||
resolution: {integrity: sha512-SgQCtb0du3vpyaRVGXM43CM5S0fTh+1WWLnZEWUBkEpyRzRtI9DegTowL6+vhbNxsWB6oHn/FqY7O3HLS5rIEw==}
|
||||
'@welshman/signer@0.7.0':
|
||||
resolution: {integrity: sha512-Jom7yQhG60X/L29XjaJgAAzhvQlIDy05OEluEl6flgpNJdmbvbPfEc0mMvH8g8pK0qDvJtTIQ7957c8zbYdXCg==}
|
||||
peerDependencies:
|
||||
nostr-signer-capacitor-plugin: ~0.0.4
|
||||
|
||||
'@welshman/store@0.6.5':
|
||||
resolution: {integrity: sha512-Fdl8ygK2/pZRxbLGSWtJJGtf2wTm46RDrCF2zURDJL6e80NGmTXl7LhqpSeRKmR1sTQiwEhsRvD1lqnKAWB3xQ==}
|
||||
'@welshman/store@0.7.0':
|
||||
resolution: {integrity: sha512-oKWD5azFtJZECtwqv/DKiZfRTiZ5/hrmuRoxFtKjKDNQYCgMOThHd+ZqsgphA3Q3+bhLpzq74A/uUAontzxUCw==}
|
||||
|
||||
'@welshman/util@0.6.5':
|
||||
resolution: {integrity: sha512-BmKgDtgSk0RSnw3YyExN8Mm25TJuJnjvE/7foTENpf2bMo2+PTXwVERNmgDEHRq9MCbmTkPv4h7kJTbpywLMVA==}
|
||||
'@welshman/util@0.7.0':
|
||||
resolution: {integrity: sha512-ZLtEP107/BncZePUINHHOqzfcjkXS1ljF3UyaJeE8+kdb2X08ncTA2PAzgrs/r+NSSRWObOM4Wxf6qJSSLzkPw==}
|
||||
|
||||
'@xml-tools/parser@1.0.11':
|
||||
resolution: {integrity: sha512-aKqQ077XnR+oQtHJlrAflaZaL7qZsulWc/i/ZEooar5JiWj1eLt0+Wg28cpa+XLney107wXqneC+oG1IZvxkTA==}
|
||||
@@ -5839,6 +5846,8 @@ snapshots:
|
||||
|
||||
'@getalby/lightning-tools@5.2.1': {}
|
||||
|
||||
'@getalby/lightning-tools@6.0.0': {}
|
||||
|
||||
'@getalby/sdk@5.1.2(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@getalby/lightning-tools': 5.2.1
|
||||
@@ -6651,16 +6660,16 @@ snapshots:
|
||||
optionalDependencies:
|
||||
'@vite-pwa/assets-generator': 0.2.6
|
||||
|
||||
'@welshman/app@0.6.5(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)':
|
||||
'@welshman/app@0.7.0(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)':
|
||||
dependencies:
|
||||
'@types/throttle-debounce': 5.0.2
|
||||
'@welshman/feeds': 0.6.5(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/lib': 0.6.5
|
||||
'@welshman/net': 0.6.5(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/router': 0.6.5(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/signer': 0.6.5(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/store': 0.6.5(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/util': 0.6.5(typescript@5.9.3)
|
||||
'@welshman/feeds': 0.7.0(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/lib': 0.7.0
|
||||
'@welshman/net': 0.7.0(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/router': 0.7.0(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/signer': 0.7.0(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/store': 0.7.0(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/util': 0.7.0(typescript@5.9.3)
|
||||
fuse.js: 7.1.0
|
||||
svelte: 4.2.20
|
||||
throttle-debounce: 5.0.2
|
||||
@@ -6669,14 +6678,14 @@ snapshots:
|
||||
- typescript
|
||||
- ws
|
||||
|
||||
'@welshman/content@0.6.5(typescript@5.9.3)':
|
||||
'@welshman/content@0.7.0(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@braintree/sanitize-url': 7.1.1
|
||||
nostr-tools: 2.17.0(typescript@5.9.3)
|
||||
transitivePeerDependencies:
|
||||
- typescript
|
||||
|
||||
'@welshman/editor@0.6.5(@tiptap/extension-image@2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3)))(@tiptap/extension-link@2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3))(@tiptap/pm@2.26.3))(linkifyjs@4.3.2)(prosemirror-markdown@1.13.2)(prosemirror-model@1.25.3)(prosemirror-state@1.4.3)(prosemirror-view@1.41.3)(tiptap-markdown@0.8.10(@tiptap/core@2.26.3(@tiptap/pm@2.26.3)))(typescript@5.9.3)':
|
||||
'@welshman/editor@0.7.0(@tiptap/extension-image@2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3)))(@tiptap/extension-link@2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3))(@tiptap/pm@2.26.3))(linkifyjs@4.3.2)(prosemirror-markdown@1.13.2)(prosemirror-model@1.25.3)(prosemirror-state@1.4.3)(prosemirror-view@1.41.3)(tiptap-markdown@0.8.10(@tiptap/core@2.26.3(@tiptap/pm@2.26.3)))(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@tiptap/core': 2.26.3(@tiptap/pm@2.26.3)
|
||||
'@tiptap/extension-code': 2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3))
|
||||
@@ -6691,8 +6700,8 @@ snapshots:
|
||||
'@tiptap/extension-text': 2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3))
|
||||
'@tiptap/pm': 2.26.3
|
||||
'@tiptap/suggestion': 2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3))(@tiptap/pm@2.26.3)
|
||||
'@welshman/lib': 0.6.5
|
||||
'@welshman/util': 0.6.5(typescript@5.9.3)
|
||||
'@welshman/lib': 0.7.0
|
||||
'@welshman/util': 0.7.0(typescript@5.9.3)
|
||||
nostr-editor: 1.0.2(@tiptap/core@2.26.3(@tiptap/pm@2.26.3))(@tiptap/extension-image@2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3)))(@tiptap/extension-link@2.27.1(@tiptap/core@2.26.3(@tiptap/pm@2.26.3))(@tiptap/pm@2.26.3))(@tiptap/pm@2.26.3)(linkifyjs@4.3.2)(nostr-tools@2.17.0(typescript@5.9.3))(prosemirror-markdown@1.13.2)(prosemirror-model@1.25.3)(prosemirror-state@1.4.3)(prosemirror-view@1.41.3)(tiptap-markdown@0.8.10(@tiptap/core@2.26.3(@tiptap/pm@2.26.3)))
|
||||
nostr-tools: 2.17.0(typescript@5.9.3)
|
||||
tippy.js: 6.3.7
|
||||
@@ -6707,71 +6716,72 @@ snapshots:
|
||||
- tiptap-markdown
|
||||
- typescript
|
||||
|
||||
'@welshman/feeds@0.6.5(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)':
|
||||
'@welshman/feeds@0.7.0(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)':
|
||||
dependencies:
|
||||
'@welshman/lib': 0.6.5
|
||||
'@welshman/net': 0.6.5(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/router': 0.6.5(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/signer': 0.6.5(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/util': 0.6.5(typescript@5.9.3)
|
||||
'@welshman/lib': 0.7.0
|
||||
'@welshman/net': 0.7.0(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/router': 0.7.0(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/signer': 0.7.0(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/util': 0.7.0(typescript@5.9.3)
|
||||
trava: 1.2.1
|
||||
transitivePeerDependencies:
|
||||
- nostr-signer-capacitor-plugin
|
||||
- typescript
|
||||
- ws
|
||||
|
||||
'@welshman/lib@0.6.5':
|
||||
'@welshman/lib@0.7.0':
|
||||
dependencies:
|
||||
'@scure/base': 1.2.6
|
||||
'@types/events': 3.0.3
|
||||
events: 3.3.0
|
||||
|
||||
'@welshman/net@0.6.5(typescript@5.9.3)(ws@8.18.3)':
|
||||
'@welshman/net@0.7.0(typescript@5.9.3)(ws@8.18.3)':
|
||||
dependencies:
|
||||
'@welshman/lib': 0.6.5
|
||||
'@welshman/util': 0.6.5(typescript@5.9.3)
|
||||
'@welshman/lib': 0.7.0
|
||||
'@welshman/util': 0.7.0(typescript@5.9.3)
|
||||
events: 3.3.0
|
||||
isomorphic-ws: 5.0.0(ws@8.18.3)
|
||||
transitivePeerDependencies:
|
||||
- typescript
|
||||
- ws
|
||||
|
||||
'@welshman/router@0.6.5(typescript@5.9.3)(ws@8.18.3)':
|
||||
'@welshman/router@0.7.0(typescript@5.9.3)(ws@8.18.3)':
|
||||
dependencies:
|
||||
'@welshman/lib': 0.6.5
|
||||
'@welshman/net': 0.6.5(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/util': 0.6.5(typescript@5.9.3)
|
||||
'@welshman/lib': 0.7.0
|
||||
'@welshman/net': 0.7.0(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/util': 0.7.0(typescript@5.9.3)
|
||||
transitivePeerDependencies:
|
||||
- typescript
|
||||
- ws
|
||||
|
||||
'@welshman/signer@0.6.5(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)':
|
||||
'@welshman/signer@0.7.0(nostr-signer-capacitor-plugin@0.0.4(@capacitor/core@7.4.3))(typescript@5.9.3)(ws@8.18.3)':
|
||||
dependencies:
|
||||
'@noble/curves': 1.9.7
|
||||
'@noble/hashes': 1.8.0
|
||||
'@welshman/lib': 0.6.5
|
||||
'@welshman/net': 0.6.5(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/util': 0.6.5(typescript@5.9.3)
|
||||
'@welshman/lib': 0.7.0
|
||||
'@welshman/net': 0.7.0(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/util': 0.7.0(typescript@5.9.3)
|
||||
nostr-signer-capacitor-plugin: 0.0.4(@capacitor/core@7.4.3)
|
||||
nostr-tools: 2.17.0(typescript@5.9.3)
|
||||
transitivePeerDependencies:
|
||||
- typescript
|
||||
- ws
|
||||
|
||||
'@welshman/store@0.6.5(typescript@5.9.3)(ws@8.18.3)':
|
||||
'@welshman/store@0.7.0(typescript@5.9.3)(ws@8.18.3)':
|
||||
dependencies:
|
||||
'@welshman/lib': 0.6.5
|
||||
'@welshman/net': 0.6.5(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/util': 0.6.5(typescript@5.9.3)
|
||||
'@welshman/lib': 0.7.0
|
||||
'@welshman/net': 0.7.0(typescript@5.9.3)(ws@8.18.3)
|
||||
'@welshman/util': 0.7.0(typescript@5.9.3)
|
||||
svelte: 4.2.20
|
||||
transitivePeerDependencies:
|
||||
- typescript
|
||||
- ws
|
||||
|
||||
'@welshman/util@0.6.5(typescript@5.9.3)':
|
||||
'@welshman/util@0.7.0(typescript@5.9.3)':
|
||||
dependencies:
|
||||
'@noble/curves': 1.9.7
|
||||
'@types/ws': 8.18.1
|
||||
'@welshman/lib': 0.6.5
|
||||
'@welshman/lib': 0.7.0
|
||||
js-base64: 3.7.8
|
||||
nostr-tools: 2.17.0(typescript@5.9.3)
|
||||
nostr-wasm: 0.1.0
|
||||
|
||||
+10
@@ -392,6 +392,16 @@ progress[value]::-webkit-progress-value {
|
||||
@apply md:bottom-sai bottom-[calc(var(--saib)+3.5rem)];
|
||||
}
|
||||
|
||||
/* Keyboard open state adjustments */
|
||||
|
||||
body.keyboard-open .cb {
|
||||
@apply bottom-sai;
|
||||
}
|
||||
|
||||
body.keyboard-open .bottom-nav {
|
||||
display: none;
|
||||
}
|
||||
|
||||
/* chat view */
|
||||
|
||||
.chat__compose {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {preventDefault} from "@lib/html"
|
||||
import {randomInt, displayList, TIMEZONE, identity} from "@welshman/lib"
|
||||
import {randomInt, map, displayList, TIMEZONE, identity} from "@welshman/lib"
|
||||
import {displayRelayUrl, getTagValue, THREAD, MESSAGE, EVENT_TIME, COMMENT} from "@welshman/util"
|
||||
import type {Filter} from "@welshman/util"
|
||||
import {makeIntersectionFeed, makeRelayFeed, feedFromFilters} from "@welshman/feeds"
|
||||
@@ -13,7 +13,7 @@
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import {alerts, userSpaceUrls} from "@app/core/state"
|
||||
import {alertsById, userSpaceUrls} from "@app/core/state"
|
||||
import {requestRelayClaim} from "@app/core/requests"
|
||||
import {createAlert} from "@app/core/commands"
|
||||
import {canSendPushNotifications} from "@app/util/push"
|
||||
@@ -45,7 +45,9 @@
|
||||
|
||||
let loading = $state(false)
|
||||
let cron = $state(WEEKLY)
|
||||
let email = $state($alerts.map(a => getTagValue("email", a.tags)).filter(identity)[0] || "")
|
||||
let email = $state(
|
||||
map(a => getTagValue("email", a.tags), $alertsById.values()).filter(identity)[0] || "",
|
||||
)
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
import {sleep} from "@welshman/lib"
|
||||
import {getTagValue, getAddress} from "@welshman/util"
|
||||
import {sleep, filter} from "@welshman/lib"
|
||||
import {getTagValue, getAddress, RelayMode} from "@welshman/util"
|
||||
import {isRelayFeed, findFeed} from "@welshman/feeds"
|
||||
import {getPubkeyRelays, pubkey} from "@welshman/app"
|
||||
import Inbox from "@assets/icons/inbox.svg?dataurl"
|
||||
import Bell from "@assets/icons/bell.svg?dataurl"
|
||||
import AddCircle from "@assets/icons/add-circle.svg?dataurl"
|
||||
@@ -12,10 +13,9 @@
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {
|
||||
alerts,
|
||||
dmAlert,
|
||||
alertsById,
|
||||
deriveAlertStatus,
|
||||
userInboxRelays,
|
||||
getAlertFeed,
|
||||
userSettingsValues,
|
||||
} from "@app/core/state"
|
||||
@@ -33,7 +33,7 @@
|
||||
const dmStatus = $derived($dmAlert ? deriveAlertStatus(getAddress($dmAlert.event)) : undefined)
|
||||
|
||||
const filteredAlerts = $derived(
|
||||
$alerts.filter(alert => {
|
||||
filter(alert => {
|
||||
const feed = getAlertFeed(alert)
|
||||
|
||||
// Skip non-feeds and DM alerts
|
||||
@@ -43,7 +43,7 @@
|
||||
if (url) return findFeed(feed, f => isRelayFeed(f) && f.includes(url))
|
||||
|
||||
return true
|
||||
}),
|
||||
}, $alertsById.values()),
|
||||
)
|
||||
|
||||
const startAlert = () => pushModal(AlertAdd, {url, channel, hideSpaceField})
|
||||
@@ -59,7 +59,7 @@
|
||||
if ($dmAlert) {
|
||||
deleteAlert($dmAlert)
|
||||
} else {
|
||||
if ($userInboxRelays.length === 0) {
|
||||
if (getPubkeyRelays($pubkey!, RelayMode.Messaging).length === 0) {
|
||||
return uncheckDmAlert("Please set up your messaging relays before enabling alerts.")
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@
|
||||
</script>
|
||||
|
||||
<div class="col-4">
|
||||
<div class="card2 bg-alt flex flex-col gap-6 shadow-xl">
|
||||
<div class="card2 bg-alt flex flex-col gap-6 shadow-md">
|
||||
<div class="flex items-center justify-between">
|
||||
<strong class="flex items-center gap-3">
|
||||
<Icon icon={Inbox} />
|
||||
@@ -108,7 +108,7 @@
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card2 bg-alt flex flex-col gap-4 shadow-xl">
|
||||
<div class="card2 bg-alt flex flex-col gap-4 shadow-md">
|
||||
<div class="flex items-center justify-between">
|
||||
<strong class="flex items-center gap-3">
|
||||
<Icon icon={Bell} />
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</script>
|
||||
|
||||
<Link
|
||||
class="col-3 card2 bg-alt w-full cursor-pointer shadow-xl"
|
||||
class="col-3 card2 bg-alt w-full cursor-pointer shadow-md"
|
||||
href={makeCalendarPath(url, event.id)}>
|
||||
<CalendarEventHeader {event} />
|
||||
<div class="flex w-full flex-col items-end justify-between gap-2 sm:flex-row">
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
tagPubkey,
|
||||
sendWrapped,
|
||||
mergeThunks,
|
||||
loadInboxRelaySelections,
|
||||
inboxRelaySelectionsByPubkey,
|
||||
loadMessagingRelayList,
|
||||
messagingRelayListsByPubkey,
|
||||
} from "@welshman/app"
|
||||
import Danger from "@assets/icons/danger-triangle.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
@@ -43,36 +43,31 @@
|
||||
import ProfileCircle from "@app/components/ProfileCircle.svelte"
|
||||
import ProfileCircles from "@app/components/ProfileCircles.svelte"
|
||||
import ProfileDetail from "@app/components/ProfileDetail.svelte"
|
||||
import ProfileList from "@app/components/ProfileList.svelte"
|
||||
import ChatMembers from "@app/components/ChatMembers.svelte"
|
||||
import ChatMessage from "@app/components/ChatMessage.svelte"
|
||||
import ChatCompose from "@app/components/ChatCompose.svelte"
|
||||
import ChatComposeParent from "@app/components/ChatComposeParent.svelte"
|
||||
import ThunkToast from "@app/components/ThunkToast.svelte"
|
||||
import {
|
||||
INDEXER_RELAYS,
|
||||
userSettingsValues,
|
||||
deriveChat,
|
||||
splitChatId,
|
||||
PLATFORM_NAME,
|
||||
} from "@app/core/state"
|
||||
import {INDEXER_RELAYS, userSettingsValues, PLATFORM_NAME, deriveChat} from "@app/core/state"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {prependParent} from "@app/core/commands"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
type Props = {
|
||||
id: string
|
||||
pubkeys: string[]
|
||||
info?: Snippet
|
||||
}
|
||||
|
||||
const {id, info}: Props = $props()
|
||||
const {pubkeys, info}: Props = $props()
|
||||
|
||||
const chat = deriveChat(id)
|
||||
const pubkeys = splitChatId(id)
|
||||
const chat = deriveChat(pubkeys)
|
||||
const others = remove($pubkey!, pubkeys)
|
||||
const missingInboxes = $derived(pubkeys.filter(pk => !$inboxRelaySelectionsByPubkey.has(pk)))
|
||||
const missingRelayLists = $derived(pubkeys.filter(pk => !$messagingRelayListsByPubkey.has(pk)))
|
||||
|
||||
const showMembers = () =>
|
||||
pushModal(ProfileList, {pubkeys: others, title: `People in this conversation`})
|
||||
others.length === 1
|
||||
? pushModal(ProfileDetail, {pubkey: others[0]})
|
||||
: pushModal(ChatMembers, {pubkeys: others})
|
||||
|
||||
const replyTo = (event: TrustedEvent) => {
|
||||
parent = event
|
||||
@@ -183,7 +178,7 @@
|
||||
|
||||
onMount(() => {
|
||||
for (const pubkey of others) {
|
||||
loadInboxRelaySelections(pubkey, INDEXER_RELAYS, true)
|
||||
loadMessagingRelayList(pubkey, INDEXER_RELAYS, true)
|
||||
}
|
||||
|
||||
const observer = new ResizeObserver(() => {
|
||||
@@ -208,19 +203,17 @@
|
||||
|
||||
<PageBar>
|
||||
{#snippet title()}
|
||||
<div class="flex flex-col gap-1 sm:flex-row sm:gap-2">
|
||||
<Button class="flex flex-col gap-1 sm:flex-row sm:gap-2" onclick={showMembers}>
|
||||
{#if others.length === 0}
|
||||
<div class="row-2">
|
||||
<ProfileCircle pubkey={$pubkey!} size={5} />
|
||||
<ProfileName pubkey={$pubkey!} />
|
||||
</div>
|
||||
{:else if others.length === 1}
|
||||
{@const pubkey = others[0]}
|
||||
{@const onClick = () => pushModal(ProfileDetail, {pubkey})}
|
||||
<Button onclick={onClick} class="row-2">
|
||||
<ProfileCircle {pubkey} size={5} />
|
||||
<ProfileName {pubkey} />
|
||||
</Button>
|
||||
<div class="row-2">
|
||||
<ProfileCircle pubkey={others[0]} size={5} />
|
||||
<ProfileName pubkey={others[0]} />
|
||||
</div>
|
||||
{:else}
|
||||
<div class="flex items-center gap-2">
|
||||
<ProfileCircles pubkeys={others} size={5} />
|
||||
@@ -235,55 +228,49 @@
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
{#if others.length > 2}
|
||||
<Button onclick={showMembers} class="btn btn-link hidden sm:block"
|
||||
>Show all members</Button>
|
||||
{/if}
|
||||
{/if}
|
||||
</div>
|
||||
</Button>
|
||||
{/snippet}
|
||||
{#snippet action()}
|
||||
<div>
|
||||
{#if remove($pubkey, missingInboxes).length > 0}
|
||||
{@const count = remove($pubkey, missingInboxes).length}
|
||||
{@const label = count > 1 ? "inboxes are" : "inbox is"}
|
||||
<div
|
||||
class="row-2 badge badge-error badge-lg tooltip tooltip-left cursor-pointer"
|
||||
data-tip="{count} {label} not configured.">
|
||||
<Icon icon={Danger} />
|
||||
{count}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
{#if remove($pubkey, missingRelayLists).length > 0}
|
||||
{@const count = remove($pubkey, missingRelayLists).length}
|
||||
{@const label = count > 1 ? "lists are" : "list is"}
|
||||
<div
|
||||
class="row-2 badge badge-error badge-lg tooltip tooltip-left cursor-pointer"
|
||||
data-tip="{count} messaging {label} not configured.">
|
||||
<Icon icon={Danger} />
|
||||
{count}
|
||||
</div>
|
||||
{/if}
|
||||
{/snippet}
|
||||
</PageBar>
|
||||
|
||||
<PageContent class="flex flex-col-reverse gap-2 pt-4">
|
||||
<div bind:this={dynamicPadding}></div>
|
||||
{#if missingInboxes.includes($pubkey!)}
|
||||
{#if missingRelayLists.includes($pubkey!)}
|
||||
<div class="py-12">
|
||||
<div class="card2 col-2 m-auto max-w-md items-center text-center">
|
||||
<p class="row-2 text-lg text-error">
|
||||
<Icon icon={Danger} />
|
||||
Your inbox is not configured.
|
||||
Your messaging relays are not configured.
|
||||
</p>
|
||||
<p>
|
||||
In order to deliver messages, {PLATFORM_NAME} needs to know where to send them. Please visit
|
||||
your <Link class="link" href="/settings/relays">relay settings page</Link> to set up your inbox.
|
||||
your <Link class="link" href="/settings/relays">relay settings page</Link> to receive messages.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{:else if missingInboxes.length > 0}
|
||||
{:else if missingRelayLists.length > 0}
|
||||
<div class="py-12">
|
||||
<div class="card2 col-2 m-auto max-w-md items-center text-center">
|
||||
<p class="row-2 text-lg text-error">
|
||||
<Icon icon={Danger} />
|
||||
{missingInboxes.length}
|
||||
{missingInboxes.length > 1 ? "inboxes are" : "inbox is"} not configured.
|
||||
{missingRelayLists.length} messaging
|
||||
{missingRelayLists.length > 1 ? "lists are" : "list is"} not configured.
|
||||
</p>
|
||||
<p>
|
||||
In order to deliver messages, {PLATFORM_NAME} needs to know where to send them. Please make
|
||||
sure everyone in this conversation has set up their inbox relays.
|
||||
sure everyone in this conversation has set up their messaging relays.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {page} from "$app/stores"
|
||||
import {remove} from "@welshman/lib"
|
||||
import {remove, formatTimestamp} from "@welshman/lib"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {pubkey, loadInboxRelaySelections} from "@welshman/app"
|
||||
import {pubkey, loadMessagingRelayList} from "@welshman/app"
|
||||
import {fade} from "@lib/transition"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import ProfileName from "@app/components/ProfileName.svelte"
|
||||
@@ -27,7 +27,7 @@
|
||||
|
||||
onMount(() => {
|
||||
for (const pk of others) {
|
||||
loadInboxRelaySelections(pk)
|
||||
loadMessagingRelayList(pk)
|
||||
}
|
||||
})
|
||||
</script>
|
||||
@@ -59,13 +59,16 @@
|
||||
{/if}
|
||||
</div>
|
||||
<p class="overflow-hidden text-ellipsis whitespace-nowrap text-sm">
|
||||
<span class="opacity-50">
|
||||
<span class="opacity-70">
|
||||
{#if props.messages[0].pubkey === $pubkey}
|
||||
You:
|
||||
{/if}
|
||||
</span>
|
||||
{props.messages[0].content}
|
||||
</p>
|
||||
<p class="text-xs opacity-70">
|
||||
{formatTimestamp(props.messages[0].created_at)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</Link>
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
<script lang="ts">
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import Profile from "@app/components/Profile.svelte"
|
||||
|
||||
interface Props {
|
||||
pubkeys: string[]
|
||||
}
|
||||
|
||||
const {pubkeys}: Props = $props()
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<ModalHeader>
|
||||
{#snippet title()}
|
||||
<div>People in this conversation</div>
|
||||
{/snippet}
|
||||
</ModalHeader>
|
||||
{#each pubkeys as pubkey (pubkey)}
|
||||
<div class="card2 bg-alt">
|
||||
<Profile {pubkey} />
|
||||
</div>
|
||||
{/each}
|
||||
<Button class="btn btn-primary" onclick={() => history.back()}>Got it</Button>
|
||||
</div>
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import {waitForThunkCompletion} from "@welshman/app"
|
||||
import {RelayMode} from "@welshman/util"
|
||||
import {waitForThunkCompletion, getPubkeyRelays, pubkey} from "@welshman/app"
|
||||
import ChatSquare from "@assets/icons/chat-square.svg?dataurl"
|
||||
import Check from "@assets/icons/check.svg?dataurl"
|
||||
import Bell from "@assets/icons/bell.svg?dataurl"
|
||||
@@ -11,7 +12,7 @@
|
||||
import {setChecked} from "@app/util/notifications"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {dmAlert, userInboxRelays} from "@app/core/state"
|
||||
import {dmAlert} from "@app/core/state"
|
||||
import {deleteAlert, createDmAlert} from "@app/core/commands"
|
||||
|
||||
const startChat = () => pushModal(ChatStart, {}, {replaceState: true})
|
||||
@@ -22,7 +23,7 @@
|
||||
}
|
||||
|
||||
const enableAlerts = async () => {
|
||||
if ($userInboxRelays.length === 0) {
|
||||
if (getPubkeyRelays($pubkey!, RelayMode.Messaging).length === 0) {
|
||||
return pushToast({
|
||||
theme: "error",
|
||||
message: "Please set up your messaging relays before enabling alerts.",
|
||||
|
||||
@@ -2,21 +2,14 @@
|
||||
import {type Instance} from "tippy.js"
|
||||
import {hash, formatTimestampAsTime} from "@welshman/lib"
|
||||
import type {TrustedEvent, EventContent} from "@welshman/util"
|
||||
import {
|
||||
thunks,
|
||||
mergeThunks,
|
||||
pubkey,
|
||||
deriveProfile,
|
||||
deriveProfileDisplay,
|
||||
sendWrapped,
|
||||
} from "@welshman/app"
|
||||
import {thunks, mergeThunks, pubkey, deriveProfileDisplay, sendWrapped} from "@welshman/app"
|
||||
import {isMobile} from "@lib/html"
|
||||
import MenuDots from "@assets/icons/menu-dots.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Tippy from "@lib/components/Tippy.svelte"
|
||||
import TapTarget from "@lib/components/TapTarget.svelte"
|
||||
import Avatar from "@lib/components/Avatar.svelte"
|
||||
import ProfileCircle from "@app/components/ProfileCircle.svelte"
|
||||
import Content from "@app/components/Content.svelte"
|
||||
import ReactionSummary from "@app/components/ReactionSummary.svelte"
|
||||
import ThunkFailure from "@app/components/ThunkFailure.svelte"
|
||||
@@ -37,7 +30,6 @@
|
||||
const {event, replyTo, pubkeys, showPubkey = false}: Props = $props()
|
||||
|
||||
const isOwn = event.pubkey === $pubkey
|
||||
const profile = deriveProfile(event.pubkey)
|
||||
const profileDisplay = deriveProfileDisplay(event.pubkey)
|
||||
const thunk = mergeThunks($thunks.filter(t => t.event.id === event.id))
|
||||
const [_, colorValue] = colors[hash(event.pubkey) % colors.length]
|
||||
@@ -107,8 +99,8 @@
|
||||
<div class="flex items-center gap-2">
|
||||
{#if !isOwn}
|
||||
<Button onclick={openProfile} class="flex items-center gap-1">
|
||||
<Avatar
|
||||
src={$profile?.picture}
|
||||
<ProfileCircle
|
||||
pubkey={event.pubkey}
|
||||
class="border border-solid border-base-content"
|
||||
size={4} />
|
||||
<div class="flex items-center gap-2">
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
<ul class="menu whitespace-nowrap rounded-box bg-base-100 p-2 shadow-xl" bind:this={ul}>
|
||||
<ul class="menu whitespace-nowrap rounded-box bg-base-100 p-2 shadow-md" bind:this={ul}>
|
||||
<li>
|
||||
<Button onclick={createGoal}>
|
||||
<Icon size={4} icon={StarFallMinimalistic} />
|
||||
|
||||
@@ -6,12 +6,15 @@
|
||||
import ContentLinkDetail from "@app/components/ContentLinkDetail.svelte"
|
||||
import ContentLinkBlockImage from "@app/components/ContentLinkBlockImage.svelte"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {PLATFORM_URL} from "@app/core/state"
|
||||
|
||||
const {value, event} = $props()
|
||||
|
||||
let hideImage = $state(false)
|
||||
|
||||
const url = value.url.toString()
|
||||
const external = !url.startsWith(PLATFORM_URL)
|
||||
const href = external ? url : url.replace(PLATFORM_URL, "")
|
||||
|
||||
const loadPreview = async () => {
|
||||
const json = await postJson(dufflepud("link/preview"), {url})
|
||||
@@ -30,7 +33,7 @@
|
||||
const expand = () => pushModal(ContentLinkDetail, {value, event}, {fullscreen: true})
|
||||
</script>
|
||||
|
||||
<Link external href={url} class="my-2 block">
|
||||
<Link {external} {href} class="my-2 block">
|
||||
<div class="overflow-hidden rounded-box">
|
||||
{#if url.match(/\.(mov|webm|mp4)$/)}
|
||||
<video controls src={url} class="max-h-96 object-contain object-center">
|
||||
@@ -49,7 +52,7 @@
|
||||
<div class="bg-alt flex max-w-xl flex-col leading-normal">
|
||||
{#if preview.image && !hideImage}
|
||||
<img
|
||||
alt="Link preview"
|
||||
alt=""
|
||||
onerror={onError}
|
||||
src={preview.image}
|
||||
class="bg-alt max-h-72 rounded-t-box object-contain object-center" />
|
||||
|
||||
@@ -6,10 +6,13 @@
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import ContentLinkDetail from "@app/components/ContentLinkDetail.svelte"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {PLATFORM_URL} from "@app/core/state"
|
||||
|
||||
const {value} = $props()
|
||||
|
||||
const url = value.url.toString()
|
||||
const external = !url.startsWith(PLATFORM_URL)
|
||||
const href = external ? url : url.replace(PLATFORM_URL, "")
|
||||
|
||||
const expand = () => pushModal(ContentLinkDetail, {url}, {fullscreen: true})
|
||||
</script>
|
||||
@@ -21,7 +24,7 @@
|
||||
{displayUrl(url)}
|
||||
</a>
|
||||
{:else}
|
||||
<Link external href={url} class="link-content whitespace-nowrap">
|
||||
<Link {external} {href} class="link-content whitespace-nowrap">
|
||||
<Icon icon={LinkRound} size={3} class="inline-block" />
|
||||
{displayUrl(url)}
|
||||
</Link>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {removeNil} from "@welshman/lib"
|
||||
import {removeUndefined} from "@welshman/lib"
|
||||
import type {ProfilePointer} from "@welshman/content"
|
||||
import {deriveProfileDisplay} from "@welshman/app"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
const {value, url}: Props = $props()
|
||||
|
||||
const display = deriveProfileDisplay(value.pubkey, removeNil([url]))
|
||||
const display = deriveProfileDisplay(value.pubkey, removeUndefined([url]))
|
||||
|
||||
const openProfile = () => pushModal(ProfileDetail, {pubkey: value.pubkey, url})
|
||||
</script>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import {max, formatTimestampRelative} from "@welshman/lib"
|
||||
import {COMMENT} from "@welshman/util"
|
||||
import {load} from "@welshman/net"
|
||||
import {deriveEvents} from "@welshman/store"
|
||||
import {deriveArray, deriveEventsById} from "@welshman/store"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {repository} from "@welshman/app"
|
||||
import {notifications} from "@app/util/notifications"
|
||||
@@ -13,7 +13,7 @@
|
||||
const {url, path, event}: {url: string; path: string; event: TrustedEvent} = $props()
|
||||
|
||||
const filters = [{kinds: [COMMENT], "#E": [event.id]}]
|
||||
const replies = deriveEvents(repository, {filters})
|
||||
const replies = deriveArray(deriveEventsById({repository, filters}))
|
||||
const lastActive = $derived(max([...$replies, event].map(e => e.created_at)))
|
||||
|
||||
onMount(() => {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
import {LOCALE, secondsToDate} from "@welshman/lib"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {displayRelayUrl} from "@welshman/util"
|
||||
import {tracker} from "@welshman/app"
|
||||
import FileText from "@assets/icons/file-text.svg?dataurl"
|
||||
import Copy from "@assets/icons/copy.svg?dataurl"
|
||||
import UserCircle from "@assets/icons/user-circle.svg?dataurl"
|
||||
@@ -11,7 +12,6 @@
|
||||
import FieldInline from "@lib/components/FieldInline.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import {trackerStore} from "@app/core/state"
|
||||
import {clip} from "@app/util/toast"
|
||||
|
||||
type Props = {
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
const relays = url ? [url] : Router.get().Event(event).getUrls()
|
||||
const nevent1 = nip19.neventEncode({...event, relays})
|
||||
const seenOn = $trackerStore.getRelays(event.id)
|
||||
const seenOn = tracker.getRelays(event.id)
|
||||
const npub1 = nip19.npubEncode(event.pubkey)
|
||||
const json = JSON.stringify(event, null, 2)
|
||||
const copyLink = () => clip(nevent1)
|
||||
|
||||
@@ -3,21 +3,23 @@
|
||||
import type {Snippet} from "svelte"
|
||||
import {goto} from "$app/navigation"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {COMMENT} from "@welshman/util"
|
||||
import {pubkey, relaysByUrl} from "@welshman/app"
|
||||
import {COMMENT, ManagementMethod} from "@welshman/util"
|
||||
import {pubkey, repository, relaysByUrl, manageRelay} from "@welshman/app"
|
||||
import ShareCircle from "@assets/icons/share-circle.svg?dataurl"
|
||||
import Code2 from "@assets/icons/code-2.svg?dataurl"
|
||||
import TrashBin2 from "@assets/icons/trash-bin-2.svg?dataurl"
|
||||
import Danger from "@assets/icons/danger.svg?dataurl"
|
||||
import {setKey} from "@lib/implicit"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Confirm from "@lib/components/Confirm.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import EventInfo from "@app/components/EventInfo.svelte"
|
||||
import EventReport from "@app/components/EventReport.svelte"
|
||||
import Report from "@app/components/Report.svelte"
|
||||
import EventShare from "@app/components/EventShare.svelte"
|
||||
import EventDeleteConfirm from "@app/components/EventDeleteConfirm.svelte"
|
||||
import {hasNip29} from "@app/core/state"
|
||||
import {hasNip29, deriveUserIsSpaceAdmin} from "@app/core/state"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {makeSpaceChatPath} from "@app/util/routes"
|
||||
|
||||
type Props = {
|
||||
@@ -31,8 +33,9 @@
|
||||
const {url, noun, event, onClick, customActions}: Props = $props()
|
||||
|
||||
const isRoot = event.kind !== COMMENT
|
||||
const userIsAdmin = deriveUserIsSpaceAdmin(url)
|
||||
|
||||
const report = () => pushModal(EventReport, {url, event})
|
||||
const report = () => pushModal(Report, {url, event})
|
||||
|
||||
const showInfo = () => pushModal(EventInfo, {url, event})
|
||||
|
||||
@@ -47,6 +50,26 @@
|
||||
|
||||
const showDelete = () => pushModal(EventDeleteConfirm, {url, event})
|
||||
|
||||
const showAdminDelete = () =>
|
||||
pushModal(Confirm, {
|
||||
title: `Delete ${noun}`,
|
||||
message: `Are you sure you want to delete this ${noun.toLowerCase()} from the space?`,
|
||||
confirm: async () => {
|
||||
const {error} = await manageRelay(url, {
|
||||
method: ManagementMethod.BanEvent,
|
||||
params: [event.id],
|
||||
})
|
||||
|
||||
if (error) {
|
||||
pushToast({theme: "error", message: error})
|
||||
} else {
|
||||
pushToast({message: "Event has successfully been deleted!"})
|
||||
repository.removeEvent(event.id)
|
||||
history.back()
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
let ul: Element
|
||||
|
||||
onMount(() => {
|
||||
@@ -54,7 +77,7 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
<ul class="menu whitespace-nowrap rounded-box bg-base-100 p-2 shadow-xl" bind:this={ul}>
|
||||
<ul class="menu whitespace-nowrap rounded-box bg-base-100 p-2 shadow-md" bind:this={ul}>
|
||||
{#if isRoot}
|
||||
<li>
|
||||
<Button onclick={share}>
|
||||
@@ -84,5 +107,13 @@
|
||||
Report Content
|
||||
</Button>
|
||||
</li>
|
||||
{#if $userIsAdmin}
|
||||
<li>
|
||||
<Button class="text-error" onclick={showAdminDelete}>
|
||||
<Icon size={4} icon={TrashBin2} />
|
||||
Delete {noun}
|
||||
</Button>
|
||||
</li>
|
||||
{/if}
|
||||
{/if}
|
||||
</ul>
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
<script lang="ts">
|
||||
import {getTag, REPORT} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {deriveEvents} from "@welshman/store"
|
||||
import {pubkey, repository} from "@welshman/app"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Profile from "@app/components/Profile.svelte"
|
||||
import {publishDelete, canEnforceNip70} from "@app/core/commands"
|
||||
|
||||
const {url, event} = $props()
|
||||
|
||||
const shouldProtect = canEnforceNip70(url)
|
||||
|
||||
const reports = deriveEvents(repository, {
|
||||
filters: [{kinds: [REPORT], "#e": [event.id]}],
|
||||
})
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const deleteReport = async (report: TrustedEvent) => {
|
||||
publishDelete({event: report, relays: [url], protect: await shouldProtect})
|
||||
|
||||
if ($reports.length === 0) {
|
||||
history.back()
|
||||
}
|
||||
}
|
||||
|
||||
const getReason = (tags: string[][]) => getTag("e", tags)?.[2] || "other"
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<ModalHeader>
|
||||
{#snippet title()}
|
||||
<div>Report Details</div>
|
||||
{/snippet}
|
||||
{#snippet info()}
|
||||
<div>All reports for this event are shown below.</div>
|
||||
{/snippet}
|
||||
</ModalHeader>
|
||||
{#each $reports as report (report.id)}
|
||||
{@const reason = getReason(report.tags)}
|
||||
{@const remove = () => deleteReport(report)}
|
||||
<div class="column gap-2">
|
||||
<div class="flex justify-between">
|
||||
<div>
|
||||
<Profile pubkey={report.pubkey} {url} />
|
||||
<span>Reported this event as "{reason}"</span>
|
||||
</div>
|
||||
{#if report.pubkey === $pubkey}
|
||||
<Button class="btn-default btn" onclick={remove}>Delete Report</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{#if report.content}
|
||||
<p>"{report.content}"</p>
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
<Button class="btn btn-primary" onclick={back}>Got it</Button>
|
||||
</div>
|
||||
@@ -20,7 +20,7 @@
|
||||
const h = getTagValue("h", event.tags)
|
||||
</script>
|
||||
|
||||
<Link class="col-2 card2 bg-alt w-full cursor-pointer shadow-xl" href={makeGoalPath(url, event.id)}>
|
||||
<Link class="col-2 card2 bg-alt w-full cursor-pointer shadow-md" href={makeGoalPath(url, event.id)}>
|
||||
<p class="text-2xl">{event.content}</p>
|
||||
<Content
|
||||
event={{content: summary, tags: event.tags}}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import {now, DAY, uniq, sum} from "@welshman/lib"
|
||||
import type {Zap, TrustedEvent} from "@welshman/util"
|
||||
import {getTagValue, fromMsats, ZAP_RESPONSE} from "@welshman/util"
|
||||
import {deriveEventsMapped} from "@welshman/store"
|
||||
import {deriveItemsByKey, deriveArray} from "@welshman/store"
|
||||
import {repository, getValidZap} from "@welshman/app"
|
||||
import Bolt from "@assets/icons/bolt.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
@@ -16,11 +16,14 @@
|
||||
|
||||
const {url, event, ...props}: Props = $props()
|
||||
|
||||
const zaps = deriveEventsMapped<Zap>(repository, {
|
||||
filters: [{kinds: [ZAP_RESPONSE], "#e": [event.id]}],
|
||||
itemToEvent: item => item.response,
|
||||
eventToItem: (response: TrustedEvent) => getValidZap(response, event),
|
||||
})
|
||||
const zaps = deriveArray(
|
||||
deriveItemsByKey<Zap>({
|
||||
repository,
|
||||
getKey: zap => zap.response.id,
|
||||
filters: [{kinds: [ZAP_RESPONSE], "#e": [event.id]}],
|
||||
eventToItem: (response: TrustedEvent) => getValidZap(response, event),
|
||||
}),
|
||||
)
|
||||
|
||||
const goalAmount = parseInt(getTagValue("amount", event.tags) || "0")
|
||||
const zapAmount = $derived(fromMsats(sum($zaps.map(zap => zap.invoiceAmount))))
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="w-96 rounded-box bg-base-100 p-4 shadow-lg">
|
||||
<div class="w-96 rounded-box bg-base-100 p-4 shadow-2xl">
|
||||
<label class="input input-bordered flex w-full items-center gap-2">
|
||||
<Icon icon={Magnifier} />
|
||||
<input bind:value={searchTerm} class="grow" type="text" placeholder="Search icons..." />
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
<script lang="ts">
|
||||
import {onMount, onDestroy} from "svelte"
|
||||
import type {Nip46ResponseWithResult} from "@welshman/signer"
|
||||
import {Nip46Broker, makeSecret} from "@welshman/signer"
|
||||
import {Nip46Broker} from "@welshman/signer"
|
||||
import {makeSecret} from "@welshman/util"
|
||||
import {loginWithNip01, loginWithNip46} from "@welshman/app"
|
||||
import {preventDefault} from "@lib/html"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<script lang="ts">
|
||||
import {onMount, onDestroy} from "svelte"
|
||||
import {postJson, stripProtocol} from "@welshman/lib"
|
||||
import {Nip46Broker, makeSecret} from "@welshman/signer"
|
||||
import {normalizeRelayUrl} from "@welshman/util"
|
||||
import {Nip46Broker} from "@welshman/signer"
|
||||
import {normalizeRelayUrl, makeSecret} from "@welshman/util"
|
||||
import {addSession, makeNip46Session} from "@welshman/app"
|
||||
import {preventDefault} from "@lib/html"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<script lang="ts">
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import CardButton from "@lib/components/CardButton.svelte"
|
||||
import SpaceAvatar from "@app/components/SpaceAvatar.svelte"
|
||||
import RelayIcon from "@app/components/RelayIcon.svelte"
|
||||
import RelayName from "@app/components/RelayName.svelte"
|
||||
import RelayDescription from "@app/components/RelayDescription.svelte"
|
||||
import {makeSpacePath} from "@app/util/routes"
|
||||
@@ -13,9 +13,9 @@
|
||||
</script>
|
||||
|
||||
<Link replaceState href={path}>
|
||||
<CardButton class="btn-neutral">
|
||||
<CardButton class="btn-neutral shadow-md">
|
||||
{#snippet icon()}
|
||||
<div><SpaceAvatar {url} /></div>
|
||||
<RelayIcon {url} size={12} />
|
||||
{/snippet}
|
||||
{#snippet title()}
|
||||
<div class="flex gap-1">
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
target: element,
|
||||
props: {
|
||||
onClose: closeModals,
|
||||
fullscreen: options.fullscreen,
|
||||
children: createRawSnippet(() => ({
|
||||
render: () => "<div></div>",
|
||||
setup: (target: Element) => {
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
<script lang="ts">
|
||||
import cx from "classnames"
|
||||
import type {Snippet} from "svelte"
|
||||
import * as nip19 from "nostr-tools/nip19"
|
||||
import {formatTimestamp} from "@welshman/lib"
|
||||
import {getListTags, getPubkeyTagValues} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {Router} from "@welshman/router"
|
||||
import {userMutes} from "@welshman/app"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import {userMuteList} from "@welshman/app"
|
||||
import Danger from "@assets/icons/danger-triangle.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Profile from "@app/components/Profile.svelte"
|
||||
import ProfileName from "@app/components/ProfileName.svelte"
|
||||
import {entityLink} from "@app/core/state"
|
||||
import {goToEvent} from "@app/util/routes"
|
||||
|
||||
const {
|
||||
event,
|
||||
@@ -31,14 +28,11 @@
|
||||
class?: string
|
||||
} = $props()
|
||||
|
||||
const relays = Router.get().Event(event).getUrls()
|
||||
const nevent = nip19.neventEncode({id: event.id, relays})
|
||||
|
||||
const ignoreMute = () => {
|
||||
muted = false
|
||||
}
|
||||
|
||||
let muted = $state(getPubkeyTagValues(getListTags($userMutes)).includes(event.pubkey))
|
||||
let muted = $state(getPubkeyTagValues(getListTags($userMuteList)).includes(event.pubkey))
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-2 {restProps.class}">
|
||||
@@ -59,12 +53,11 @@
|
||||
<Profile pubkey={event.pubkey} {url} />
|
||||
{/if}
|
||||
{/if}
|
||||
<Link
|
||||
external
|
||||
href={entityLink(nevent)}
|
||||
class={cx("text-sm opacity-75", {"text-xs": minimal})}>
|
||||
<Button
|
||||
class={cx("text-sm opacity-75", {"text-xs": minimal})}
|
||||
onclick={() => goToEvent(event)}>
|
||||
{formatTimestamp(event.created_at)}
|
||||
</Link>
|
||||
</Button>
|
||||
</div>
|
||||
{@render children()}
|
||||
{/if}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import {sum} from "@welshman/lib"
|
||||
import type {Zap, TrustedEvent} from "@welshman/util"
|
||||
import {getTagValue, fromMsats, ZAP_RESPONSE} from "@welshman/util"
|
||||
import {deriveEventsMapped} from "@welshman/store"
|
||||
import {deriveItemsByKey, deriveArray} from "@welshman/store"
|
||||
import {repository, getValidZap} from "@welshman/app"
|
||||
import Bolt from "@assets/icons/bolt.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
@@ -14,11 +14,14 @@
|
||||
const content = getTagValue("summary", props.event.tags)
|
||||
const fakeEvent = {content, tags: props.event.tags}
|
||||
|
||||
const zaps = deriveEventsMapped<Zap>(repository, {
|
||||
filters: [{kinds: [ZAP_RESPONSE], "#e": [props.event.id]}],
|
||||
itemToEvent: item => item.response,
|
||||
eventToItem: (response: TrustedEvent) => getValidZap(response, props.event),
|
||||
})
|
||||
const zaps = deriveArray(
|
||||
deriveItemsByKey<Zap>({
|
||||
repository,
|
||||
getKey: zap => zap.response.id,
|
||||
filters: [{kinds: [ZAP_RESPONSE], "#e": [props.event.id]}],
|
||||
eventToItem: (response: TrustedEvent) => getValidZap(response, props.event),
|
||||
}),
|
||||
)
|
||||
|
||||
const goalAmount = parseInt(getTagValue("amount", props.event.tags) || "0")
|
||||
const zapAmount = $derived(fromMsats(sum($zaps.map(zap => zap.invoiceAmount))))
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
const openProfile = () => pushModal(ProfileDetail, {pubkey, url})
|
||||
</script>
|
||||
|
||||
<div class="card2 bg-alt flex flex-col gap-4 shadow-xl">
|
||||
<div class="card2 bg-alt flex flex-col gap-4 shadow-md">
|
||||
<div class="flex justify-between">
|
||||
<Profile {pubkey} {url} />
|
||||
<Button onclick={openProfile} class="btn btn-primary hidden sm:flex">
|
||||
|
||||
@@ -4,7 +4,15 @@
|
||||
import {goto} from "$app/navigation"
|
||||
import {splitAt} from "@welshman/lib"
|
||||
import {userProfile, shouldUnwrap} from "@welshman/app"
|
||||
import Avatar from "@lib/components/Avatar.svelte"
|
||||
import Widget from "@assets/icons/widget.svg?dataurl"
|
||||
import Compass from "@assets/icons/compass.svg?dataurl"
|
||||
import Letter from "@assets/icons/letter.svg?dataurl"
|
||||
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
|
||||
import HomeSmile from "@assets/icons/home-smile.svg?dataurl"
|
||||
import SettingsMinimalistic from "@assets/icons/settings-minimalistic.svg?dataurl"
|
||||
import UserRounded from "@assets/icons/user-rounded.svg?dataurl"
|
||||
import Settings from "@assets/icons/settings.svg?dataurl"
|
||||
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
||||
import Divider from "@lib/components/Divider.svelte"
|
||||
import PrimaryNavItem from "@lib/components/PrimaryNavItem.svelte"
|
||||
import ChatEnable from "@app/components/ChatEnable.svelte"
|
||||
@@ -15,13 +23,6 @@
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {makeSpacePath} from "@app/util/routes"
|
||||
import {notifications} from "@app/util/notifications"
|
||||
import Widget from "@assets/icons/widget.svg?dataurl"
|
||||
import Compass from "@assets/icons/compass.svg?dataurl"
|
||||
import Letter from "@assets/icons/letter.svg?dataurl"
|
||||
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
|
||||
import HomeSmile from "@assets/icons/home-smile.svg?dataurl"
|
||||
import SettingsMinimalistic from "@assets/icons/settings-minimalistic.svg?dataurl"
|
||||
import Settings from "@assets/icons/settings.svg?dataurl"
|
||||
|
||||
type Props = {
|
||||
children?: Snippet
|
||||
@@ -61,7 +62,7 @@
|
||||
<PrimaryNavItemSpace {url} />
|
||||
{:else}
|
||||
<PrimaryNavItem title="Home" href="/home" class="tooltip-right">
|
||||
<Avatar src={PLATFORM_LOGO} class="!h-10 !w-10" />
|
||||
<ImageIcon alt="Home" src={PLATFORM_LOGO} class="rounded-full" />
|
||||
</PrimaryNavItem>
|
||||
<Divider />
|
||||
{#each primarySpaceUrls as url (url)}
|
||||
@@ -73,11 +74,11 @@
|
||||
class="tooltip-right"
|
||||
onclick={showOtherSpacesMenu}
|
||||
notification={otherSpaceNotifications}>
|
||||
<Avatar icon={Widget} class="!h-10 !w-10" />
|
||||
<ImageIcon alt="Other Spaces" src={Widget} />
|
||||
</PrimaryNavItem>
|
||||
{/if}
|
||||
<PrimaryNavItem title="Add a Space" href="/discover" class="tooltip-right">
|
||||
<Avatar icon={Compass} class="!h-10 !w-10" />
|
||||
<ImageIcon alt="Add a Space" src={Compass} size={7} />
|
||||
</PrimaryNavItem>
|
||||
{/each}
|
||||
</div>
|
||||
@@ -90,17 +91,17 @@
|
||||
href="/settings/profile"
|
||||
prefix="/settings"
|
||||
class="tooltip-right">
|
||||
<Avatar src={$userProfile?.picture} class="!h-10 !w-10" />
|
||||
<ImageIcon alt="Settings" src={$userProfile?.picture || UserRounded} class="rounded-full" />
|
||||
</PrimaryNavItem>
|
||||
<PrimaryNavItem
|
||||
title="Messages"
|
||||
onclick={openChat}
|
||||
class="tooltip-right"
|
||||
notification={$notifications.has("/chat")}>
|
||||
<Avatar icon={Letter} class="!h-10 !w-10" />
|
||||
<ImageIcon alt="Messages" src={Letter} size={7} />
|
||||
</PrimaryNavItem>
|
||||
<PrimaryNavItem title="Search" href="/people" class="tooltip-right">
|
||||
<Avatar icon={Magnifier} class="!h-10 !w-10" />
|
||||
<ImageIcon alt="Search" src={Magnifier} size={7} />
|
||||
</PrimaryNavItem>
|
||||
</div>
|
||||
</div>
|
||||
@@ -109,28 +110,33 @@
|
||||
{@render children?.()}
|
||||
|
||||
<!-- a little extra something for ios -->
|
||||
<div class="fixed bottom-0 left-0 right-0 z-nav h-[var(--saib)] bg-base-100 md:hidden"></div>
|
||||
<div class="bottom-nav fixed bottom-0 left-0 right-0 z-nav h-[var(--saib)] bg-base-100 md:hidden">
|
||||
</div>
|
||||
<div
|
||||
class="border-top bottom-sai fixed left-0 right-0 z-nav h-14 border border-base-200 bg-base-100 md:hidden">
|
||||
class="bottom-nav border-top bottom-sai fixed left-0 right-0 z-nav h-14 border border-base-200 bg-base-100 md:hidden">
|
||||
<div class="content-padding-x content-sizing flex justify-between px-2">
|
||||
<div class="flex gap-2 sm:gap-6">
|
||||
<PrimaryNavItem title="Home" href="/home">
|
||||
<Avatar icon={HomeSmile} class="!h-10 !w-10" />
|
||||
<ImageIcon alt="Home" src={HomeSmile} size={7} />
|
||||
</PrimaryNavItem>
|
||||
<PrimaryNavItem
|
||||
title="Messages"
|
||||
onclick={openChat}
|
||||
notification={$notifications.has("/chat")}>
|
||||
<Avatar icon={Letter} class="!h-10 !w-10" />
|
||||
<ImageIcon alt="Messages" src={Letter} size={7} />
|
||||
</PrimaryNavItem>
|
||||
{#if PLATFORM_RELAYS.length !== 1}
|
||||
<PrimaryNavItem title="Spaces" href="/spaces" notification={anySpaceNotifications}>
|
||||
<Avatar icon={SettingsMinimalistic} class="!h-10 !w-10" />
|
||||
<ImageIcon alt="Spaces" src={SettingsMinimalistic} size={7} />
|
||||
</PrimaryNavItem>
|
||||
{/if}
|
||||
</div>
|
||||
<PrimaryNavItem title="Settings" onclick={showSettingsMenu}>
|
||||
<Avatar icon={Settings} src={$userProfile?.picture} class="!h-10 !w-10" />
|
||||
<ImageIcon
|
||||
alt="Settings"
|
||||
src={$userProfile?.picture || Settings}
|
||||
size={7}
|
||||
class="rounded-full" />
|
||||
</PrimaryNavItem>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
<script lang="ts">
|
||||
import {displayRelayUrl} from "@welshman/util"
|
||||
import PrimaryNavItem from "@lib/components/PrimaryNavItem.svelte"
|
||||
import SpaceAvatar from "@app/components/SpaceAvatar.svelte"
|
||||
import RelayIcon from "@app/components/RelayIcon.svelte"
|
||||
import {makeSpacePath, goToSpace} from "@app/util/routes"
|
||||
import {notifications} from "@app/util/notifications"
|
||||
|
||||
const {url} = $props()
|
||||
type Props = {
|
||||
url: string
|
||||
}
|
||||
|
||||
const {url}: Props = $props()
|
||||
|
||||
const onClick = () => goToSpace(url)
|
||||
</script>
|
||||
@@ -15,5 +19,5 @@
|
||||
title={displayRelayUrl(url)}
|
||||
class="tooltip-right"
|
||||
notification={$notifications.has(makeSpacePath(url))}>
|
||||
<SpaceAvatar {url} />
|
||||
<RelayIcon {url} size={7} class="rounded-full" />
|
||||
</PrimaryNavItem>
|
||||
|
||||
@@ -1,16 +1,11 @@
|
||||
<script lang="ts">
|
||||
import * as nip19 from "nostr-tools/nip19"
|
||||
import {removeNil} from "@welshman/lib"
|
||||
import {removeUndefined} from "@welshman/lib"
|
||||
import {displayPubkey} from "@welshman/util"
|
||||
import {
|
||||
deriveHandleForPubkey,
|
||||
displayHandle,
|
||||
deriveProfile,
|
||||
deriveProfileDisplay,
|
||||
} from "@welshman/app"
|
||||
import {deriveHandleForPubkey, displayHandle, deriveProfileDisplay} from "@welshman/app"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Avatar from "@lib/components/Avatar.svelte"
|
||||
import ProfileCircle from "@app/components/ProfileCircle.svelte"
|
||||
import WotScore from "@app/components/WotScore.svelte"
|
||||
import ProfileDetail from "@app/components/ProfileDetail.svelte"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
@@ -26,8 +21,7 @@
|
||||
|
||||
const {pubkey, url, showPubkey, avatarSize = 10}: Props = $props()
|
||||
|
||||
const relays = removeNil([url])
|
||||
const profile = deriveProfile(pubkey, relays)
|
||||
const relays = removeUndefined([url])
|
||||
const profileDisplay = deriveProfileDisplay(pubkey, relays)
|
||||
const handle = deriveHandleForPubkey(pubkey)
|
||||
|
||||
@@ -38,7 +32,7 @@
|
||||
|
||||
<div class="flex max-w-full items-start gap-3">
|
||||
<Button onclick={openProfile} class="py-1">
|
||||
<Avatar src={$profile?.picture} size={avatarSize} />
|
||||
<ProfileCircle {pubkey} size={avatarSize} />
|
||||
</Button>
|
||||
<div class="flex min-w-0 flex-col">
|
||||
<div class="flex items-center gap-2">
|
||||
|
||||
@@ -3,17 +3,13 @@
|
||||
import {load} from "@welshman/net"
|
||||
import {Router} from "@welshman/router"
|
||||
import type {Filter} from "@welshman/util"
|
||||
import {deriveEvents} from "@welshman/store"
|
||||
import {deriveArray, deriveEventsById} from "@welshman/store"
|
||||
import {formatTimestampRelative} from "@welshman/lib"
|
||||
import {NOTE, ROOMS, COMMENT} from "@welshman/util"
|
||||
import {repository, loadRelaySelections} from "@welshman/app"
|
||||
import {repository, loadRelayList} from "@welshman/app"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ProfileSpaces from "@app/components/ProfileSpaces.svelte"
|
||||
import {
|
||||
deriveGroupSelections,
|
||||
getSpaceUrlsFromGroupSelections,
|
||||
MESSAGE_KINDS,
|
||||
} from "@app/core/state"
|
||||
import {deriveGroupList, getSpaceUrlsFromGroupList, MESSAGE_KINDS} from "@app/core/state"
|
||||
import {goToEvent} from "@app/util/routes"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
|
||||
@@ -24,9 +20,9 @@
|
||||
|
||||
const {pubkey, url}: Props = $props()
|
||||
const filters: Filter[] = [{authors: [pubkey], limit: 1}]
|
||||
const events = deriveEvents(repository, {filters})
|
||||
const selections = deriveGroupSelections(pubkey)
|
||||
const spaceUrls = $derived(getSpaceUrlsFromGroupSelections($selections))
|
||||
const events = deriveArray(deriveEventsById({repository, filters}))
|
||||
const groupList = deriveGroupList(pubkey)
|
||||
const spaceUrls = $derived(getSpaceUrlsFromGroupList($groupList))
|
||||
|
||||
const viewEvent = () => goToEvent($events[0]!)
|
||||
|
||||
@@ -34,7 +30,7 @@
|
||||
|
||||
onMount(async () => {
|
||||
// Make sure we have their relay selections before we load their posts
|
||||
await loadRelaySelections(pubkey)
|
||||
await loadRelayList(pubkey)
|
||||
|
||||
// Load groups and at least one note, regardless of time frame
|
||||
load({
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
<script lang="ts">
|
||||
import Avatar from "@lib/components/Avatar.svelte"
|
||||
import {removeNil} from "@welshman/lib"
|
||||
import cx from "classnames"
|
||||
import {removeUndefined} from "@welshman/lib"
|
||||
import {deriveProfile} from "@welshman/app"
|
||||
import UserCircle from "@assets/icons/user-circle.svg?dataurl"
|
||||
import UserRounded from "@assets/icons/user-rounded.svg?dataurl"
|
||||
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
||||
|
||||
type Props = {
|
||||
pubkey: string
|
||||
class?: string
|
||||
size?: number
|
||||
url?: string
|
||||
} & Record<string, any>
|
||||
}
|
||||
|
||||
const {pubkey, url, ...props}: Props = $props()
|
||||
const {pubkey, url, size = 7, ...props}: Props = $props()
|
||||
|
||||
const profile = deriveProfile(pubkey, removeNil([url]))
|
||||
const profile = deriveProfile(pubkey, removeUndefined([url]))
|
||||
</script>
|
||||
|
||||
<Avatar src={$profile?.picture} icon={UserCircle} {...props} />
|
||||
<ImageIcon
|
||||
{size}
|
||||
alt=""
|
||||
class={cx(props.class, "rounded-full")}
|
||||
src={$profile?.picture || UserRounded} />
|
||||
|
||||
@@ -1,13 +1,22 @@
|
||||
<script lang="ts">
|
||||
import {getProfile} from "@welshman/app"
|
||||
import ProfileCircle from "@app/components/ProfileCircle.svelte"
|
||||
|
||||
const {...props} = $props()
|
||||
type Props = {
|
||||
pubkeys: string[]
|
||||
size?: number
|
||||
}
|
||||
|
||||
const {pubkeys, size = 7}: Props = $props()
|
||||
</script>
|
||||
|
||||
<div class="flex pr-3">
|
||||
{#each props.pubkeys.toSorted().slice(0, 15) as pubkey (pubkey)}
|
||||
{#each pubkeys
|
||||
.filter(p => getProfile(p)?.picture)
|
||||
.toSorted()
|
||||
.slice(0, 15) as pubkey (pubkey)}
|
||||
<div class="z-feature -mr-3 inline-block">
|
||||
<ProfileCircle class="h-8 w-8 bg-base-300" {pubkey} {...props} />
|
||||
<ProfileCircle class="h-8 w-8 bg-base-300" {pubkey} {size} />
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
DELETE,
|
||||
isReplaceable,
|
||||
getAddress,
|
||||
RelayMode,
|
||||
} from "@welshman/util"
|
||||
import {pubkey, publishThunk, repository} from "@welshman/app"
|
||||
import {pubkey, publishThunk, repository, derivePubkeyRelays} from "@welshman/app"
|
||||
import {preventDefault} from "@lib/html"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import AltArrowRight from "@assets/icons/alt-arrow-right.svg?dataurl"
|
||||
@@ -19,12 +20,13 @@
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {logout} from "@app/core/commands"
|
||||
import {INDEXER_RELAYS, PLATFORM_NAME, userSpaceUrls, userWriteRelays} from "@app/core/state"
|
||||
import {INDEXER_RELAYS, PLATFORM_NAME, userSpaceUrls} from "@app/core/state"
|
||||
|
||||
let progress: number | undefined = $state(undefined)
|
||||
let confirmText = $state("")
|
||||
|
||||
const CONFIRM_TEXT = "permanently delete my nostr account"
|
||||
const userWriteRelays = derivePubkeyRelays($pubkey!, RelayMode.Write)
|
||||
const confirmOk = $derived(confirmText.toLowerCase().trim() === CONFIRM_TEXT)
|
||||
const showProgress = $derived(progress !== undefined)
|
||||
|
||||
|
||||
@@ -1,19 +1,29 @@
|
||||
<script lang="ts">
|
||||
import {goto} from "$app/navigation"
|
||||
import {shouldUnwrap} from "@welshman/app"
|
||||
import {removeUndefined} from "@welshman/lib"
|
||||
import {ManagementMethod} from "@welshman/util"
|
||||
import {shouldUnwrap, manageRelay, deriveProfile, displayProfileByPubkey} 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"
|
||||
import MenuDots from "@assets/icons/menu-dots.svg?dataurl"
|
||||
import MinusCircle from "@assets/icons/minus-circle.svg?dataurl"
|
||||
import {fly} from "@lib/transition"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Avatar from "@lib/components/Avatar.svelte"
|
||||
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import Confirm from "@lib/components/Confirm.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Popover from "@lib/components/Popover.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import Profile from "@app/components/Profile.svelte"
|
||||
import ProfileInfo from "@app/components/ProfileInfo.svelte"
|
||||
import EventInfo from "@app/components/EventInfo.svelte"
|
||||
import ProfileBadges from "@app/components/ProfileBadges.svelte"
|
||||
import ChatEnable from "@app/components/ChatEnable.svelte"
|
||||
import {pubkeyLink} from "@app/core/state"
|
||||
import {pubkeyLink, deriveUserIsSpaceAdmin} from "@app/core/state"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {makeChatPath} from "@app/util/routes"
|
||||
|
||||
export type Props = {
|
||||
@@ -23,15 +33,83 @@
|
||||
|
||||
const {pubkey, url}: Props = $props()
|
||||
|
||||
const profile = deriveProfile(pubkey, removeUndefined([url]))
|
||||
|
||||
const userIsAdmin = deriveUserIsSpaceAdmin(url)
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const chatPath = makeChatPath([pubkey])
|
||||
|
||||
const showInfo = () => pushModal(EventInfo, {url, event: $profile!.event})
|
||||
|
||||
const openChat = () => ($shouldUnwrap ? goto(chatPath) : pushModal(ChatEnable, {next: chatPath}))
|
||||
|
||||
const toggleMenu = (pubkey: string) => {
|
||||
showMenu = !showMenu
|
||||
}
|
||||
|
||||
const closeMenu = () => {
|
||||
showMenu = false
|
||||
}
|
||||
|
||||
const banMember = () =>
|
||||
pushModal(Confirm, {
|
||||
title: "Ban User",
|
||||
message: `Are you sure you want to ban @${displayProfileByPubkey(pubkey)} from the space?`,
|
||||
confirm: async () => {
|
||||
const {error} = await manageRelay(url!, {
|
||||
method: ManagementMethod.BanPubkey,
|
||||
params: [pubkey],
|
||||
})
|
||||
|
||||
if (error) {
|
||||
pushToast({theme: "error", message: error})
|
||||
} else {
|
||||
pushToast({message: "User has successfully been banned!"})
|
||||
back()
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
let showMenu = $state(false)
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
<Profile showPubkey avatarSize={14} {pubkey} {url} />
|
||||
<div class="flex justify-between">
|
||||
<Profile showPubkey avatarSize={14} {pubkey} {url} />
|
||||
{#if $profile || $userIsAdmin}
|
||||
<div class="relative">
|
||||
<Button class="btn btn-circle btn-ghost btn-sm" onclick={() => toggleMenu(pubkey)}>
|
||||
<Icon icon={MenuDots} />
|
||||
</Button>
|
||||
{#if showMenu}
|
||||
<Popover hideOnClick onClose={closeMenu}>
|
||||
<ul
|
||||
transition:fly
|
||||
class="bg-alt menu absolute right-0 z-popover w-48 gap-1 rounded-box p-2 shadow-md">
|
||||
{#if $profile}
|
||||
<li>
|
||||
<Button onclick={showInfo}>
|
||||
<Icon icon={Code2} />
|
||||
User Details
|
||||
</Button>
|
||||
</li>
|
||||
{/if}
|
||||
{#if $userIsAdmin}
|
||||
<li>
|
||||
<Button class="text-error" onclick={banMember}>
|
||||
<Icon icon={MinusCircle} />
|
||||
Ban User
|
||||
</Button>
|
||||
</li>
|
||||
{/if}
|
||||
</ul>
|
||||
</Popover>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<ProfileInfo {pubkey} {url} />
|
||||
<ProfileBadges {pubkey} {url} />
|
||||
<ModalFooter>
|
||||
@@ -41,7 +119,7 @@
|
||||
</Button>
|
||||
<div class="flex gap-2">
|
||||
<Link external href={pubkeyLink(pubkey)} class="btn btn-neutral">
|
||||
<Avatar src="/coracle.png" />
|
||||
<ImageIcon alt="" src="/coracle.png" />
|
||||
Open in Coracle
|
||||
</Link>
|
||||
<Button onclick={openChat} class="btn btn-primary">
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
}
|
||||
|
||||
success = true
|
||||
pushToast({message: "Success! Please check your inbox and continue when you're ready."})
|
||||
pushToast({message: "Success! Please check your messages and continue when you're ready."})
|
||||
|
||||
await logout()
|
||||
} finally {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {removeNil} from "@welshman/lib"
|
||||
import {removeUndefined} from "@welshman/lib"
|
||||
import {deriveProfile} from "@welshman/app"
|
||||
import ContentMinimal from "@app/components/ContentMinimal.svelte"
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
const {pubkey, url}: Props = $props()
|
||||
|
||||
const profile = deriveProfile(pubkey, removeNil([url]))
|
||||
const profile = deriveProfile(pubkey, removeUndefined([url]))
|
||||
</script>
|
||||
|
||||
{#if $profile}
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
import type {Snippet} from "svelte"
|
||||
import {load} from "@welshman/net"
|
||||
import {NOTE} from "@welshman/util"
|
||||
import {fly} from "@lib/transition"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import NoteItem from "@app/components/NoteItem.svelte"
|
||||
|
||||
interface Props {
|
||||
@@ -24,16 +22,16 @@
|
||||
<div class="col-4">
|
||||
<div class="flex flex-col gap-2">
|
||||
{#await events}
|
||||
<p class="center my-12 flex">
|
||||
<Spinner loading />
|
||||
<p class="center flex min-h-6">
|
||||
<span class="loading loading-spinner"></span>
|
||||
</p>
|
||||
{:then events}
|
||||
{#each events as event (event.id)}
|
||||
<div in:fly>
|
||||
<NoteItem {url} {event} />
|
||||
</div>
|
||||
<NoteItem {url} {event} />
|
||||
{:else}
|
||||
{@render fallback?.()}
|
||||
<div class="min-h-6">
|
||||
{@render fallback?.()}
|
||||
</div>
|
||||
{/each}
|
||||
{/await}
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {removeNil} from "@welshman/lib"
|
||||
import {removeUndefined} from "@welshman/lib"
|
||||
import {deriveProfileDisplay} from "@welshman/app"
|
||||
|
||||
type Props = {
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
const {pubkey, url}: Props = $props()
|
||||
|
||||
const profileDisplay = deriveProfileDisplay(pubkey, removeNil([url]))
|
||||
const profileDisplay = deriveProfileDisplay(pubkey, removeUndefined([url]))
|
||||
</script>
|
||||
|
||||
{$profileDisplay}
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import SpaceAvatar from "@app/components/SpaceAvatar.svelte"
|
||||
import RelayIcon from "@app/components/RelayIcon.svelte"
|
||||
import RelayName from "@app/components/RelayName.svelte"
|
||||
import {makeSpacePath} from "@app/util/routes"
|
||||
import {deriveGroupSelections, getSpaceUrlsFromGroupSelections} from "@app/core/state"
|
||||
import {deriveGroupList, getSpaceUrlsFromGroupList} from "@app/core/state"
|
||||
|
||||
type Props = {
|
||||
pubkey: string
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
const {pubkey}: Props = $props()
|
||||
|
||||
const selections = deriveGroupSelections(pubkey)
|
||||
const spaceUrls = $derived(getSpaceUrlsFromGroupSelections($selections))
|
||||
const groupList = deriveGroupList(pubkey)
|
||||
const spaceUrls = $derived(getSpaceUrlsFromGroupList($groupList))
|
||||
|
||||
const back = () => history.back()
|
||||
</script>
|
||||
@@ -26,7 +26,7 @@
|
||||
{#each spaceUrls as url (url)}
|
||||
<div class="card2 bg-alt flex flex-row items-center gap-2">
|
||||
<div class="flex-shrink-0">
|
||||
<SpaceAvatar {url} />
|
||||
<RelayIcon {url} size={12} />
|
||||
</div>
|
||||
<div class="flex flex-grow flex-col">
|
||||
<RelayName {url} />
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import cx from "classnames"
|
||||
import {onMount} from "svelte"
|
||||
import type {Snippet} from "svelte"
|
||||
import {groupBy, sum, uniq, uniqBy, batch, displayList} from "@welshman/lib"
|
||||
import {groupBy, map, sum, uniq, uniqBy, batch, displayList} from "@welshman/lib"
|
||||
import {
|
||||
REPORT,
|
||||
REACTION,
|
||||
@@ -15,14 +15,14 @@
|
||||
DELETE,
|
||||
} from "@welshman/util"
|
||||
import type {TrustedEvent, EventContent, Zap} from "@welshman/util"
|
||||
import {deriveEvents, deriveEventsMapped} from "@welshman/store"
|
||||
import {deriveArray, deriveEventsById, deriveItemsByKey} from "@welshman/store"
|
||||
import {load} from "@welshman/net"
|
||||
import {pubkey, repository, getValidZap, displayProfileByPubkey} from "@welshman/app"
|
||||
import {isMobile, preventDefault, stopPropagation} from "@lib/html"
|
||||
import Danger from "@assets/icons/danger-triangle.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Reaction from "@app/components/Reaction.svelte"
|
||||
import EventReportDetails from "@app/components/EventReportDetails.svelte"
|
||||
import ReportDetails from "@app/components/ReportDetails.svelte"
|
||||
import {REACTION_KINDS} from "@app/core/state"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
|
||||
@@ -46,19 +46,22 @@
|
||||
children,
|
||||
}: Props = $props()
|
||||
|
||||
const reports = deriveEvents(repository, {
|
||||
filters: [{kinds: [REPORT], "#e": [event.id]}],
|
||||
})
|
||||
const reports = deriveArray(
|
||||
deriveEventsById({repository, filters: [{kinds: [REPORT], "#e": [event.id]}]}),
|
||||
)
|
||||
|
||||
const reactions = deriveEvents(repository, {
|
||||
filters: [{kinds: [REACTION], "#e": [event.id]}],
|
||||
})
|
||||
const reactions = deriveArray(
|
||||
deriveEventsById({repository, filters: [{kinds: [REACTION], "#e": [event.id]}]}),
|
||||
)
|
||||
|
||||
const zaps = deriveEventsMapped<Zap>(repository, {
|
||||
filters: [{kinds: [ZAP_RESPONSE], "#e": [event.id]}],
|
||||
itemToEvent: item => item.response,
|
||||
eventToItem: (response: TrustedEvent) => getValidZap(response, event),
|
||||
})
|
||||
const zaps = deriveArray(
|
||||
deriveItemsByKey<Zap>({
|
||||
repository,
|
||||
getKey: zap => zap.response.id,
|
||||
filters: [{kinds: [ZAP_RESPONSE], "#e": [event.id]}],
|
||||
eventToItem: (response: TrustedEvent) => getValidZap(response, event),
|
||||
}),
|
||||
)
|
||||
|
||||
const onReactionClick = (events: TrustedEvent[]) => {
|
||||
const reaction = events.find(e => e.pubkey === $pubkey)
|
||||
@@ -75,20 +78,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
const onReportClick = () => pushModal(EventReportDetails, {url, event})
|
||||
const onReportClick = () => pushModal(ReportDetails, {url, event})
|
||||
|
||||
const reportReasons = $derived(uniq($reports.map(e => getTag("e", e.tags)?.[2])))
|
||||
const reportReasons = $derived(uniq(map(e => getTag("e", e.tags)?.[2], $reports.values())))
|
||||
|
||||
const getReactionKey = (e: TrustedEvent) => getEmojiTag(e.content, e.tags)?.join("") || e.content
|
||||
|
||||
const groupedReactions = $derived(
|
||||
groupBy(
|
||||
getReactionKey,
|
||||
uniqBy(e => `${e.pubkey}${getReactionKey(e)}`, $reactions),
|
||||
uniqBy(e => `${e.pubkey}${getReactionKey(e)}`, $reactions.values()),
|
||||
),
|
||||
)
|
||||
|
||||
const groupedZaps = $derived(groupBy(e => getReactionKey(e.request), $zaps))
|
||||
const groupedZaps = $derived(groupBy(e => getReactionKey(e.request), $zaps.values()))
|
||||
|
||||
onMount(() => {
|
||||
const controller = new AbortController()
|
||||
@@ -137,7 +140,7 @@
|
||||
data-tip={tooltip}
|
||||
class={cx(
|
||||
reactionClass,
|
||||
"flex-inline btn btn-outline btn-neutral btn-xs gap-1 rounded-full text-xs font-normal",
|
||||
"flex-inline btn btn-outline btn-neutral btn-xs flex items-center gap-1 rounded-full text-xs font-normal",
|
||||
{
|
||||
tooltip: !noTooltip && !isMobile,
|
||||
"border-neutral-content/20": !isOwn,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<script lang="ts">
|
||||
import {deriveRelay} from "@welshman/app"
|
||||
import RemoteControllerMinimalistic from "@assets/icons/remote-controller-minimalistic.svg?dataurl"
|
||||
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
size?: number
|
||||
class?: string
|
||||
}
|
||||
|
||||
const {url, size = 7, ...props}: Props = $props()
|
||||
|
||||
const relay = deriveRelay(url)
|
||||
</script>
|
||||
|
||||
<ImageIcon {size} alt="" src={$relay?.icon || RemoteControllerMinimalistic} class={props.class} />
|
||||
@@ -1,7 +1,11 @@
|
||||
<script lang="ts">
|
||||
import {deriveRelayDisplay} from "@welshman/app"
|
||||
|
||||
const {url} = $props()
|
||||
type Props = {
|
||||
url: string
|
||||
}
|
||||
|
||||
const {url}: Props = $props()
|
||||
|
||||
const display = $derived(deriveRelayDisplay(url))
|
||||
</script>
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
<script lang="ts">
|
||||
import {deriveRelay} from "@welshman/app"
|
||||
import Ghost from "@assets/icons/ghost-smile.svg?dataurl"
|
||||
import CheckCircle from "@assets/icons/check-circle.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import RelayName from "@app/components/RelayName.svelte"
|
||||
import RelayIcon from "@app/components/RelayIcon.svelte"
|
||||
import RelayDescription from "@app/components/RelayDescription.svelte"
|
||||
import ProfileCircles from "@app/components/ProfileCircles.svelte"
|
||||
import {deriveSpaceMembers, deriveUserRooms} from "@app/core/state"
|
||||
import {deriveGroupListPubkeys, deriveUserRooms} from "@app/core/state"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
}
|
||||
|
||||
const {url}: Props = $props()
|
||||
const relay = deriveRelay(url)
|
||||
const rooms = deriveUserRooms(url)
|
||||
const members = deriveSpaceMembers(url)
|
||||
const favorited = deriveGroupListPubkeys(url)
|
||||
</script>
|
||||
|
||||
<div class="col-4 text-left">
|
||||
@@ -25,11 +23,7 @@
|
||||
<div class="avatar relative">
|
||||
<div
|
||||
class="center !flex h-12 w-12 min-w-12 rounded-full border-2 border-solid border-base-300 bg-base-300">
|
||||
{#if $relay?.icon}
|
||||
<img alt="" src={$relay.icon} />
|
||||
{:else}
|
||||
<Icon icon={Ghost} size={5} />
|
||||
{/if}
|
||||
<RelayIcon {url} />
|
||||
</div>
|
||||
</div>
|
||||
{#if $rooms.includes(url)}
|
||||
@@ -49,10 +43,10 @@
|
||||
</div>
|
||||
<RelayDescription {url} />
|
||||
</div>
|
||||
{#if $members.length > 0}
|
||||
{#if $favorited.size > 0}
|
||||
<div class="row-2 card2 card2-sm bg-alt">
|
||||
Members:
|
||||
<ProfileCircles pubkeys={$members} />
|
||||
Favorited By:
|
||||
<ProfileCircles pubkeys={Array.from($favorited)} />
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<script lang="ts">
|
||||
import {REPORT} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {deriveEventsById} from "@welshman/store"
|
||||
import {repository} from "@welshman/app"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ReportItem from "@app/components/ReportItem.svelte"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
event: TrustedEvent
|
||||
}
|
||||
|
||||
const {url, event}: Props = $props()
|
||||
|
||||
const reports = deriveEventsById({
|
||||
repository,
|
||||
filters: [{kinds: [REPORT], "#e": [event.id]}],
|
||||
})
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const onDelete = () => {
|
||||
if ($reports.size === 0) {
|
||||
back()
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<ModalHeader>
|
||||
{#snippet title()}
|
||||
<div>Report Details</div>
|
||||
{/snippet}
|
||||
{#snippet info()}
|
||||
<div>All reports for this event are shown below.</div>
|
||||
{/snippet}
|
||||
</ModalHeader>
|
||||
{#each $reports.values() as report (report.id)}
|
||||
<div class="card2 card2-sm bg-alt">
|
||||
<ReportItem {url} event={report} {onDelete} />
|
||||
</div>
|
||||
{/each}
|
||||
<Button class="btn btn-primary" onclick={back}>Got it</Button>
|
||||
</div>
|
||||
@@ -0,0 +1,93 @@
|
||||
<script lang="ts">
|
||||
import {formatTimestamp} from "@welshman/lib"
|
||||
import {getTag, getIdFilters} from "@welshman/util"
|
||||
import {load, LOCAL_RELAY_URL} from "@welshman/net"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {pubkey} from "@welshman/app"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Profile from "@app/components/Profile.svelte"
|
||||
import ProfileName from "@app/components/ProfileName.svelte"
|
||||
import ProfileDetail from "@app/components/ProfileDetail.svelte"
|
||||
import NoteContent from "@app/components/NoteContent.svelte"
|
||||
import ReportMenu from "@app/components/ReportMenu.svelte"
|
||||
import {publishDelete, canEnforceNip70} from "@app/core/commands"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {goToEvent} from "@app/util/routes"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
event: TrustedEvent
|
||||
onDelete?: () => void
|
||||
}
|
||||
|
||||
const {url, event, onDelete}: Props = $props()
|
||||
|
||||
const etag = getTag("e", event.tags)
|
||||
const ptag = getTag("p", event.tags)
|
||||
const reason = etag?.[2] || ptag?.[2]
|
||||
const shouldProtect = canEnforceNip70(url)
|
||||
|
||||
const onClick = (e: Event, event: TrustedEvent) => {
|
||||
// @ts-ignore
|
||||
if (e.target?.classList.contains("profile-name")) {
|
||||
pushModal(ProfileDetail, {pubkey: event.pubkey, url})
|
||||
} else {
|
||||
goToEvent(event)
|
||||
}
|
||||
}
|
||||
|
||||
const deleteReport = async () => {
|
||||
publishDelete({event, relays: [url], protect: await shouldProtect})
|
||||
onDelete?.()
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<div class="flex justify-between">
|
||||
<div>
|
||||
<Profile pubkey={event.pubkey} {url} avatarSize={5} />
|
||||
<span>
|
||||
Reported this event
|
||||
{#if reason}
|
||||
as "{reason}"
|
||||
{/if}
|
||||
</span>
|
||||
</div>
|
||||
{#if event.pubkey === $pubkey}
|
||||
<Button class="btn-default btn" onclick={deleteReport}>Delete Report</Button>
|
||||
{:else}
|
||||
<ReportMenu {url} {event} />
|
||||
{/if}
|
||||
</div>
|
||||
{#if event.content}
|
||||
<div class="border-l-2 border-primary pl-3">
|
||||
<NoteContent {event} />
|
||||
</div>
|
||||
{/if}
|
||||
<div class="card2 card2-sm bg-alt">
|
||||
{#if etag}
|
||||
{#await load({relays: [url, LOCAL_RELAY_URL], filters: getIdFilters([etag[1]])})}
|
||||
<p>Loading</p>
|
||||
{:then reportedEvents}
|
||||
{#if reportedEvents.length === 0}
|
||||
<p>Unable to find reported note.</p>
|
||||
{:else}
|
||||
{@const event = reportedEvents[0]}
|
||||
<Button class="col-2 w-full" onclick={(e: Event) => onClick(e, event)}>
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<span class="profile-name">
|
||||
@<ProfileName pubkey={event.pubkey} {url} />
|
||||
</span>
|
||||
<span class="text-xs opacity-75">
|
||||
{formatTimestamp(event.created_at)}
|
||||
</span>
|
||||
</div>
|
||||
<NoteContent {event} />
|
||||
</Button>
|
||||
{/if}
|
||||
{/await}
|
||||
{:else if ptag}
|
||||
<Profile pubkey={ptag[1]} />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,132 @@
|
||||
<script lang="ts">
|
||||
import {getTag, ManagementMethod} from "@welshman/util"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {manageRelay, repository, displayProfileByPubkey} from "@welshman/app"
|
||||
import InboxOut from "@assets/icons/inbox-out.svg?dataurl"
|
||||
import MenuDots from "@assets/icons/menu-dots.svg?dataurl"
|
||||
import MinusCircle from "@assets/icons/minus-circle.svg?dataurl"
|
||||
import TrashBin2 from "@assets/icons/trash-bin-2.svg?dataurl"
|
||||
import {fly} from "@lib/transition"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Popover from "@lib/components/Popover.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Confirm from "@lib/components/Confirm.svelte"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
event: TrustedEvent
|
||||
}
|
||||
|
||||
const {url, event}: Props = $props()
|
||||
|
||||
const etag = getTag("e", event.tags)
|
||||
const ptag = getTag("p", event.tags)
|
||||
|
||||
const toggleMenu = () => {
|
||||
isOpen = !isOpen
|
||||
}
|
||||
|
||||
const closeMenu = () => {
|
||||
isOpen = false
|
||||
}
|
||||
|
||||
const dismissReport = async () => {
|
||||
const {error} = await manageRelay(url, {
|
||||
method: ManagementMethod.BanEvent,
|
||||
params: [event.id, "Dismissed by admin"],
|
||||
})
|
||||
|
||||
if (error) {
|
||||
pushToast({theme: "error", message: error})
|
||||
} else {
|
||||
pushToast({message: "Content has successfully been deleted!"})
|
||||
repository.removeEvent(event.id)
|
||||
history.back()
|
||||
}
|
||||
}
|
||||
|
||||
const banContent = () => {
|
||||
const [_, id, reason = ""] = etag!
|
||||
|
||||
pushModal(Confirm, {
|
||||
title: `Delete Content`,
|
||||
message: `Are you sure you want to delete this content from the space?`,
|
||||
confirm: async () => {
|
||||
const {error} = await manageRelay(url, {
|
||||
method: ManagementMethod.BanEvent,
|
||||
params: [id, reason],
|
||||
})
|
||||
|
||||
if (error) {
|
||||
pushToast({theme: "error", message: error})
|
||||
} else {
|
||||
pushToast({message: "Content has successfully been deleted!"})
|
||||
repository.removeEvent(id)
|
||||
history.back()
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
const banMember = () => {
|
||||
const [pubkey, reason = ""] = ptag!
|
||||
|
||||
pushModal(Confirm, {
|
||||
title: "Ban User",
|
||||
message: `Are you sure you want to ban @${displayProfileByPubkey(pubkey)} from the space?`,
|
||||
confirm: async () => {
|
||||
const {error} = await manageRelay(url, {
|
||||
method: ManagementMethod.BanPubkey,
|
||||
params: [pubkey, reason],
|
||||
})
|
||||
|
||||
if (error) {
|
||||
pushToast({theme: "error", message: error})
|
||||
} else {
|
||||
pushToast({message: "User has successfully been banned!"})
|
||||
history.back()
|
||||
}
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
let isOpen = $state(false)
|
||||
</script>
|
||||
|
||||
<div class="relative">
|
||||
<Button class="btn btn-circle btn-ghost btn-sm" onclick={toggleMenu}>
|
||||
<Icon icon={MenuDots} />
|
||||
</Button>
|
||||
{#if isOpen}
|
||||
<Popover hideOnClick onClose={closeMenu}>
|
||||
<ul
|
||||
transition:fly
|
||||
class="menu absolute right-0 z-popover mt-2 w-48 gap-1 rounded-box bg-base-100 p-2 shadow-md">
|
||||
<li>
|
||||
<Button onclick={dismissReport}>
|
||||
<Icon icon={InboxOut} />
|
||||
Dismiss Report
|
||||
</Button>
|
||||
</li>
|
||||
{#if etag}
|
||||
<li>
|
||||
<Button class="text-error" onclick={banContent}>
|
||||
<Icon icon={TrashBin2} />
|
||||
Remove Content
|
||||
</Button>
|
||||
</li>
|
||||
{/if}
|
||||
{#if ptag}
|
||||
<li>
|
||||
<Button class="text-error" onclick={banMember}>
|
||||
<Icon icon={MinusCircle} />
|
||||
Ban User
|
||||
</Button>
|
||||
</li>
|
||||
{/if}
|
||||
</ul>
|
||||
</Popover>
|
||||
{/if}
|
||||
</div>
|
||||
@@ -0,0 +1,37 @@
|
||||
<script lang="ts">
|
||||
import EyeClosed from "@assets/icons/eye-closed.svg?dataurl"
|
||||
import Lock from "@assets/icons/lock.svg?dataurl"
|
||||
import Microphone from "@assets/icons/microphone.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import {deriveRoom} from "@app/core/state"
|
||||
|
||||
interface Props {
|
||||
h: any
|
||||
url: any
|
||||
}
|
||||
|
||||
const {url, h}: Props = $props()
|
||||
|
||||
const room = deriveRoom(url, h)
|
||||
</script>
|
||||
|
||||
{#if $room.isHidden}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="This room is not visible to non-members.">
|
||||
<Icon size={4} icon={EyeClosed} />
|
||||
</Button>
|
||||
{:else if $room.isPrivate}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="Only members can view messages.">
|
||||
<Icon size={4} icon={Lock} />
|
||||
</Button>
|
||||
{:else if $room.isRestricted}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="Only members can send messages.">
|
||||
<Icon size={4} icon={Microphone} />
|
||||
</Button>
|
||||
{/if}
|
||||
@@ -0,0 +1,186 @@
|
||||
<script lang="ts">
|
||||
import {goto} from "$app/navigation"
|
||||
import type {RoomMeta} from "@welshman/util"
|
||||
import {displayRelayUrl, makeRoomMeta} from "@welshman/util"
|
||||
import type {Thunk} from "@welshman/app"
|
||||
import {deleteRoom, waitForThunkError, repository, joinRoom, leaveRoom} from "@welshman/app"
|
||||
import Pen from "@assets/icons/pen.svg?dataurl"
|
||||
import TrashBin2 from "@assets/icons/trash-bin-2.svg?dataurl"
|
||||
import Login3 from "@assets/icons/login-3.svg?dataurl"
|
||||
import ClockCircle from "@assets/icons/clock-circle.svg?dataurl"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import EyeClosed from "@assets/icons/eye-closed.svg?dataurl"
|
||||
import MinusCircle from "@assets/icons/minus-circle.svg?dataurl"
|
||||
import Lock from "@assets/icons/lock.svg?dataurl"
|
||||
import Microphone from "@assets/icons/microphone.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Confirm from "@lib/components/Confirm.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import ProfileCircles from "@app/components/ProfileCircles.svelte"
|
||||
import RoomMembers from "@app/components/RoomMembers.svelte"
|
||||
import RoomEdit from "@app/components/RoomEdit.svelte"
|
||||
import RoomName from "@app/components/RoomName.svelte"
|
||||
import RoomImage from "@app/components/RoomImage.svelte"
|
||||
import {
|
||||
deriveRoom,
|
||||
deriveRoomMembers,
|
||||
deriveUserIsRoomAdmin,
|
||||
deriveUserRoomMembershipStatus,
|
||||
MembershipStatus,
|
||||
} from "@app/core/state"
|
||||
import {makeSpacePath} from "@app/util/routes"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
h: string
|
||||
}
|
||||
|
||||
const {url, h}: Props = $props()
|
||||
|
||||
const room = deriveRoom(url, h)
|
||||
const members = deriveRoomMembers(url, h)
|
||||
const userIsAdmin = deriveUserIsRoomAdmin(url, h)
|
||||
const membershipStatus = deriveUserRoomMembershipStatus(url, h)
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const startEdit = () => pushModal(RoomEdit, {url, h})
|
||||
|
||||
const handleLoading = async (f: (url: string, room: RoomMeta) => Thunk) => {
|
||||
loading = true
|
||||
|
||||
try {
|
||||
const message = await waitForThunkError(f(url, makeRoomMeta({h})))
|
||||
|
||||
if (message && !message.startsWith("duplicate:")) {
|
||||
pushToast({theme: "error", message})
|
||||
}
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
}
|
||||
|
||||
const join = () => handleLoading(joinRoom)
|
||||
|
||||
const leave = () => handleLoading(leaveRoom)
|
||||
|
||||
const showMembers = () => pushModal(RoomMembers, {url, h})
|
||||
|
||||
const startDelete = () =>
|
||||
pushModal(Confirm, {
|
||||
title: "Are you sure you want to delete this room?",
|
||||
message:
|
||||
"This room will no longer be accessible to space members, and all messages posted to it will be deleted.",
|
||||
confirm: async () => {
|
||||
const thunk = deleteRoom(url, $room)
|
||||
const message = await waitForThunkError(thunk)
|
||||
|
||||
if (message) {
|
||||
repository.removeEvent(thunk.event.id)
|
||||
pushToast({theme: "error", message})
|
||||
} else {
|
||||
goto(makeSpacePath(url))
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
let loading = $state(false)
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-3">
|
||||
<div class="flex justify-between">
|
||||
<div class="flex gap-3">
|
||||
<RoomImage {url} {h} size={8} />
|
||||
<div class="flex min-w-0 flex-col">
|
||||
<RoomName {url} {h} class="text-2xl" />
|
||||
<span class="text-primary">{displayRelayUrl(url)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-2 gap-2">
|
||||
{#if $room?.isRestricted}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="Only members can send messages.">
|
||||
<Icon size={4} icon={Microphone} />
|
||||
</Button>
|
||||
{/if}
|
||||
{#if $room?.isPrivate}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="Only members can view messages.">
|
||||
<Icon size={4} icon={Lock} />
|
||||
</Button>
|
||||
{/if}
|
||||
{#if $room?.isHidden}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="This room is not visible to non-members.">
|
||||
<Icon size={4} icon={EyeClosed} />
|
||||
</Button>
|
||||
{/if}
|
||||
{#if $room?.isClosed}
|
||||
<Button
|
||||
class="btn btn-neutral btn-sm tooltip tooltip-left"
|
||||
data-tip="Requests to join this room will be ignored.">
|
||||
<Icon size={4} icon={MinusCircle} />
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{#if $room?.about}
|
||||
<p>{$room.about}</p>
|
||||
{/if}
|
||||
{#if $members.length > 0}
|
||||
<div class="card2 card2-sm bg-alt flex items-center justify-between gap-4">
|
||||
<div class="flex items-center gap-4">
|
||||
<span>Members:</span>
|
||||
<ProfileCircles pubkeys={$members} />
|
||||
</div>
|
||||
<Button class="btn btn-neutral btn-sm" onclick={showMembers}>View All</Button>
|
||||
</div>
|
||||
{/if}
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
<div class="flex gap-2">
|
||||
{#if $userIsAdmin}
|
||||
<Button class="btn btn-outline btn-error" onclick={startDelete}>
|
||||
<Icon icon={TrashBin2} />
|
||||
<span class="hidden md:inline">Delete Room</span>
|
||||
</Button>
|
||||
<Button class="btn btn-primary" onclick={startEdit}>
|
||||
<Icon icon={Pen} />
|
||||
Edit Room
|
||||
</Button>
|
||||
{:else if $membershipStatus === MembershipStatus.Initial}
|
||||
<Button class="btn btn-neutral" disabled={loading} onclick={join}>
|
||||
{#if loading}
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
{:else}
|
||||
<Icon icon={Login3} />
|
||||
{/if}
|
||||
Join member list
|
||||
</Button>
|
||||
{:else if $membershipStatus === MembershipStatus.Pending}
|
||||
<Button class="btn btn-neutral">
|
||||
<Icon icon={ClockCircle} />
|
||||
Membership pending
|
||||
</Button>
|
||||
{:else}
|
||||
<Button class="btn btn-neutral" disabled={loading} onclick={leave}>
|
||||
{#if loading}
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
{:else}
|
||||
<Icon icon={Login3} />
|
||||
{/if}
|
||||
Leave member list
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
</ModalFooter>
|
||||
</div>
|
||||
@@ -2,20 +2,15 @@
|
||||
import {goto} from "$app/navigation"
|
||||
import type {RoomMeta} from "@welshman/util"
|
||||
import {displayRelayUrl} from "@welshman/util"
|
||||
import {deleteRoom, waitForThunkError, repository} from "@welshman/app"
|
||||
import TrashBin2 from "@assets/icons/trash-bin-2.svg?dataurl"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Confirm from "@lib/components/Confirm.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import RoomForm from "@app/components/RoomForm.svelte"
|
||||
import {deriveRoom} from "@app/core/state"
|
||||
import {makeSpacePath} from "@app/util/routes"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
@@ -29,24 +24,6 @@
|
||||
const back = () => history.back()
|
||||
|
||||
const onsubmit = (room: RoomMeta) => goto(makeSpacePath(url, h))
|
||||
|
||||
const startDelete = () =>
|
||||
pushModal(Confirm, {
|
||||
title: "Are you sure you want to delete this room?",
|
||||
message:
|
||||
"This room will no longer be accessible to space members, and all messages posted to it will be deleted.",
|
||||
confirm: async () => {
|
||||
const thunk = deleteRoom(url, $room)
|
||||
const message = await waitForThunkError(thunk)
|
||||
|
||||
if (message) {
|
||||
repository.removeEvent(thunk.event.id)
|
||||
pushToast({theme: "error", message})
|
||||
} else {
|
||||
goto(makeSpacePath(url))
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<RoomForm {url} {onsubmit} initialValues={$room}>
|
||||
@@ -68,15 +45,9 @@
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
<div class="flex gap-2">
|
||||
<Button class="btn btn-outline btn-error" onclick={startDelete}>
|
||||
<Icon icon={TrashBin2} />
|
||||
<span class="hidden md:inline">Delete Room</span>
|
||||
</Button>
|
||||
<Button type="submit" class="btn btn-primary" disabled={loading}>
|
||||
<Spinner {loading}>Save Changes</Spinner>
|
||||
</Button>
|
||||
</div>
|
||||
<Button type="submit" class="btn btn-primary" disabled={loading}>
|
||||
<Spinner {loading}>Save Changes</Spinner>
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
{/snippet}
|
||||
</RoomForm>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import StickerSmileSquare from "@assets/icons/sticker-smile-square.svg?dataurl"
|
||||
import Hashtag from "@assets/icons/hashtag.svg?dataurl"
|
||||
import UploadMinimalistic from "@assets/icons/upload-minimalistic.svg?dataurl"
|
||||
import {preventDefault, compressFile} from "@lib/html"
|
||||
import {preventDefault} from "@lib/html"
|
||||
import FieldInline from "@lib/components/FieldInline.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
||||
@@ -30,7 +30,7 @@
|
||||
const room = $state.snapshot(values)
|
||||
|
||||
if (imageFile) {
|
||||
const {error, result} = await uploadFile(imageFile)
|
||||
const {error, result} = await uploadFile(imageFile, {maxWidth: 128, maxHeight: 128})
|
||||
|
||||
if (error) {
|
||||
return pushToast({theme: "error", message: error})
|
||||
@@ -38,8 +38,6 @@
|
||||
|
||||
room.picture = result.url
|
||||
room.pictureMeta = result.tags
|
||||
} else if (selectedIcon) {
|
||||
room.picture = selectedIcon
|
||||
}
|
||||
|
||||
const createMessage = await waitForThunkError(createRoom(url, room))
|
||||
@@ -76,29 +74,34 @@
|
||||
let loading = $state(false)
|
||||
let imageFile = $state<File | undefined>()
|
||||
let imagePreview = $state(initialValues.picture)
|
||||
let selectedIcon = $state<string | undefined>()
|
||||
|
||||
const handleImageUpload = async (event: Event) => {
|
||||
const file = (event.target as HTMLInputElement).files?.[0]
|
||||
|
||||
if (file && file.type.startsWith("image/")) {
|
||||
selectedIcon = undefined
|
||||
imageFile = await compressFile(file, {maxWidth: 64, maxHeight: 64})
|
||||
|
||||
const reader = new FileReader()
|
||||
|
||||
reader.onload = e => {
|
||||
imageFile = file
|
||||
imagePreview = e.target?.result as string
|
||||
}
|
||||
|
||||
reader.readAsDataURL(imageFile)
|
||||
reader.readAsDataURL(file)
|
||||
}
|
||||
}
|
||||
|
||||
const handleIconSelect = (iconUrl: string) => {
|
||||
imageFile = undefined
|
||||
imagePreview = undefined
|
||||
selectedIcon = iconUrl
|
||||
imagePreview = iconUrl
|
||||
|
||||
const parts = iconUrl.split(",")
|
||||
const imageData = atob(parts[1])
|
||||
const result = new Uint8Array(imageData.length)
|
||||
|
||||
for (let n = 0; n < imageData.length; n++) {
|
||||
result[n] = imageData.charCodeAt(n)
|
||||
}
|
||||
|
||||
imageFile = new File([result], `icon.svg`, {type: "image/svg+xml"})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -114,12 +117,7 @@
|
||||
{#if imagePreview}
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-sm opacity-75">Selected:</span>
|
||||
<ImageIcon src={imagePreview} alt="Room icon preview" />
|
||||
</div>
|
||||
{:else if selectedIcon}
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-sm opacity-75">Selected:</span>
|
||||
<Icon icon={selectedIcon} class="h-8 w-8" />
|
||||
<ImageIcon src={imagePreview} alt="" class="rounded-lg" />
|
||||
</div>
|
||||
{:else}
|
||||
<span class="text-sm opacity-75">No icon selected</span>
|
||||
@@ -146,9 +144,7 @@
|
||||
{#snippet input()}
|
||||
<label class="input input-bordered flex w-full items-center gap-2">
|
||||
{#if imagePreview}
|
||||
<ImageIcon src={imagePreview} alt="Room icon preview" />
|
||||
{:else if selectedIcon}
|
||||
<Icon icon={selectedIcon} class="h-8 w-8" />
|
||||
<ImageIcon src={imagePreview} alt="" class="rounded-lg" />
|
||||
{:else}
|
||||
<Icon icon={Hashtag} />
|
||||
{/if}
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
<script lang="ts">
|
||||
import Hashtag from "@assets/icons/hashtag.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
||||
import {deriveRoom} from "@app/core/state"
|
||||
|
||||
interface Props {
|
||||
h: string
|
||||
url: string
|
||||
size?: number
|
||||
}
|
||||
|
||||
const {url, h, size = 5}: Props = $props()
|
||||
|
||||
const room = deriveRoom(url, h)
|
||||
</script>
|
||||
|
||||
{#if $room.picture}
|
||||
<ImageIcon src={$room.picture} {size} alt="" class="rounded-lg" />
|
||||
{:else}
|
||||
<Icon icon={Hashtag} {size} />
|
||||
{/if}
|
||||
@@ -7,7 +7,6 @@
|
||||
thunks,
|
||||
pubkey,
|
||||
mergeThunks,
|
||||
deriveProfile,
|
||||
deriveProfileDisplay,
|
||||
displayProfileByPubkey,
|
||||
} from "@welshman/app"
|
||||
@@ -16,12 +15,12 @@
|
||||
import Reply from "@assets/icons/reply-2.svg?dataurl"
|
||||
import ReplyAlt from "@assets/icons/reply.svg?dataurl"
|
||||
import TapTarget from "@lib/components/TapTarget.svelte"
|
||||
import Avatar from "@lib/components/Avatar.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ThunkFailure from "@app/components/ThunkFailure.svelte"
|
||||
import ProfileDetail from "@app/components/ProfileDetail.svelte"
|
||||
import ProfileCircle from "@app/components/ProfileCircle.svelte"
|
||||
import ReactionSummary from "@app/components/ReactionSummary.svelte"
|
||||
import RoomItemZapButton from "@app/components/RoomItemZapButton.svelte"
|
||||
import RoomItemEmojiButton from "@app/components/RoomItemEmojiButton.svelte"
|
||||
@@ -56,7 +55,6 @@
|
||||
const path = getRoomItemPath(url, event)
|
||||
const shouldProtect = canEnforceNip70(url)
|
||||
const today = formatTimestampAsDate(now())
|
||||
const profile = deriveProfile(event.pubkey, [url])
|
||||
const profileDisplay = deriveProfileDisplay(event.pubkey, [url])
|
||||
const thunk = mergeThunks($thunks.filter(t => t.event.id === event.id))
|
||||
const [_, colorValue] = colors[hash(event.pubkey) % colors.length]
|
||||
@@ -83,7 +81,10 @@
|
||||
<div class="flex w-full gap-3 overflow-auto">
|
||||
{#if showPubkey}
|
||||
<Button onclick={openProfile} class="flex items-start">
|
||||
<Avatar src={$profile?.picture} class="border border-solid border-base-content" size={8} />
|
||||
<ProfileCircle
|
||||
pubkey={event.pubkey}
|
||||
class="border border-solid border-base-content"
|
||||
size={8} />
|
||||
</Button>
|
||||
{:else}
|
||||
<div class="w-8 min-w-8 max-w-8"></div>
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
<script lang="ts">
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {pubkey} from "@welshman/app"
|
||||
import {ManagementMethod} from "@welshman/util"
|
||||
import {pubkey, manageRelay, repository} from "@welshman/app"
|
||||
import Code2 from "@assets/icons/code-2.svg?dataurl"
|
||||
import TrashBin2 from "@assets/icons/trash-bin-2.svg?dataurl"
|
||||
import Danger from "@assets/icons/danger.svg?dataurl"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Confirm from "@lib/components/Confirm.svelte"
|
||||
import EventInfo from "@app/components/EventInfo.svelte"
|
||||
import EventReport from "@app/components/EventReport.svelte"
|
||||
import Report from "@app/components/Report.svelte"
|
||||
import EventDeleteConfirm from "@app/components/EventDeleteConfirm.svelte"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {deriveUserIsSpaceAdmin} from "@app/core/state"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
@@ -19,9 +23,11 @@
|
||||
|
||||
const {url, event, onClick}: Props = $props()
|
||||
|
||||
const userIsAdmin = deriveUserIsSpaceAdmin(url)
|
||||
|
||||
const report = () => {
|
||||
onClick()
|
||||
pushModal(EventReport, {url, event})
|
||||
pushModal(Report, {url, event})
|
||||
}
|
||||
|
||||
const showInfo = () => {
|
||||
@@ -33,9 +39,29 @@
|
||||
onClick()
|
||||
pushModal(EventDeleteConfirm, {url, event})
|
||||
}
|
||||
|
||||
const showAdminDelete = () =>
|
||||
pushModal(Confirm, {
|
||||
title: `Delete Message`,
|
||||
message: `Are you sure you want to delete this message from the space?`,
|
||||
confirm: async () => {
|
||||
const {error} = await manageRelay(url, {
|
||||
method: ManagementMethod.BanEvent,
|
||||
params: [event.id],
|
||||
})
|
||||
|
||||
if (error) {
|
||||
pushToast({theme: "error", message: error})
|
||||
} else {
|
||||
pushToast({message: "Event has successfully been deleted!"})
|
||||
repository.removeEvent(event.id)
|
||||
history.back()
|
||||
}
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<ul class="menu whitespace-nowrap rounded-box bg-base-100 p-2 shadow-xl">
|
||||
<ul class="menu whitespace-nowrap rounded-box bg-base-100 p-2 shadow-md">
|
||||
<li>
|
||||
<Button onclick={showInfo}>
|
||||
<Icon size={4} icon={Code2} />
|
||||
@@ -56,5 +82,13 @@
|
||||
Report Content
|
||||
</Button>
|
||||
</li>
|
||||
{#if $userIsAdmin}
|
||||
<li>
|
||||
<Button class="text-error" onclick={showAdminDelete}>
|
||||
<Icon size={4} icon={TrashBin2} />
|
||||
Delete Message
|
||||
</Button>
|
||||
</li>
|
||||
{/if}
|
||||
{/if}
|
||||
</ul>
|
||||
|
||||
@@ -71,16 +71,16 @@
|
||||
View Details
|
||||
</Link>
|
||||
{/if}
|
||||
<Button class="btn btn-outline btn-neutral w-full" onclick={sendReply}>
|
||||
<Button class="btn btn-neutral w-full" onclick={sendReply}>
|
||||
<Icon size={4} icon={Reply} />
|
||||
Reply
|
||||
</Button>
|
||||
<Button class="btn btn-secondary w-full" onclick={showEmojiPicker}>
|
||||
<Button class="btn btn-neutral w-full" onclick={showEmojiPicker}>
|
||||
<Icon size={4} icon={SmileCircle} />
|
||||
React
|
||||
</Button>
|
||||
{#if ENABLE_ZAPS}
|
||||
<ZapButton replaceState {url} {event} class="btn btn-primary w-full">
|
||||
<ZapButton replaceState {url} {event} class="btn btn-neutral w-full">
|
||||
<Icon size={4} icon={Bolt} />
|
||||
Zap
|
||||
</ZapButton>
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
<script lang="ts">
|
||||
import {waitForThunkError, removeRoomMember} from "@welshman/app"
|
||||
import MenuDots from "@assets/icons/menu-dots.svg?dataurl"
|
||||
import MinusCircle from "@assets/icons/minus-circle.svg?dataurl"
|
||||
import AddCircle from "@assets/icons/add-circle.svg?dataurl"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import {fly} from "@lib/transition"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Popover from "@lib/components/Popover.svelte"
|
||||
import Confirm from "@lib/components/Confirm.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import Profile from "@app/components/Profile.svelte"
|
||||
import RoomName from "@app/components/RoomName.svelte"
|
||||
import RoomMembersAdd from "@app/components/RoomMembersAdd.svelte"
|
||||
import {deriveRoom, deriveRoomMembers, deriveUserIsRoomAdmin} from "@app/core/state"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
interface Props {
|
||||
url: string
|
||||
h: string
|
||||
}
|
||||
|
||||
const {url, h}: Props = $props()
|
||||
|
||||
const room = deriveRoom(url, h)
|
||||
const members = deriveRoomMembers(url, h)
|
||||
const userIsAdmin = deriveUserIsRoomAdmin(url, h)
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const toggleMenu = (pubkey: string) => {
|
||||
menuPubkey = menuPubkey === pubkey ? undefined : pubkey
|
||||
}
|
||||
|
||||
const closeMenu = () => {
|
||||
menuPubkey = undefined
|
||||
}
|
||||
|
||||
const addMember = () => pushModal(RoomMembersAdd, {url, h})
|
||||
|
||||
const removeMember = (pubkey: string) =>
|
||||
pushModal(Confirm, {
|
||||
title: "Remove Member",
|
||||
message: "Are you sure you want to remove this user from the room?",
|
||||
confirm: async () => {
|
||||
const error = await waitForThunkError(removeRoomMember(url, $room, pubkey))
|
||||
|
||||
if (error) {
|
||||
pushToast({theme: "error", message: error})
|
||||
} else {
|
||||
pushToast({message: "Member has successfully been removed!"})
|
||||
back()
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
let menuPubkey = $state<string | undefined>()
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<div class="flex min-w-0 flex-col gap-1">
|
||||
<h1 class="ellipsize whitespace-nowrap text-2xl font-bold">Members</h1>
|
||||
<p class="ellipsize text-sm opacity-75">of <RoomName {url} {h} /></p>
|
||||
</div>
|
||||
{#if $userIsAdmin}
|
||||
<div class="flex gap-2">
|
||||
<Button class="btn btn-primary" onclick={addMember}>
|
||||
<Icon icon={AddCircle} />
|
||||
Add members
|
||||
</Button>
|
||||
</div>
|
||||
{/if}
|
||||
{#each $members as pubkey (pubkey)}
|
||||
<div class="card2 bg-alt relative">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<div class="min-w-0 flex-1">
|
||||
<Profile {pubkey} {url} />
|
||||
</div>
|
||||
<div class="relative">
|
||||
<Button class="btn btn-circle btn-ghost btn-sm" onclick={() => toggleMenu(pubkey)}>
|
||||
<Icon icon={MenuDots} />
|
||||
</Button>
|
||||
{#if menuPubkey === pubkey}
|
||||
<Popover hideOnClick onClose={closeMenu}>
|
||||
<ul
|
||||
transition:fly
|
||||
class="menu absolute right-0 z-popover mt-2 w-48 gap-1 rounded-box bg-base-100 p-2 shadow-md">
|
||||
<li>
|
||||
<Button class="text-error" onclick={() => removeMember(pubkey)}>
|
||||
<Icon icon={MinusCircle} />
|
||||
Remove Member
|
||||
</Button>
|
||||
</li>
|
||||
</ul>
|
||||
</Popover>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</div>
|
||||
@@ -0,0 +1,77 @@
|
||||
<script lang="ts">
|
||||
import {addRoomMember, waitForThunkError} from "@welshman/app"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Field from "@lib/components/Field.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import RoomName from "@app/components/RoomName.svelte"
|
||||
import ProfileMultiSelect from "@app/components/ProfileMultiSelect.svelte"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {deriveRoom} from "@app/core/state"
|
||||
|
||||
interface Props {
|
||||
url: string
|
||||
h: string
|
||||
}
|
||||
|
||||
const {url, h}: Props = $props()
|
||||
|
||||
const room = deriveRoom(url, h)
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const addMember = async () => {
|
||||
loading = true
|
||||
|
||||
try {
|
||||
const errors = await Promise.all(
|
||||
pubkeys.map(pubkey => waitForThunkError(addRoomMember(url, $room, pubkey))),
|
||||
)
|
||||
|
||||
for (const error of errors) {
|
||||
if (error) {
|
||||
return pushToast({theme: "error", message: errors[0]})
|
||||
}
|
||||
}
|
||||
|
||||
pushToast({message: "Members have successfully been added!"})
|
||||
back()
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
}
|
||||
|
||||
let loading = $state(false)
|
||||
let pubkeys: string[] = $state([])
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<ModalHeader>
|
||||
{#snippet title()}
|
||||
<div>Add Members</div>
|
||||
{/snippet}
|
||||
{#snippet info()}
|
||||
<div>to <RoomName {url} {h} /></div>
|
||||
{/snippet}
|
||||
</ModalHeader>
|
||||
<Field>
|
||||
{#snippet label()}
|
||||
<p>Search for People</p>
|
||||
{/snippet}
|
||||
{#snippet input()}
|
||||
<ProfileMultiSelect bind:value={pubkeys} />
|
||||
{/snippet}
|
||||
</Field>
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
<Button class="btn btn-primary" onclick={addMember} disabled={loading}>
|
||||
<Spinner {loading}>Save changes</Spinner>
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</div>
|
||||
@@ -1,7 +1,17 @@
|
||||
<script lang="ts">
|
||||
import {roomsById, makeRoomId} from "@app/core/state"
|
||||
import {deriveRoom} from "@app/core/state"
|
||||
|
||||
const {url, h} = $props()
|
||||
type Props = {
|
||||
url: string
|
||||
h: string
|
||||
class?: string
|
||||
}
|
||||
|
||||
const {url, h, ...props}: Props = $props()
|
||||
|
||||
const room = deriveRoom(url, h)
|
||||
</script>
|
||||
|
||||
{$roomsById.get(makeRoomId(url, h))?.name || h}
|
||||
<span class="ellipsize {props.class}">
|
||||
{$room?.name || h}
|
||||
</span>
|
||||
|
||||
@@ -1,26 +1,21 @@
|
||||
<script lang="ts">
|
||||
import Hashtag from "@assets/icons/hashtag.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
||||
import RoomName from "@app/components/RoomName.svelte"
|
||||
import {deriveRoom} from "@app/core/state"
|
||||
import RoomImage from "@app/components/RoomImage.svelte"
|
||||
|
||||
interface Props {
|
||||
url: any
|
||||
h: any
|
||||
h: string
|
||||
url: string
|
||||
class?: string
|
||||
}
|
||||
|
||||
const {url, h}: Props = $props()
|
||||
|
||||
const room = deriveRoom(url, h)
|
||||
const {url, h, ...props}: Props = $props()
|
||||
</script>
|
||||
|
||||
{#if $room.picture}
|
||||
{@const src = $room.picture}
|
||||
<ImageIcon {src} alt="Room icon" />
|
||||
{:else}
|
||||
<Icon icon={Hashtag} />
|
||||
{/if}
|
||||
<div class="min-w-0 overflow-hidden text-ellipsis">
|
||||
<RoomName {url} {h} />
|
||||
<div class="flex flex-grow items-center justify-between gap-4 {props.class}">
|
||||
<div class="flex items-center gap-3">
|
||||
<RoomImage {url} {h} />
|
||||
<div class="min-w-0 overflow-hidden text-ellipsis">
|
||||
<RoomName {url} {h} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
import {nsecEncode} from "nostr-tools/nip19"
|
||||
import {encrypt} from "nostr-tools/nip49"
|
||||
import {hexToBytes} from "@welshman/lib"
|
||||
import {makeSecret} from "@welshman/signer"
|
||||
import {makeSecret} from "@welshman/util"
|
||||
import type {Profile} from "@welshman/util"
|
||||
import {preventDefault, downloadText} from "@lib/html"
|
||||
import Key from "@assets/icons/key-minimalistic.svg?dataurl"
|
||||
|
||||
@@ -12,12 +12,29 @@
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import SpaceAccessRequest from "@app/components/SpaceAccessRequest.svelte"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {removeSpaceMembership, publishLeaveRequest, removeTrustedRelay} from "@app/core/commands"
|
||||
|
||||
const {url, error} = $props()
|
||||
|
||||
const back = () => goto("/home")
|
||||
|
||||
const requestAccess = () => pushModal(SpaceAccessRequest, {url})
|
||||
|
||||
const leaveSpace = async () => {
|
||||
loading = true
|
||||
|
||||
try {
|
||||
await removeSpaceMembership(url)
|
||||
await publishLeaveRequest({url})
|
||||
await removeTrustedRelay(url)
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
|
||||
goto("/home")
|
||||
}
|
||||
|
||||
let loading = $state(false)
|
||||
</script>
|
||||
|
||||
<form class="column gap-4" onsubmit={preventDefault(requestAccess)}>
|
||||
@@ -40,9 +57,14 @@
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go Home
|
||||
</Button>
|
||||
<Button type="submit" class="btn btn-primary">
|
||||
Request Access
|
||||
<Icon icon={AltArrowRight} />
|
||||
</Button>
|
||||
<div class="flex gap-2">
|
||||
<Button class="btn btn-outline btn-error" onclick={leaveSpace} disabled={loading}>
|
||||
Leave Space
|
||||
</Button>
|
||||
<Button type="submit" class="btn btn-primary" disabled={loading}>
|
||||
Request Access
|
||||
<Icon icon={AltArrowRight} />
|
||||
</Button>
|
||||
</div>
|
||||
</ModalFooter>
|
||||
</form>
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
<script lang="ts">
|
||||
import {displayRelayUrl} from "@welshman/util"
|
||||
import Avatar from "@lib/components/Avatar.svelte"
|
||||
import {deriveRelay} from "@welshman/app"
|
||||
import RemoteControllerMinimalistic from "@assets/icons/remote-controller-minimalistic.svg?dataurl"
|
||||
|
||||
interface Props {
|
||||
url?: string
|
||||
}
|
||||
|
||||
const {url = ""}: Props = $props()
|
||||
|
||||
const relay = deriveRelay(url)
|
||||
</script>
|
||||
|
||||
<Avatar
|
||||
icon={RemoteControllerMinimalistic}
|
||||
class="!h-10 !w-10"
|
||||
alt={displayRelayUrl(url)}
|
||||
src={$relay?.icon} />
|
||||
@@ -10,19 +10,24 @@
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import SpaceVisitConfirm, {confirmSpaceVisit} from "@app/components/SpaceVisitConfirm.svelte"
|
||||
import SpaceJoinConfirm, {confirmSpaceJoin} from "@app/components/SpaceJoinConfirm.svelte"
|
||||
import {attemptRelayAccess} from "@app/core/commands"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
const {url} = $props()
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const next = () => {
|
||||
if (!error && Pool.get().get(url).auth.status === AuthStatus.None) {
|
||||
pushModal(SpaceVisitConfirm, {url}, {replaceState: true})
|
||||
const next = async () => {
|
||||
if (error) {
|
||||
return pushToast({theme: "error", message: error, timeout: 30_000})
|
||||
}
|
||||
|
||||
if (Pool.get().get(url).auth.status === AuthStatus.None) {
|
||||
pushModal(SpaceJoinConfirm, {url}, {replaceState: true})
|
||||
} else {
|
||||
confirmSpaceVisit(url)
|
||||
await confirmSpaceJoin(url)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +77,7 @@
|
||||
Go back
|
||||
</Button>
|
||||
<Button type="submit" class="btn btn-primary" disabled={loading}>
|
||||
Go to Space
|
||||
Join Space
|
||||
<Icon icon={AltArrowRight} />
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
|
||||
@@ -2,16 +2,22 @@
|
||||
import {displayRelayUrl} from "@welshman/util"
|
||||
import {deriveRelay} from "@welshman/app"
|
||||
import UserRounded from "@assets/icons/user-rounded.svg?dataurl"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import Pen from "@assets/icons/pen.svg?dataurl"
|
||||
import ShieldUser from "@assets/icons/shield-user.svg?dataurl"
|
||||
import BillList from "@assets/icons/bill-list.svg?dataurl"
|
||||
import Ghost from "@assets/icons/ghost-smile.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Link from "@lib/components/Link.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import RelayName from "@app/components/RelayName.svelte"
|
||||
import RelayIcon from "@app/components/RelayIcon.svelte"
|
||||
import SpaceEdit from "@app/components/SpaceEdit.svelte"
|
||||
import SpaceRelayStatus from "@app/components/SpaceRelayStatus.svelte"
|
||||
import RelayDescription from "@app/components/RelayDescription.svelte"
|
||||
import ProfileLatest from "@app/components/ProfileLatest.svelte"
|
||||
import {deriveUserIsSpaceAdmin} from "@app/core/state"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
@@ -20,30 +26,37 @@
|
||||
const {url}: Props = $props()
|
||||
const relay = deriveRelay(url)
|
||||
const owner = $derived($relay?.pubkey)
|
||||
const userIsAdmin = deriveUserIsSpaceAdmin(url)
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const startEdit = () => pushModal(SpaceEdit, {url, initialValues: $relay})
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<div class="relative flex gap-4">
|
||||
<div class="relative">
|
||||
<div class="avatar relative">
|
||||
<div
|
||||
class="center !flex h-16 w-16 min-w-16 rounded-full border-2 border-solid border-base-300 bg-base-300">
|
||||
{#if $relay?.icon}
|
||||
<img alt="" src={$relay.icon} />
|
||||
{:else}
|
||||
<Icon icon={Ghost} size={6} />
|
||||
{/if}
|
||||
<div class="flex justify-between">
|
||||
<div class="relative flex gap-4">
|
||||
<div class="relative">
|
||||
<div class="avatar relative">
|
||||
<div
|
||||
class="center !flex h-16 w-16 min-w-16 rounded-full border-2 border-solid border-base-300 bg-base-300">
|
||||
<RelayIcon {url} size={10} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex min-w-0 flex-col gap-1">
|
||||
<h1 class="ellipsize whitespace-nowrap text-2xl font-bold">
|
||||
<RelayName {url} />
|
||||
</h1>
|
||||
<p class="ellipsize text-sm opacity-75">{displayRelayUrl(url)}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex min-w-0 flex-col gap-1">
|
||||
<h1 class="ellipsize whitespace-nowrap text-2xl font-bold">
|
||||
<RelayName {url} />
|
||||
</h1>
|
||||
<p class="ellipsize text-sm opacity-75">{displayRelayUrl(url)}</p>
|
||||
</div>
|
||||
{#if $userIsAdmin}
|
||||
<Button class="btn btn-primary" onclick={startEdit}>
|
||||
<Icon icon={Pen} />
|
||||
Edit
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
<RelayDescription {url} />
|
||||
{#if $relay?.terms_of_service || $relay?.privacy_policy}
|
||||
@@ -78,5 +91,10 @@
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<Button class="btn btn-primary" onclick={back}>Got it</Button>
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,206 @@
|
||||
<script lang="ts">
|
||||
import {ifLet} from "@welshman/lib"
|
||||
import type {RelayProfile} from "@welshman/util"
|
||||
import {displayRelayUrl, ManagementMethod} from "@welshman/util"
|
||||
import {manageRelay, relaysByUrl, notifyRelay, fetchRelayDirectly} from "@welshman/app"
|
||||
import StickerSmileSquare from "@assets/icons/sticker-smile-square.svg?dataurl"
|
||||
import SettingsMinimalistic from "@assets/icons/settings-minimalistic.svg?dataurl"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import UploadMinimalistic from "@assets/icons/upload-minimalistic.svg?dataurl"
|
||||
import {preventDefault} from "@lib/html"
|
||||
import FieldInline from "@lib/components/FieldInline.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import ImageIcon from "@lib/components/ImageIcon.svelte"
|
||||
import IconPickerButton from "@lib/components/IconPickerButton.svelte"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {clearModals} from "@app/util/modal"
|
||||
import {uploadFile} from "@app/core/commands"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
initialValues: RelayProfile
|
||||
}
|
||||
|
||||
const {url, initialValues}: Props = $props()
|
||||
|
||||
const values = $state(initialValues)
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const submit = async () => {
|
||||
if (values.name != initialValues.name) {
|
||||
const res = await manageRelay(url, {
|
||||
method: ManagementMethod.ChangeRelayName,
|
||||
params: [values.name || ""],
|
||||
})
|
||||
|
||||
if (res.error) {
|
||||
return pushToast({theme: "error", message: res.error})
|
||||
}
|
||||
}
|
||||
|
||||
if (values.description != initialValues.description) {
|
||||
const res = await manageRelay(url, {
|
||||
method: ManagementMethod.ChangeRelayDescription,
|
||||
params: [values.description || ""],
|
||||
})
|
||||
|
||||
if (res.error) {
|
||||
return pushToast({theme: "error", message: res.error})
|
||||
}
|
||||
}
|
||||
|
||||
if (imageFile) {
|
||||
const {error, result} = await uploadFile(imageFile, {maxWidth: 128, maxHeight: 128})
|
||||
|
||||
if (error) {
|
||||
return pushToast({theme: "error", message: error})
|
||||
}
|
||||
|
||||
const res = await manageRelay(url, {
|
||||
method: ManagementMethod.ChangeRelayIcon,
|
||||
params: [result.url],
|
||||
})
|
||||
|
||||
if (res.error) {
|
||||
return pushToast({theme: "error", message: res.error})
|
||||
}
|
||||
}
|
||||
|
||||
// Force-reload the relay
|
||||
ifLet(await fetchRelayDirectly(url), relay => {
|
||||
relaysByUrl.update($relaysByUrl => {
|
||||
$relaysByUrl.set(url, relay)
|
||||
|
||||
return new Map($relaysByUrl)
|
||||
})
|
||||
|
||||
notifyRelay(relay)
|
||||
})
|
||||
|
||||
pushToast({message: "Your changes have been saved!"})
|
||||
clearModals()
|
||||
}
|
||||
|
||||
const trySubmit = async () => {
|
||||
loading = true
|
||||
|
||||
try {
|
||||
await submit()
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
}
|
||||
|
||||
let loading = $state(false)
|
||||
let imageFile = $state<File | undefined>()
|
||||
let imagePreview = $state(initialValues.icon)
|
||||
|
||||
const handleImageUpload = async (event: Event) => {
|
||||
const file = (event.target as HTMLInputElement).files?.[0]
|
||||
|
||||
if (file && file.type.startsWith("image/")) {
|
||||
const reader = new FileReader()
|
||||
|
||||
reader.onload = e => {
|
||||
imageFile = file
|
||||
imagePreview = e.target?.result as string
|
||||
}
|
||||
|
||||
reader.readAsDataURL(file)
|
||||
}
|
||||
}
|
||||
|
||||
const handleIconSelect = (iconUrl: string) => {
|
||||
imagePreview = iconUrl
|
||||
|
||||
const parts = iconUrl.split(",")
|
||||
const imageData = atob(parts[1])
|
||||
const result = new Uint8Array(imageData.length)
|
||||
|
||||
for (let n = 0; n < imageData.length; n++) {
|
||||
result[n] = imageData.charCodeAt(n)
|
||||
}
|
||||
|
||||
imageFile = new File([result], `icon.svg`, {type: "image/svg+xml"})
|
||||
}
|
||||
</script>
|
||||
|
||||
<form class="column gap-4" onsubmit={preventDefault(trySubmit)}>
|
||||
<ModalHeader>
|
||||
{#snippet title()}
|
||||
<div>Edit a Space</div>
|
||||
{/snippet}
|
||||
{#snippet info()}
|
||||
<span class="text-primary">{displayRelayUrl(url)}</span>
|
||||
{/snippet}
|
||||
</ModalHeader>
|
||||
<FieldInline>
|
||||
{#snippet label()}
|
||||
<p>Icon</p>
|
||||
{/snippet}
|
||||
{#snippet input()}
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-4">
|
||||
{#if imagePreview}
|
||||
<div class="flex items-center gap-2">
|
||||
<span class="text-sm opacity-75">Selected:</span>
|
||||
<ImageIcon src={imagePreview} alt="" />
|
||||
</div>
|
||||
{:else}
|
||||
<span class="text-sm opacity-75">No icon selected</span>
|
||||
{/if}
|
||||
<div class="flex gap-2">
|
||||
<IconPickerButton onSelect={handleIconSelect} class="btn btn-primary btn-sm">
|
||||
<Icon icon={StickerSmileSquare} size={4} />
|
||||
Select
|
||||
</IconPickerButton>
|
||||
<label class="btn btn-neutral btn-sm cursor-pointer">
|
||||
<Icon icon={UploadMinimalistic} size={4} />
|
||||
Upload
|
||||
<input type="file" accept="image/*" class="hidden" onchange={handleImageUpload} />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/snippet}
|
||||
</FieldInline>
|
||||
<FieldInline>
|
||||
{#snippet label()}
|
||||
<p>Name</p>
|
||||
{/snippet}
|
||||
{#snippet input()}
|
||||
<label class="input input-bordered flex w-full items-center gap-2">
|
||||
{#if imagePreview}
|
||||
<ImageIcon src={imagePreview} alt="" />
|
||||
{:else}
|
||||
<Icon icon={SettingsMinimalistic} />
|
||||
{/if}
|
||||
<input bind:value={values.name} class="grow" type="text" />
|
||||
</label>
|
||||
{/snippet}
|
||||
</FieldInline>
|
||||
<FieldInline>
|
||||
{#snippet label()}
|
||||
<p>Description</p>
|
||||
{/snippet}
|
||||
{#snippet input()}
|
||||
<label class="input input-bordered flex w-full items-center gap-2">
|
||||
<input bind:value={values.description} class="grow" type="text" />
|
||||
</label>
|
||||
{/snippet}
|
||||
</FieldInline>
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
<Button type="submit" class="btn btn-primary" disabled={loading}>
|
||||
<Spinner {loading}>Save Changes</Spinner>
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</form>
|
||||
@@ -10,8 +10,8 @@
|
||||
await addSpaceMembership(url)
|
||||
|
||||
broadcastUserData([url])
|
||||
goto(makeSpacePath(url), {replaceState: true})
|
||||
relaysMostlyRestricted.update(dissoc(url))
|
||||
goto(makeSpacePath(url), {replaceState: true})
|
||||
pushToast({message: "Welcome to the space!"})
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
<script lang="ts">
|
||||
import {displayRelayUrl, ManagementMethod} from "@welshman/util"
|
||||
import {manageRelay, displayProfileByPubkey} from "@welshman/app"
|
||||
import MenuDots from "@assets/icons/menu-dots.svg?dataurl"
|
||||
import MinusCircle from "@assets/icons/minus-circle.svg?dataurl"
|
||||
import AddCircle from "@assets/icons/add-circle.svg?dataurl"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import {fly} from "@lib/transition"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Popover from "@lib/components/Popover.svelte"
|
||||
import Confirm from "@lib/components/Confirm.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import Profile from "@app/components/Profile.svelte"
|
||||
import SpaceMembersAdd from "@app/components/SpaceMembersAdd.svelte"
|
||||
import SpaceMembersBanned from "@app/components/SpaceMembersBanned.svelte"
|
||||
import {
|
||||
deriveSpaceMembers,
|
||||
deriveSpaceBannedPubkeyItems,
|
||||
deriveUserIsSpaceAdmin,
|
||||
} from "@app/core/state"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
interface Props {
|
||||
url: string
|
||||
}
|
||||
|
||||
const {url}: Props = $props()
|
||||
|
||||
const members = deriveSpaceMembers(url)
|
||||
const bans = deriveSpaceBannedPubkeyItems(url)
|
||||
const userIsAdmin = deriveUserIsSpaceAdmin(url)
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const toggleMenu = (pubkey: string) => {
|
||||
menuPubkey = menuPubkey === pubkey ? undefined : pubkey
|
||||
}
|
||||
|
||||
const closeMenu = () => {
|
||||
menuPubkey = undefined
|
||||
}
|
||||
|
||||
const showBannedPubkeyItems = () => pushModal(SpaceMembersBanned, {url})
|
||||
|
||||
const addMember = () => pushModal(SpaceMembersAdd, {url})
|
||||
|
||||
const banMember = (pubkey: string) =>
|
||||
pushModal(Confirm, {
|
||||
title: "Ban User",
|
||||
message: `Are you sure you want to ban @${displayProfileByPubkey(pubkey)} from the space?`,
|
||||
confirm: async () => {
|
||||
const {error} = await manageRelay(url, {
|
||||
method: ManagementMethod.BanPubkey,
|
||||
params: [pubkey],
|
||||
})
|
||||
|
||||
if (error) {
|
||||
pushToast({theme: "error", message: error})
|
||||
} else {
|
||||
pushToast({message: "User has successfully been banned!"})
|
||||
back()
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
let menuPubkey = $state<string | undefined>()
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<div class="flex min-w-0 flex-col gap-1">
|
||||
<h1 class="ellipsize whitespace-nowrap text-2xl font-bold">Members</h1>
|
||||
<p class="ellipsize text-sm opacity-75">of {displayRelayUrl(url)}</p>
|
||||
</div>
|
||||
{#if $userIsAdmin}
|
||||
<div class="flex gap-2">
|
||||
<Button class="btn btn-primary" onclick={addMember}>
|
||||
<Icon icon={AddCircle} />
|
||||
Add members
|
||||
</Button>
|
||||
{#if $bans.length > 0}
|
||||
<Button class="btn btn-neutral" onclick={showBannedPubkeyItems}>
|
||||
Banned users ({$bans.length})
|
||||
</Button>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{#each $members as pubkey (pubkey)}
|
||||
<div class="card2 bg-alt relative">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<div class="min-w-0 flex-1">
|
||||
<Profile {pubkey} {url} />
|
||||
</div>
|
||||
<div class="relative">
|
||||
<Button class="btn btn-circle btn-ghost btn-sm" onclick={() => toggleMenu(pubkey)}>
|
||||
<Icon icon={MenuDots} />
|
||||
</Button>
|
||||
{#if menuPubkey === pubkey}
|
||||
<Popover hideOnClick onClose={closeMenu}>
|
||||
<ul
|
||||
transition:fly
|
||||
class="menu absolute right-0 z-popover mt-2 w-48 gap-1 rounded-box bg-base-100 p-2 shadow-md">
|
||||
<li>
|
||||
<Button class="text-error" onclick={() => banMember(pubkey)}>
|
||||
<Icon icon={MinusCircle} />
|
||||
Ban User
|
||||
</Button>
|
||||
</li>
|
||||
</ul>
|
||||
</Popover>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</div>
|
||||
@@ -0,0 +1,78 @@
|
||||
<script lang="ts">
|
||||
import {displayRelayUrl, ManagementMethod} from "@welshman/util"
|
||||
import {manageRelay} from "@welshman/app"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import Spinner from "@lib/components/Spinner.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Field from "@lib/components/Field.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import ProfileMultiSelect from "@app/components/ProfileMultiSelect.svelte"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
interface Props {
|
||||
url: string
|
||||
}
|
||||
|
||||
const {url}: Props = $props()
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const addMember = async () => {
|
||||
loading = true
|
||||
|
||||
try {
|
||||
const results = await Promise.all(
|
||||
pubkeys.map(pubkey =>
|
||||
manageRelay(url, {
|
||||
method: ManagementMethod.AllowPubkey,
|
||||
params: [pubkey],
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
||||
for (const {error} of results) {
|
||||
if (error) {
|
||||
return pushToast({theme: "error", message: error})
|
||||
}
|
||||
}
|
||||
|
||||
pushToast({message: "Members have successfully been added!"})
|
||||
back()
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
}
|
||||
|
||||
let loading = $state(false)
|
||||
let pubkeys: string[] = $state([])
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<ModalHeader>
|
||||
{#snippet title()}
|
||||
<div>Add Members</div>
|
||||
{/snippet}
|
||||
{#snippet info()}
|
||||
<div>to {displayRelayUrl(url)}</div>
|
||||
{/snippet}
|
||||
</ModalHeader>
|
||||
<Field>
|
||||
{#snippet label()}
|
||||
<p>Search for People</p>
|
||||
{/snippet}
|
||||
{#snippet input()}
|
||||
<ProfileMultiSelect bind:value={pubkeys} />
|
||||
{/snippet}
|
||||
</Field>
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
<Button class="btn btn-primary" onclick={addMember} disabled={loading}>
|
||||
<Spinner {loading}>Save changes</Spinner>
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</div>
|
||||
@@ -0,0 +1,95 @@
|
||||
<script lang="ts">
|
||||
import {displayRelayUrl, ManagementMethod} from "@welshman/util"
|
||||
import {manageRelay} from "@welshman/app"
|
||||
import MenuDots from "@assets/icons/menu-dots.svg?dataurl"
|
||||
import Restart from "@assets/icons/restart.svg?dataurl"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import {fly} from "@lib/transition"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Popover from "@lib/components/Popover.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import Profile from "@app/components/Profile.svelte"
|
||||
import {deriveSpaceBannedPubkeyItems} from "@app/core/state"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
interface Props {
|
||||
url: string
|
||||
}
|
||||
|
||||
const {url}: Props = $props()
|
||||
|
||||
const bans = deriveSpaceBannedPubkeyItems(url)
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const toggleMenu = (pubkey: string) => {
|
||||
menuPubkey = menuPubkey === pubkey ? undefined : pubkey
|
||||
}
|
||||
|
||||
const closeMenu = () => {
|
||||
menuPubkey = undefined
|
||||
}
|
||||
|
||||
const restoreMember = async (pubkey: string) => {
|
||||
const {error} = await manageRelay(url, {
|
||||
method: ManagementMethod.AllowPubkey,
|
||||
params: [pubkey],
|
||||
})
|
||||
|
||||
if (error) {
|
||||
pushToast({theme: "error", message: error})
|
||||
} else {
|
||||
pushToast({message: "User has successfully been restored!"})
|
||||
back()
|
||||
}
|
||||
}
|
||||
|
||||
let menuPubkey = $state<string | undefined>()
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<ModalHeader>
|
||||
{#snippet title()}
|
||||
<div>Banned users</div>
|
||||
{/snippet}
|
||||
{#snippet info()}
|
||||
<div>on {displayRelayUrl(url)}</div>
|
||||
{/snippet}
|
||||
</ModalHeader>
|
||||
{#each $bans as { pubkey, reason } (pubkey)}
|
||||
<div class="card2 bg-alt relative">
|
||||
<div class="flex items-center justify-between gap-2">
|
||||
<div class="min-w-0 flex-1">
|
||||
<Profile {pubkey} {url} />
|
||||
</div>
|
||||
<div class="relative">
|
||||
<Button class="btn btn-circle btn-ghost btn-sm" onclick={() => toggleMenu(pubkey)}>
|
||||
<Icon icon={MenuDots} />
|
||||
</Button>
|
||||
{#if menuPubkey === pubkey}
|
||||
<Popover hideOnClick onClose={closeMenu}>
|
||||
<ul
|
||||
transition:fly
|
||||
class="menu absolute right-0 z-popover mt-2 w-48 gap-1 rounded-box bg-base-100 p-2 shadow-md">
|
||||
<li>
|
||||
<Button onclick={() => restoreMember(pubkey)}>
|
||||
<Icon icon={Restart} />
|
||||
Restore User
|
||||
</Button>
|
||||
</li>
|
||||
</ul>
|
||||
</Popover>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/each}
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Got it
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</div>
|
||||
@@ -1,18 +1,19 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {derived} from "svelte/store"
|
||||
import {displayRelayUrl, getTagValue, EVENT_TIME, ZAP_GOAL, THREAD} from "@welshman/util"
|
||||
import {deriveRelay} from "@welshman/app"
|
||||
import {some} from "@welshman/lib"
|
||||
import {displayRelayUrl, getTagValue, EVENT_TIME, ZAP_GOAL, THREAD, REPORT} from "@welshman/util"
|
||||
import {deriveRelay, pubkey} from "@welshman/app"
|
||||
import {fly} from "@lib/transition"
|
||||
import AltArrowDown from "@assets/icons/alt-arrow-down.svg?dataurl"
|
||||
import RemoteControllerMinimalistic from "@assets/icons/remote-controller-minimalistic.svg?dataurl"
|
||||
import UserRounded from "@assets/icons/user-rounded.svg?dataurl"
|
||||
import Danger from "@assets/icons/danger.svg?dataurl"
|
||||
import LinkRound from "@assets/icons/link-round.svg?dataurl"
|
||||
import Exit from "@assets/icons/logout-3.svg?dataurl"
|
||||
import Letter from "@assets/icons/letter.svg?dataurl"
|
||||
import Login from "@assets/icons/login-3.svg?dataurl"
|
||||
import History from "@assets/icons/history.svg?dataurl"
|
||||
import Tuning2 from "@assets/icons/tuning-2.svg?dataurl"
|
||||
import StarFallMinimalistic from "@assets/icons/star-fall-minimalistic-2.svg?dataurl"
|
||||
import NotesMinimalistic from "@assets/icons/notes-minimalistic.svg?dataurl"
|
||||
import CalendarMinimalistic from "@assets/icons/calendar-minimalistic.svg?dataurl"
|
||||
@@ -31,7 +32,8 @@
|
||||
import SpaceExit from "@app/components/SpaceExit.svelte"
|
||||
import SpaceJoin from "@app/components/SpaceJoin.svelte"
|
||||
import RelayName from "@app/components/RelayName.svelte"
|
||||
import ProfileList from "@app/components/ProfileList.svelte"
|
||||
import SpaceMembers from "@app/components/SpaceMembers.svelte"
|
||||
import SpaceReports from "@app/components/SpaceReports.svelte"
|
||||
import AlertAdd from "@app/components/AlertAdd.svelte"
|
||||
import Alerts from "@app/components/Alerts.svelte"
|
||||
import RoomCreate from "@app/components/RoomCreate.svelte"
|
||||
@@ -41,14 +43,14 @@
|
||||
ENABLE_ZAPS,
|
||||
CONTENT_KINDS,
|
||||
deriveSpaceMembers,
|
||||
deriveEventsForUrl,
|
||||
deriveUserRooms,
|
||||
deriveOtherRooms,
|
||||
userSpaceUrls,
|
||||
hasNip29,
|
||||
alerts,
|
||||
alertsById,
|
||||
deriveUserCanCreateRoom,
|
||||
deriveUserIsSpaceAdmin,
|
||||
deriveEventsForUrl,
|
||||
} from "@app/core/state"
|
||||
import {notifications} from "@app/util/notifications"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
@@ -64,8 +66,11 @@
|
||||
const userRooms = deriveUserRooms(url)
|
||||
const otherRooms = deriveOtherRooms(url)
|
||||
const members = deriveSpaceMembers(url)
|
||||
const hasAlerts = $derived($alerts.some(a => getTagValue("feed", a.tags)?.includes(url)))
|
||||
const userIsAdmin = deriveUserIsSpaceAdmin(url)
|
||||
const reports = deriveEventsForUrl(url, [{kinds: [REPORT]}])
|
||||
const hasAlerts = $derived(
|
||||
some(a => getTagValue("feed", a.tags)?.includes(url), $alertsById.values()),
|
||||
)
|
||||
|
||||
const spaceKinds = derived(
|
||||
deriveEventsForUrl(url, [{kinds: CONTENT_KINDS}]),
|
||||
@@ -82,12 +87,9 @@
|
||||
|
||||
const showDetail = () => pushModal(SpaceDetail, {url}, {replaceState})
|
||||
|
||||
const showMembers = () =>
|
||||
pushModal(
|
||||
ProfileList,
|
||||
{url, pubkeys: $members, title: `Members of`, subtitle: displayRelayUrl(url)},
|
||||
{replaceState},
|
||||
)
|
||||
const showMembers = () => pushModal(SpaceMembers, {url}, {replaceState})
|
||||
|
||||
const showReports = () => pushModal(SpaceReports, {url}, {replaceState})
|
||||
|
||||
const canCreateRoom = deriveUserCanCreateRoom(url)
|
||||
|
||||
@@ -133,7 +135,7 @@
|
||||
<Popover hideOnClick onClose={toggleMenu}>
|
||||
<ul
|
||||
transition:fly
|
||||
class="menu absolute z-popover mt-2 w-full gap-1 rounded-box bg-base-100 p-2 shadow-xl">
|
||||
class="menu absolute z-popover mt-2 w-full gap-1 rounded-box bg-base-100 p-2 shadow-md">
|
||||
<li>
|
||||
<Button onclick={createInvite}>
|
||||
<Icon icon={LinkRound} />
|
||||
@@ -154,12 +156,13 @@
|
||||
</li>
|
||||
{#if $userIsAdmin}
|
||||
<li>
|
||||
<Link external href="https://landlubber.coracle.social">
|
||||
<Icon icon={Tuning2} />
|
||||
Manage Space
|
||||
</Link>
|
||||
<Button onclick={showReports}>
|
||||
<Icon icon={Danger} />
|
||||
View Reports ({$reports.length})
|
||||
</Button>
|
||||
</li>
|
||||
{:else if $relay?.pubkey}
|
||||
{/if}
|
||||
{#if $relay?.pubkey && $relay.pubkey !== $pubkey}
|
||||
<li>
|
||||
<Link href={makeChatPath([$relay.pubkey])}>
|
||||
<Icon icon={Letter} />
|
||||
@@ -184,7 +187,7 @@
|
||||
</Popover>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="flex max-h-[calc(100vh-150px)] min-h-0 flex-col gap-1 overflow-auto">
|
||||
<div class="flex max-h-[calc(100vh-250px)] min-h-0 flex-col gap-1 overflow-auto">
|
||||
{#if hasNip29($relay)}
|
||||
<SecondaryNavItem {replaceState} href={makeSpacePath(url, "recent")}>
|
||||
<Icon icon={History} /> Recent Activity
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
import MenuDots from "@assets/icons/menu-dots.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import MenuSpace from "@app/components/MenuSpace.svelte"
|
||||
import SpaceMenu from "@app/components/SpaceMenu.svelte"
|
||||
import {notifications} from "@app/util/notifications"
|
||||
import {makeSpacePath} from "@app/util/routes"
|
||||
import {pushDrawer} from "@app/util/modal"
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
const status = deriveSocketStatus(url)
|
||||
|
||||
const openMenu = () => pushDrawer(MenuSpace, {url})
|
||||
const openMenu = () => pushDrawer(SpaceMenu, {url})
|
||||
</script>
|
||||
|
||||
<Button onclick={openMenu} class="btn btn-neutral btn-sm relative md:hidden">
|
||||
@@ -0,0 +1,35 @@
|
||||
<script lang="ts">
|
||||
import {REPORT, displayRelayUrl} from "@welshman/util"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import ReportItem from "@app/components/ReportItem.svelte"
|
||||
import {deriveEventsForUrl} from "@app/core/state"
|
||||
|
||||
interface Props {
|
||||
url: string
|
||||
}
|
||||
|
||||
const {url}: Props = $props()
|
||||
|
||||
const reports = deriveEventsForUrl(url, [{kinds: [REPORT]}])
|
||||
|
||||
const back = () => history.back()
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<div class="flex min-w-0 flex-col gap-1">
|
||||
<h1 class="ellipsize whitespace-nowrap text-2xl font-bold">Reports</h1>
|
||||
<p class="ellipsize text-sm opacity-75">on {displayRelayUrl(url)}</p>
|
||||
</div>
|
||||
{#each $reports as event (event.id)}
|
||||
<ReportItem {url} {event} />
|
||||
{/each}
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</div>
|
||||
@@ -1,24 +0,0 @@
|
||||
<script module lang="ts">
|
||||
import {goto} from "$app/navigation"
|
||||
import {makeSpacePath} from "@app/util/routes"
|
||||
|
||||
export const confirmSpaceVisit = (url: string) => {
|
||||
goto(makeSpacePath(url), {replaceState: true})
|
||||
}
|
||||
</script>
|
||||
|
||||
<script lang="ts">
|
||||
import Confirm from "@lib/components/Confirm.svelte"
|
||||
|
||||
type Props = {
|
||||
url: string
|
||||
}
|
||||
|
||||
const {url}: Props = $props()
|
||||
|
||||
const confirm = () => confirmSpaceVisit(url)
|
||||
</script>
|
||||
|
||||
<Confirm
|
||||
{confirm}
|
||||
message="This space does not appear to limit who can post to it. This can result in a large amount of spam or other objectionable content. Continue?" />
|
||||
@@ -23,7 +23,7 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class="card2 bg-alt col-2 shadow-2xl">
|
||||
<div class="card2 bg-alt col-2 shadow-lg">
|
||||
<p>
|
||||
Failed to publish to {displayRelayUrl(url)}: {message}.
|
||||
</p>
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {pushModal} from "@app/util/modal"
|
||||
import WalletAsReceivingAddress from "@app/components/WalletAsReceivingAddress.svelte"
|
||||
import Divider from "@src/lib/components/Divider.svelte"
|
||||
import Divider from "@lib/components/Divider.svelte"
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
<script lang="ts">
|
||||
import {Invoice} from "@getalby/lightning-tools/bolt11"
|
||||
import {debounce} from "throttle-debounce"
|
||||
import {session} from "@welshman/app"
|
||||
import Bolt from "@assets/icons/bolt.svg?dataurl"
|
||||
import AltArrowLeft from "@assets/icons/alt-arrow-left.svg?dataurl"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import FieldInline from "@lib/components/FieldInline.svelte"
|
||||
import Scanner from "@lib/components/Scanner.svelte"
|
||||
import ModalHeader from "@lib/components/ModalHeader.svelte"
|
||||
import ModalFooter from "@lib/components/ModalFooter.svelte"
|
||||
import {payInvoice} from "@app/core/commands"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
import {clearModals} from "@app/util/modal"
|
||||
|
||||
const back = () => history.back()
|
||||
|
||||
const onScan = debounce(1000, async (data: string) => {
|
||||
invoice = new Invoice({pr: data})
|
||||
sats = invoice.satoshi || 0
|
||||
})
|
||||
|
||||
const confirm = async () => {
|
||||
loading = true
|
||||
|
||||
try {
|
||||
await payInvoice(invoice!.paymentRequest, sats * 1000)
|
||||
|
||||
pushToast({message: `Payment sent!`})
|
||||
clearModals()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
|
||||
const message = String(e).replace(/^.*Error: /, "")
|
||||
|
||||
pushToast({
|
||||
theme: "error",
|
||||
message: `Failed to send payment: ${message}`,
|
||||
})
|
||||
} finally {
|
||||
loading = false
|
||||
}
|
||||
}
|
||||
|
||||
let loading = $state(false)
|
||||
let invoice: Invoice | undefined = $state()
|
||||
let sats = $state(0)
|
||||
</script>
|
||||
|
||||
<div class="column gap-4">
|
||||
<ModalHeader>
|
||||
{#snippet title()}
|
||||
<div>Pay with Lightning</div>
|
||||
{/snippet}
|
||||
{#snippet info()}
|
||||
Use your Nostr wallet to send Bitcoin payments over lightning.
|
||||
{/snippet}
|
||||
</ModalHeader>
|
||||
{#if invoice}
|
||||
<div class="card2 bg-alt flex flex-col gap-2">
|
||||
{#if $session?.wallet?.type === "webln" && invoice.satoshi === 0}
|
||||
<p class="text-sm opacity-75">
|
||||
Uh oh! It looks like your current wallet doesn't support invoices without an amount. See
|
||||
if you can get a lightning invoice with a pre-set amount.
|
||||
</p>
|
||||
{:else}
|
||||
<FieldInline>
|
||||
{#snippet label()}
|
||||
Amount (satoshis)
|
||||
{/snippet}
|
||||
{#snippet input()}
|
||||
<div class="flex flex-grow justify-end">
|
||||
<label class="input input-bordered flex items-center gap-2">
|
||||
<Icon icon={Bolt} />
|
||||
<input
|
||||
bind:value={sats}
|
||||
type="number"
|
||||
class="w-14"
|
||||
disabled={invoice!.satoshi > 0} />
|
||||
</label>
|
||||
</div>
|
||||
{/snippet}
|
||||
</FieldInline>
|
||||
<p class="text-sm opacity-75">
|
||||
You're about to pay a bitcoin lightning invoice with the following description:
|
||||
<strong>{invoice.description || "[no description]"}</strong>"
|
||||
</p>
|
||||
{/if}
|
||||
</div>
|
||||
{:else}
|
||||
<Scanner onscan={onScan} />
|
||||
<p class="text-center text-sm opacity-75">
|
||||
To make a payment, scan a lightning invoice with your camera.
|
||||
</p>
|
||||
{/if}
|
||||
<ModalFooter>
|
||||
<Button class="btn btn-link" onclick={back}>
|
||||
<Icon icon={AltArrowLeft} />
|
||||
Go back
|
||||
</Button>
|
||||
<Button class="btn btn-primary" onclick={confirm} disabled={!invoice || sats === 0 || loading}>
|
||||
{#if loading}
|
||||
<span class="loading loading-spinner loading-sm"></span>
|
||||
{:else}
|
||||
<Icon icon={Bolt} />
|
||||
{/if}
|
||||
Confirm Payment
|
||||
</Button>
|
||||
</ModalFooter>
|
||||
</div>
|
||||
+37
-38
@@ -31,7 +31,7 @@ import {
|
||||
DELETE,
|
||||
REPORT,
|
||||
PROFILE,
|
||||
INBOX_RELAYS,
|
||||
MESSAGING_RELAYS,
|
||||
RELAYS,
|
||||
FOLLOWS,
|
||||
REACTION,
|
||||
@@ -46,7 +46,6 @@ import {
|
||||
APP_DATA,
|
||||
isSignedEvent,
|
||||
makeEvent,
|
||||
displayProfile,
|
||||
normalizeRelayUrl,
|
||||
makeList,
|
||||
addToListPublicly,
|
||||
@@ -79,21 +78,21 @@ import {
|
||||
session,
|
||||
repository,
|
||||
publishThunk,
|
||||
profilesByPubkey,
|
||||
tagEvent,
|
||||
tagEventForReaction,
|
||||
userRelaySelections,
|
||||
userInboxRelaySelections,
|
||||
userRelayList,
|
||||
userMessagingRelayList,
|
||||
nip44EncryptToSelf,
|
||||
dropSession,
|
||||
tagEventForComment,
|
||||
tagEventForQuote,
|
||||
waitForThunkError,
|
||||
getPubkeyRelays,
|
||||
userBlossomServers,
|
||||
userBlossomServerList,
|
||||
shouldUnwrap,
|
||||
} from "@welshman/app"
|
||||
import {compressFile} from "@src/lib/html"
|
||||
import {compressFile} from "@lib/html"
|
||||
import {kv, db} from "@app/core/storage"
|
||||
import type {SettingsValues, Alert} from "@app/core/state"
|
||||
import {
|
||||
SETTINGS,
|
||||
@@ -105,13 +104,11 @@ import {
|
||||
userSpaceUrls,
|
||||
userSettingsValues,
|
||||
getSetting,
|
||||
userInboxRelays,
|
||||
userGroupSelections,
|
||||
userGroupList,
|
||||
shouldIgnoreError,
|
||||
} from "@app/core/state"
|
||||
import {loadAlertStatuses} from "@app/core/requests"
|
||||
import {platform, platformName, getPushInfo} from "@app/util/push"
|
||||
import {preferencesStorageProvider, Collection} from "@src/lib/storage"
|
||||
|
||||
// Utils
|
||||
|
||||
@@ -122,13 +119,6 @@ export const getPubkeyHints = (pubkey: string) => {
|
||||
return hints
|
||||
}
|
||||
|
||||
export const getPubkeyPetname = (pubkey: string) => {
|
||||
const profile = profilesByPubkey.get().get(pubkey)
|
||||
const display = displayProfile(profile)
|
||||
|
||||
return display
|
||||
}
|
||||
|
||||
export const prependParent = (parent: TrustedEvent | undefined, {content, tags}: EventContent) => {
|
||||
if (parent) {
|
||||
const nevent = nip19.neventEncode({
|
||||
@@ -156,15 +146,15 @@ export const logout = async () => {
|
||||
|
||||
localStorage.clear()
|
||||
|
||||
await preferencesStorageProvider.clear()
|
||||
await Collection.clearAll()
|
||||
await kv.clear()
|
||||
await db.clear()
|
||||
}
|
||||
|
||||
// Synchronization
|
||||
|
||||
export const broadcastUserData = async (relays: string[]) => {
|
||||
const authors = [pubkey.get()!]
|
||||
const kinds = [RELAYS, INBOX_RELAYS, FOLLOWS, PROFILE]
|
||||
const kinds = [RELAYS, MESSAGING_RELAYS, FOLLOWS, PROFILE]
|
||||
const events = repository.query([{kinds, authors}])
|
||||
|
||||
for (const event of events) {
|
||||
@@ -177,7 +167,7 @@ export const broadcastUserData = async (relays: string[]) => {
|
||||
// List updates
|
||||
|
||||
export const addSpaceMembership = async (url: string) => {
|
||||
const list = get(userGroupSelections) || makeList({kind: ROOMS})
|
||||
const list = get(userGroupList) || makeList({kind: ROOMS})
|
||||
const event = await addToListPublicly(list, ["r", url]).reconcile(nip44EncryptToSelf)
|
||||
const relays = uniq([...Router.get().FromUser().getUrls(), ...getRelayTagValues(event.tags)])
|
||||
|
||||
@@ -185,7 +175,7 @@ export const addSpaceMembership = async (url: string) => {
|
||||
}
|
||||
|
||||
export const removeSpaceMembership = async (url: string) => {
|
||||
const list = get(userGroupSelections) || makeList({kind: ROOMS})
|
||||
const list = get(userGroupList) || makeList({kind: ROOMS})
|
||||
const pred = (t: string[]) => t[t[0] === "r" ? 1 : 2] === url
|
||||
const event = await removeFromListByPredicate(list, pred).reconcile(nip44EncryptToSelf)
|
||||
const relays = uniq([url, ...Router.get().FromUser().getUrls(), ...getRelayTagValues(event.tags)])
|
||||
@@ -194,7 +184,7 @@ export const removeSpaceMembership = async (url: string) => {
|
||||
}
|
||||
|
||||
export const addRoomMembership = async (url: string, h: string) => {
|
||||
const list = get(userGroupSelections) || makeList({kind: ROOMS})
|
||||
const list = get(userGroupList) || makeList({kind: ROOMS})
|
||||
const newTags = [
|
||||
["r", url],
|
||||
["group", h, url],
|
||||
@@ -206,7 +196,7 @@ export const addRoomMembership = async (url: string, h: string) => {
|
||||
}
|
||||
|
||||
export const removeRoomMembership = async (url: string, h: string) => {
|
||||
const list = get(userGroupSelections) || makeList({kind: ROOMS})
|
||||
const list = get(userGroupList) || makeList({kind: ROOMS})
|
||||
const pred = (t: string[]) => equals(["group", h, url], t.slice(0, 3))
|
||||
const event = await removeFromListByPredicate(list, pred).reconcile(nip44EncryptToSelf)
|
||||
const relays = uniq([url, ...Router.get().FromUser().getUrls(), ...getRelayTagValues(event.tags)])
|
||||
@@ -215,7 +205,7 @@ export const removeRoomMembership = async (url: string, h: string) => {
|
||||
}
|
||||
|
||||
export const setRelayPolicy = (url: string, read: boolean, write: boolean) => {
|
||||
const list = get(userRelaySelections) || makeList({kind: RELAYS})
|
||||
const list = get(userRelayList) || makeList({kind: RELAYS})
|
||||
const tags = getRelayTags(getListTags(list)).filter(t => normalizeRelayUrl(t[1]) !== url)
|
||||
|
||||
if (read && write) {
|
||||
@@ -232,10 +222,10 @@ export const setRelayPolicy = (url: string, read: boolean, write: boolean) => {
|
||||
})
|
||||
}
|
||||
|
||||
export const setInboxRelayPolicy = (url: string, enabled: boolean) => {
|
||||
const list = get(userInboxRelaySelections) || makeList({kind: INBOX_RELAYS})
|
||||
export const setMessagingRelayPolicy = (url: string, enabled: boolean) => {
|
||||
const list = get(userMessagingRelayList) || makeList({kind: MESSAGING_RELAYS})
|
||||
|
||||
// Only update inbox policies if they already exist or we're adding them
|
||||
// Only update messaging policies if they already exist or we're adding them
|
||||
if (enabled || getRelaysFromList(list).includes(url)) {
|
||||
const tags = getRelayTags(getListTags(list)).filter(t => normalizeRelayUrl(t[1]) !== url)
|
||||
|
||||
@@ -538,11 +528,13 @@ export const createDmAlert = async () => {
|
||||
shouldUnwrap.set(true)
|
||||
}
|
||||
|
||||
const $pubkey = pubkey.get()!
|
||||
|
||||
return createAlert({
|
||||
description: `for direct messages.`,
|
||||
feed: makeIntersectionFeed(
|
||||
feedFromFilters([{kinds: [WRAP], "#p": [pubkey.get()!]}]),
|
||||
makeRelayFeed(...get(userInboxRelays)),
|
||||
feedFromFilters([{kinds: [WRAP], "#p": [$pubkey]}]),
|
||||
makeRelayFeed(...getPubkeyRelays($pubkey, RelayMode.Messaging)),
|
||||
),
|
||||
})
|
||||
}
|
||||
@@ -592,7 +584,7 @@ export const publishLeaveRequest = (params: LeaveRequestParams) =>
|
||||
|
||||
export const getWebLn = () => (window as any).webln
|
||||
|
||||
export const payInvoice = async (invoice: string) => {
|
||||
export const payInvoice = async (invoice: string, msats?: number) => {
|
||||
const $session = session.get()
|
||||
|
||||
if (!$session?.wallet) {
|
||||
@@ -600,8 +592,11 @@ export const payInvoice = async (invoice: string) => {
|
||||
}
|
||||
|
||||
if ($session.wallet.type === "nwc") {
|
||||
return new nwc.NWCClient($session.wallet.info).payInvoice({invoice})
|
||||
const params: {invoice: string; amount?: number} = {invoice}
|
||||
if (msats) params.amount = msats
|
||||
return new nwc.NWCClient($session.wallet.info).payInvoice(params)
|
||||
} else if ($session.wallet.type === "webln") {
|
||||
if (msats) throw new Error("Unable to pay zero invoices with webln")
|
||||
return getWebLn()
|
||||
.enable()
|
||||
.then(() => getWebLn().sendPayment(invoice))
|
||||
@@ -612,7 +607,7 @@ export const payInvoice = async (invoice: string) => {
|
||||
|
||||
export const normalizeBlossomUrl = (url: string) => normalizeUrl(url.replace(/^ws/, "http"))
|
||||
|
||||
export const hasBlossomSupport = simpleCache(async ([url]: [string]) => {
|
||||
export const fetchHasBlossomSupport = async (url: string) => {
|
||||
const server = normalizeBlossomUrl(url)
|
||||
const $signer = signer.get() || Nip01Signer.ephemeral()
|
||||
const headers: Record<string, string> = {
|
||||
@@ -633,7 +628,9 @@ export const hasBlossomSupport = simpleCache(async ([url]: [string]) => {
|
||||
}
|
||||
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
export const hasBlossomSupport = simpleCache(([url]: [string]) => fetchHasBlossomSupport(url))
|
||||
|
||||
export type GetBlossomServerOptions = {
|
||||
url?: string
|
||||
@@ -646,7 +643,7 @@ export const getBlossomServer = async (options: GetBlossomServerOptions = {}) =>
|
||||
}
|
||||
}
|
||||
|
||||
const userUrls = getTagValues("server", getListTags(userBlossomServers.get()))
|
||||
const userUrls = getTagValues("server", getListTags(get(userBlossomServerList)))
|
||||
|
||||
for (const url of userUrls) {
|
||||
return normalizeBlossomUrl(url)
|
||||
@@ -658,6 +655,8 @@ export const getBlossomServer = async (options: GetBlossomServerOptions = {}) =>
|
||||
export type UploadFileOptions = {
|
||||
url?: string
|
||||
encrypt?: boolean
|
||||
maxWidth?: number
|
||||
maxHeight?: number
|
||||
}
|
||||
|
||||
export type UploadFileResult = {
|
||||
@@ -669,8 +668,8 @@ export const uploadFile = async (file: File, options: UploadFileOptions = {}) =>
|
||||
try {
|
||||
const {name, type} = file
|
||||
|
||||
if (!type.match("image/(webp|gif)")) {
|
||||
file = await compressFile(file)
|
||||
if (!type.match("image/(webp|gif|svg)")) {
|
||||
file = await compressFile(file, options)
|
||||
}
|
||||
|
||||
const tags: string[][] = []
|
||||
@@ -701,7 +700,7 @@ export const uploadFile = async (file: File, options: UploadFileOptions = {}) =>
|
||||
let {uploaded, url, ...task} = parseJson(text) || {}
|
||||
|
||||
if (!uploaded) {
|
||||
return {error: text}
|
||||
return {error: text || `Failed to upload file (HTTP ${res.status})`}
|
||||
}
|
||||
|
||||
// Always append correct file extension if we encrypted the file, or if it's missing
|
||||
|
||||
@@ -4,11 +4,12 @@ import {
|
||||
int,
|
||||
YEAR,
|
||||
DAY,
|
||||
assoc,
|
||||
insertAt,
|
||||
sortBy,
|
||||
now,
|
||||
on,
|
||||
isNotNil,
|
||||
isDefined,
|
||||
filterVals,
|
||||
fromPairs,
|
||||
} from "@welshman/lib"
|
||||
@@ -32,7 +33,7 @@ import {load, request} from "@welshman/net"
|
||||
import {repository, makeFeedController, loadRelay, tracker} from "@welshman/app"
|
||||
import {createScroller} from "@lib/html"
|
||||
import {daysBetween} from "@lib/util"
|
||||
import {NOTIFIER_RELAY, getEventsForUrl} from "@app/core/state"
|
||||
import {NOTIFIER_RELAY} from "@app/core/state"
|
||||
|
||||
// Utils
|
||||
|
||||
@@ -47,7 +48,9 @@ export const makeFeed = ({
|
||||
element: HTMLElement
|
||||
onExhausted?: () => void
|
||||
}) => {
|
||||
const initialEvents = getEventsForUrl(url, filters)
|
||||
const initialIds = Array.from(tracker.getIds(url))
|
||||
const initialFilters = filters.map(assoc("ids", initialIds))
|
||||
const initialEvents = repository.query(initialFilters)
|
||||
const seen = new Set(initialEvents.map(e => e.id))
|
||||
const controller = new AbortController()
|
||||
const buffer = writable(initialEvents)
|
||||
@@ -144,7 +147,9 @@ export const makeCalendarFeed = ({
|
||||
}) => {
|
||||
const interval = int(5, DAY)
|
||||
const controller = new AbortController()
|
||||
const initialEvents = getEventsForUrl(url, filters)
|
||||
const initialIds = Array.from(tracker.getIds(url))
|
||||
const initialFilters = filters.map(assoc("ids", initialIds))
|
||||
const initialEvents = repository.query(initialFilters)
|
||||
|
||||
let exhaustedScrollers = 0
|
||||
let backwardWindow = [now() - interval, now()]
|
||||
@@ -279,6 +284,6 @@ export const requestRelayClaim = async (url: string) => {
|
||||
|
||||
export const requestRelayClaims = async (urls: string[]) =>
|
||||
filterVals(
|
||||
isNotNil,
|
||||
isDefined,
|
||||
fromPairs(await Promise.all(urls.map(async url => [url, await requestRelayClaim(url)]))),
|
||||
)
|
||||
|
||||
+295
-325
@@ -1,33 +1,34 @@
|
||||
import twColors from "tailwindcss/colors"
|
||||
import {Capacitor} from "@capacitor/core"
|
||||
import {get, derived, writable} from "svelte/store"
|
||||
import {get, derived, readable, writable} from "svelte/store"
|
||||
import * as nip19 from "nostr-tools/nip19"
|
||||
import {
|
||||
on,
|
||||
gt,
|
||||
max,
|
||||
find,
|
||||
spec,
|
||||
call,
|
||||
first,
|
||||
assoc,
|
||||
remove,
|
||||
uniqBy,
|
||||
sortBy,
|
||||
append,
|
||||
sort,
|
||||
prop,
|
||||
uniq,
|
||||
indexBy,
|
||||
partition,
|
||||
pushToMapKey,
|
||||
shuffle,
|
||||
parseJson,
|
||||
memoize,
|
||||
addToMapKey,
|
||||
identity,
|
||||
groupBy,
|
||||
always,
|
||||
tryCatch,
|
||||
fromPairs,
|
||||
} from "@welshman/lib"
|
||||
import type {Socket} from "@welshman/net"
|
||||
import type {Override} from "@welshman/lib"
|
||||
import type {RepositoryUpdate} from "@welshman/net"
|
||||
import {
|
||||
Pool,
|
||||
load,
|
||||
@@ -37,7 +38,17 @@ import {
|
||||
SocketEvent,
|
||||
netContext,
|
||||
} from "@welshman/net"
|
||||
import {collection, custom, throttled, deriveEvents, deriveEventsMapped} from "@welshman/store"
|
||||
import {
|
||||
getter,
|
||||
throttled,
|
||||
deriveArray,
|
||||
makeDeriveEvent,
|
||||
makeLoadItem,
|
||||
makeDeriveItem,
|
||||
deriveItemsByKey,
|
||||
deriveEventsByIdByUrl,
|
||||
deriveEventsByIdForUrl,
|
||||
} from "@welshman/store"
|
||||
import {isKindFeed, findFeed} from "@welshman/feeds"
|
||||
import {
|
||||
ALERT_ANDROID,
|
||||
@@ -72,16 +83,14 @@ import {
|
||||
ROOMS,
|
||||
THREAD,
|
||||
WRAP,
|
||||
PROFILE,
|
||||
ZAP_GOAL,
|
||||
ZAP_REQUEST,
|
||||
ZAP_RESPONSE,
|
||||
asDecryptedEvent,
|
||||
displayProfile,
|
||||
getGroupTags,
|
||||
getIdFilters,
|
||||
getListTags,
|
||||
getPubkeyTagValues,
|
||||
getRelaysFromList,
|
||||
getRelayTagValues,
|
||||
getTagValue,
|
||||
getTagValues,
|
||||
@@ -89,47 +98,33 @@ import {
|
||||
makeEvent,
|
||||
normalizeRelayUrl,
|
||||
readList,
|
||||
RelayMode,
|
||||
verifyEvent,
|
||||
readRoomMeta,
|
||||
makeRoomMeta,
|
||||
ManagementMethod,
|
||||
} from "@welshman/util"
|
||||
import type {
|
||||
TrustedEvent,
|
||||
RelayProfile,
|
||||
PublishedList,
|
||||
PublishedRoomMeta,
|
||||
List,
|
||||
Filter,
|
||||
} from "@welshman/util"
|
||||
import type {TrustedEvent, RelayProfile, PublishedRoomMeta, List, Filter} from "@welshman/util"
|
||||
import {decrypt} from "@welshman/signer"
|
||||
import {routerContext, Router} from "@welshman/router"
|
||||
import {
|
||||
pubkey,
|
||||
repository,
|
||||
profilesByPubkey,
|
||||
tracker,
|
||||
makeTrackerStore,
|
||||
makeRepositoryStore,
|
||||
createSearch,
|
||||
userFollows,
|
||||
userFollowList,
|
||||
ensurePlaintext,
|
||||
thunks,
|
||||
sign,
|
||||
signer,
|
||||
makeOutboxLoader,
|
||||
appContext,
|
||||
getThunkError,
|
||||
publishThunk,
|
||||
userRelaySelections,
|
||||
userInboxRelaySelections,
|
||||
deriveRelay,
|
||||
makeUserData,
|
||||
makeUserLoader,
|
||||
manageRelay,
|
||||
displayProfileByPubkey,
|
||||
} from "@welshman/app"
|
||||
import type {Thunk} from "@welshman/app"
|
||||
|
||||
export const fromCsv = (s: string) => (s || "").split(",").filter(identity)
|
||||
|
||||
@@ -208,87 +203,28 @@ export const entityLink = (entity: string) => `https://coracle.social/${entity}`
|
||||
export const pubkeyLink = (pubkey: string, relays = Router.get().FromPubkeys([pubkey]).getUrls()) =>
|
||||
entityLink(nip19.nprofileEncode({pubkey, relays}))
|
||||
|
||||
export const bootstrapPubkeys = derived(userFollows, $userFollows => {
|
||||
export const bootstrapPubkeys = derived(userFollowList, $userFollowList => {
|
||||
const appPubkeys = DEFAULT_PUBKEYS.split(",")
|
||||
const userPubkeys = shuffle(getPubkeyTagValues(getListTags($userFollows)))
|
||||
const userPubkeys = shuffle(getPubkeyTagValues(getListTags($userFollowList)))
|
||||
|
||||
return userPubkeys.length > 5 ? userPubkeys : [...userPubkeys, ...appPubkeys]
|
||||
})
|
||||
|
||||
export const trackerStore = makeTrackerStore()
|
||||
|
||||
export const repositoryStore = makeRepositoryStore()
|
||||
|
||||
export const deriveEvent = (idOrAddress: string, hints: string[] = []) => {
|
||||
let attempted = false
|
||||
|
||||
const filters = getIdFilters([idOrAddress])
|
||||
const relays = [...hints, ...INDEXER_RELAYS]
|
||||
|
||||
return derived(
|
||||
deriveEvents(repository, {filters, includeDeleted: true}),
|
||||
(events: TrustedEvent[]) => {
|
||||
if (!attempted && events.length === 0) {
|
||||
load({relays, filters})
|
||||
attempted = true
|
||||
}
|
||||
|
||||
return events[0]
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
export const getUrlsForEvent = derived([trackerStore, thunks], ([$tracker, $thunks]) => {
|
||||
const getThunksByEventId = memoize(() => {
|
||||
const thunksByEventId = new Map<string, Thunk[]>()
|
||||
|
||||
for (const thunk of $thunks) {
|
||||
pushToMapKey(thunksByEventId, thunk.event.id, thunk)
|
||||
}
|
||||
|
||||
return thunksByEventId
|
||||
})
|
||||
|
||||
return (id: string) => {
|
||||
const urls = Array.from($tracker.getRelays(id))
|
||||
|
||||
for (const thunk of getThunksByEventId().get(id) || []) {
|
||||
for (const url of thunk.options.relays) {
|
||||
urls.push(url)
|
||||
}
|
||||
}
|
||||
|
||||
return uniq(urls)
|
||||
}
|
||||
export const deriveEvent = makeDeriveEvent({
|
||||
repository,
|
||||
includeDeleted: true,
|
||||
onDerive: (filters: Filter[], relays: string[]) => load({filters, relays}),
|
||||
})
|
||||
|
||||
export const getEventsForUrl = (url: string, filters: Filter[]) => {
|
||||
const ids = uniq([
|
||||
...tracker.getIds(url),
|
||||
...get(thunks)
|
||||
.filter(t => t.options.relays.includes(url))
|
||||
.map(t => t.event.id),
|
||||
])
|
||||
|
||||
return repository.query(filters.map(assoc("ids", ids)))
|
||||
}
|
||||
|
||||
export const deriveEventsForUrl = (url: string, filters: Filter[]) =>
|
||||
derived([trackerStore, thunks], ([$tracker, $thunks]) => {
|
||||
const ids = uniq([
|
||||
...$tracker.getIds(url),
|
||||
...$thunks.filter(t => t.options.relays.includes(url)).map(t => t.event.id),
|
||||
])
|
||||
deriveArray(deriveEventsByIdForUrl({url, tracker, repository, filters}))
|
||||
|
||||
return repository.query(filters.map(assoc("ids", ids)))
|
||||
})
|
||||
|
||||
export const deriveSignedEventsForUrl = (url: string, filters: Filter[]) =>
|
||||
export const deriveRelaySignedEvents = (url: string, filters: Filter[]) =>
|
||||
derived(
|
||||
[deriveEventsForUrl(url, filters), deriveRelay(url)],
|
||||
([$events, $relay]) => $events,
|
||||
// Disable this check for now since khatru doesn't support self
|
||||
// $relay?.self ? $events.filter(spec({pubkey: $relay.self})) : [],
|
||||
[deriveRelay(url), deriveEventsForUrl(url, filters)],
|
||||
([relay, events]) => events,
|
||||
// khatru doesn't support relay.self, uncomment when it's ready
|
||||
// filter(spec({pubkey: relay.self}), events)
|
||||
)
|
||||
|
||||
// Context
|
||||
@@ -351,30 +287,27 @@ export const defaultSettings = {
|
||||
show_notifications_badge: true,
|
||||
}
|
||||
|
||||
export const settings = deriveEventsMapped<Settings>(repository, {
|
||||
filters: [{kinds: [APP_DATA], "#d": [SETTINGS]}],
|
||||
itemToEvent: item => item.event,
|
||||
eventToItem: async (event: TrustedEvent) => ({
|
||||
event,
|
||||
values: {...defaultSettings, ...parseJson(await ensurePlaintext(event))},
|
||||
}),
|
||||
})
|
||||
|
||||
export const {
|
||||
indexStore: settingsByPubkey,
|
||||
deriveItem: deriveSettings,
|
||||
loadItem: loadSettings,
|
||||
} = collection({
|
||||
name: "settings",
|
||||
store: settings,
|
||||
export const settingsByPubkey = deriveItemsByKey({
|
||||
repository,
|
||||
getKey: settings => settings.event.pubkey,
|
||||
load: makeOutboxLoader(APP_DATA, {"#d": [SETTINGS]}),
|
||||
filters: [{kinds: [APP_DATA], "#d": [SETTINGS]}],
|
||||
eventToItem: async (event: TrustedEvent) => {
|
||||
const values = {...defaultSettings, ...parseJson(await ensurePlaintext(event))}
|
||||
|
||||
return {event, values}
|
||||
},
|
||||
})
|
||||
|
||||
export const userSettings = makeUserData({
|
||||
mapStore: settingsByPubkey,
|
||||
loadItem: loadSettings,
|
||||
})
|
||||
export const getSettingsByPubkey = getter(settingsByPubkey)
|
||||
|
||||
export const getSettings = (pubkey: string) => getSettingsByPubkey().get(pubkey)
|
||||
|
||||
export const loadSettings = makeLoadItem(
|
||||
makeOutboxLoader(APP_DATA, {"#d": [SETTINGS]}),
|
||||
getSettings,
|
||||
)
|
||||
|
||||
export const userSettings = makeUserData(settingsByPubkey, loadSettings)
|
||||
|
||||
export const loadUserSettings = makeUserLoader(loadSettings)
|
||||
|
||||
@@ -390,18 +323,6 @@ export const relaysPendingTrust = writable<string[]>([])
|
||||
|
||||
export const relaysMostlyRestricted = writable<Record<string, string>>({})
|
||||
|
||||
// Relay selections
|
||||
|
||||
export const userReadRelays = derived(userRelaySelections, $l =>
|
||||
getRelaysFromList($l, RelayMode.Read),
|
||||
)
|
||||
|
||||
export const userWriteRelays = derived(userRelaySelections, $l =>
|
||||
getRelaysFromList($l, RelayMode.Write),
|
||||
)
|
||||
|
||||
export const userInboxRelays = derived(userInboxRelaySelections, $l => getRelaysFromList($l))
|
||||
|
||||
// Alerts
|
||||
|
||||
export type Alert = {
|
||||
@@ -409,9 +330,10 @@ export type Alert = {
|
||||
tags: string[][]
|
||||
}
|
||||
|
||||
export const alerts = deriveEventsMapped<Alert>(repository, {
|
||||
export const alertsById = deriveItemsByKey<Alert>({
|
||||
repository,
|
||||
getKey: alert => alert.event.id,
|
||||
filters: [{kinds: [ALERT_EMAIL, ALERT_WEB, ALERT_IOS, ALERT_ANDROID]}],
|
||||
itemToEvent: item => item.event,
|
||||
eventToItem: async event => {
|
||||
const $signer = signer.get()
|
||||
|
||||
@@ -426,13 +348,13 @@ export const alerts = deriveEventsMapped<Alert>(repository, {
|
||||
export const getAlertFeed = (alert: Alert) =>
|
||||
tryCatch(() => JSON.parse(getTagValue("feed", alert.tags)!))
|
||||
|
||||
export const dmAlert = derived(alerts, $alerts =>
|
||||
$alerts.find(alert => {
|
||||
const feed = getAlertFeed(alert)
|
||||
|
||||
return findFeed(feed, f => isKindFeed(f) && f.includes(WRAP))
|
||||
}),
|
||||
)
|
||||
export const dmAlert = derived(alertsById, $alertsById => {
|
||||
for (const alert of $alertsById.values()) {
|
||||
if (findFeed(getAlertFeed(alert), f => isKindFeed(f) && f.includes(WRAP))) {
|
||||
return alert
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// Alert Statuses
|
||||
|
||||
@@ -441,9 +363,10 @@ export type AlertStatus = {
|
||||
tags: string[][]
|
||||
}
|
||||
|
||||
export const alertStatuses = deriveEventsMapped<AlertStatus>(repository, {
|
||||
export const alertStatusesByAddress = deriveItemsByKey<AlertStatus>({
|
||||
repository,
|
||||
filters: [{kinds: [ALERT_STATUS]}],
|
||||
itemToEvent: item => item.event,
|
||||
getKey: alertStatus => getTagValue("d", alertStatus.event.tags)!,
|
||||
eventToItem: async event => {
|
||||
const $signer = signer.get()
|
||||
|
||||
@@ -455,15 +378,10 @@ export const alertStatuses = deriveEventsMapped<AlertStatus>(repository, {
|
||||
},
|
||||
})
|
||||
|
||||
export const deriveAlertStatus = (address: string) =>
|
||||
derived(alertStatuses, statuses => statuses.find(s => getTagValue("d", s.event.tags) === address))
|
||||
export const deriveAlertStatus = makeDeriveItem(alertStatusesByAddress)
|
||||
|
||||
// Chats
|
||||
|
||||
export const chatMessages = deriveEvents(repository, {
|
||||
filters: [{kinds: [DIRECT_MESSAGE, DIRECT_MESSAGE_FILE]}],
|
||||
})
|
||||
|
||||
export type Chat = {
|
||||
id: string
|
||||
pubkeys: string[]
|
||||
@@ -472,66 +390,85 @@ export type Chat = {
|
||||
search_text: string
|
||||
}
|
||||
|
||||
export const makeChatId = (pubkeys: string[]) => sort(uniq(pubkeys.concat(pubkey.get()!))).join(",")
|
||||
export const makeChatId = (pubkeys: string[]) => sort(uniq(pubkeys)).join(",")
|
||||
|
||||
export const splitChatId = (id: string) => id.split(",")
|
||||
|
||||
export const chats = derived(
|
||||
[pubkey, chatMessages, profilesByPubkey],
|
||||
([$pubkey, $messages, $profilesByPubkey]) => {
|
||||
const messagesByChatId = new Map<string, TrustedEvent[]>()
|
||||
export const chatsById = call(() => {
|
||||
const chatsById = new Map<string, Chat>()
|
||||
const chatsByPubkey = new Map<string, Chat[]>()
|
||||
|
||||
for (const message of $messages) {
|
||||
const chatId = makeChatId(getPubkeyTagValues(message.tags).concat(message.pubkey))
|
||||
const addSearchText = (chat: Override<Chat, {search_text?: string}>) => {
|
||||
chat.search_text =
|
||||
chat.pubkeys.length === 1
|
||||
? displayProfileByPubkey(chat.pubkeys[0]) + " note to self"
|
||||
: chat.pubkeys.map(displayProfileByPubkey).join(" ")
|
||||
|
||||
pushToMapKey(messagesByChatId, chatId, message)
|
||||
return chat as Chat
|
||||
}
|
||||
|
||||
return readable(chatsById, set => {
|
||||
const addEvents = (events: TrustedEvent[]) => {
|
||||
let dirty = false
|
||||
for (const event of events) {
|
||||
if ([DIRECT_MESSAGE, DIRECT_MESSAGE_FILE].includes(event.kind)) {
|
||||
const pubkeys = getPubkeyTagValues(event.tags).concat(event.pubkey)
|
||||
const id = makeChatId(pubkeys)
|
||||
const chat = chatsById.get(id)
|
||||
const messages = append(event, chat?.messages || [])
|
||||
const last_activity = Math.max(chat?.last_activity || 0, event.created_at)
|
||||
const updatedChat = addSearchText({id, pubkeys, messages, last_activity})
|
||||
|
||||
chatsById.set(id, updatedChat)
|
||||
|
||||
for (const pubkey of pubkeys) {
|
||||
const pubkeyChats = chatsByPubkey.get(pubkey) || []
|
||||
const uniqueChats = uniqBy(chat => chat.id, append(updatedChat, pubkeyChats))
|
||||
|
||||
chatsByPubkey.set(pubkey, uniqueChats)
|
||||
}
|
||||
|
||||
dirty = true
|
||||
}
|
||||
|
||||
if (event.kind === PROFILE) {
|
||||
for (const chat of chatsByPubkey.get(event.pubkey) || []) {
|
||||
addSearchText(chat)
|
||||
dirty = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dirty) {
|
||||
set(chatsById)
|
||||
}
|
||||
}
|
||||
|
||||
const displayPubkey = (pubkey: string) => {
|
||||
const profile = $profilesByPubkey.get(pubkey)
|
||||
addEvents(repository.query([{kinds: [DIRECT_MESSAGE, PROFILE]}]))
|
||||
|
||||
return profile ? displayProfile(profile) : ""
|
||||
}
|
||||
const unsubscribers = [
|
||||
on(repository, "update", ({added}: RepositoryUpdate) => addEvents(added)),
|
||||
]
|
||||
|
||||
return sortBy(
|
||||
c => -c.last_activity,
|
||||
Array.from(messagesByChatId.entries()).map(([id, events]): Chat => {
|
||||
const pubkeys = remove($pubkey!, splitChatId(id))
|
||||
const messages = sortBy(e => -e.created_at, uniqBy(prop("id"), events))
|
||||
const last_activity = messages[0].created_at
|
||||
const search_text =
|
||||
pubkeys.length === 0
|
||||
? displayPubkey($pubkey!) + " note to self"
|
||||
: pubkeys.map(displayPubkey).join(" ")
|
||||
|
||||
return {id, pubkeys, messages, last_activity, search_text}
|
||||
}),
|
||||
)
|
||||
},
|
||||
)
|
||||
|
||||
export const {
|
||||
indexStore: chatsById,
|
||||
deriveItem: deriveChat,
|
||||
loadItem: loadChat,
|
||||
} = collection({
|
||||
name: "chats",
|
||||
store: chats,
|
||||
getKey: chat => chat.id,
|
||||
load: always(Promise.resolve()),
|
||||
return () => unsubscribers.forEach(call)
|
||||
})
|
||||
})
|
||||
|
||||
export const chatSearch = derived(chats, $chats =>
|
||||
createSearch($chats, {
|
||||
export const deriveChat = call(() => {
|
||||
const _deriveChat = makeDeriveItem(chatsById)
|
||||
|
||||
return (pubkeys: string[]) => _deriveChat(makeChatId(pubkeys))
|
||||
})
|
||||
|
||||
export const chatSearch = derived(throttled(800, chatsById), $chatsByPubkey => {
|
||||
return createSearch(Array.from($chatsByPubkey.values()), {
|
||||
getValue: (chat: Chat) => chat.id,
|
||||
fuseOptions: {keys: ["search_text"]},
|
||||
}),
|
||||
)
|
||||
})
|
||||
})
|
||||
|
||||
// Rooms
|
||||
|
||||
export const messages = deriveEvents(repository, {filters: [{kinds: [MESSAGE]}]})
|
||||
|
||||
export type Room = PublishedRoomMeta & {
|
||||
id: string
|
||||
url: string
|
||||
@@ -544,95 +481,94 @@ export const splitRoomId = (id: string) => id.split("'")
|
||||
export const hasNip29 = (relay?: RelayProfile) =>
|
||||
relay?.supported_nips?.map?.(String)?.includes?.("29")
|
||||
|
||||
export const roomMetas = deriveEventsMapped<PublishedRoomMeta>(repository, {
|
||||
filters: [{kinds: [ROOM_META]}],
|
||||
itemToEvent: item => item.event,
|
||||
eventToItem: readRoomMeta,
|
||||
export const roomMetaEventsByIdByUrl = deriveEventsByIdByUrl({
|
||||
tracker,
|
||||
repository,
|
||||
filters: [{kinds: [ROOM_META, ROOM_DELETE]}],
|
||||
})
|
||||
|
||||
export const roomDeletes = deriveEvents(repository, {
|
||||
filters: [{kinds: [ROOM_DELETE]}],
|
||||
})
|
||||
export const roomsByUrl = derived(roomMetaEventsByIdByUrl, roomMetaEventsByIdByUrl => {
|
||||
const result = new Map<string, Room[]>()
|
||||
|
||||
export const rooms = derived(
|
||||
[roomMetas, roomDeletes, getUrlsForEvent],
|
||||
([$roomMetas, $roomDeletes, $getUrlsForEvent]) => {
|
||||
const result = new Map<string, Room>()
|
||||
for (const [url, events] of roomMetaEventsByIdByUrl.entries()) {
|
||||
const [metaEvents, deleteEvents] = partition(spec({kind: ROOM_META}), events.values())
|
||||
const deletedByH = new Map<string, number>()
|
||||
|
||||
for (const event of $roomDeletes) {
|
||||
for (const event of deleteEvents) {
|
||||
for (const h of getTagValues("h", event.tags)) {
|
||||
deletedByH.set(h, max([deletedByH.get(h), event.created_at]))
|
||||
}
|
||||
}
|
||||
|
||||
for (const meta of $roomMetas) {
|
||||
for (const event of metaEvents) {
|
||||
const meta = readRoomMeta(event)
|
||||
|
||||
if (gt(deletedByH.get(meta.h), meta.event.created_at)) {
|
||||
continue
|
||||
}
|
||||
|
||||
for (const url of $getUrlsForEvent(meta.event.id)) {
|
||||
const id = makeRoomId(url, meta.h)
|
||||
|
||||
result.set(id, {...meta, url, id})
|
||||
}
|
||||
pushToMapKey(result, url, {...meta, url, id: makeRoomId(url, meta.h)})
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(result.values())
|
||||
},
|
||||
return result
|
||||
})
|
||||
|
||||
export const roomsById = derived(roomsByUrl, roomsByUrl =>
|
||||
indexBy(room => room.id, Array.from(roomsByUrl.values()).flatMap(identity)),
|
||||
)
|
||||
|
||||
export const roomsByUrl = derived(rooms, $rooms => groupBy(c => c.url, $rooms))
|
||||
export const getRoomsById = getter(roomsById)
|
||||
|
||||
export const {
|
||||
indexStore: roomsById,
|
||||
deriveItem: _deriveRoom,
|
||||
loadItem: _loadRoom,
|
||||
} = collection({
|
||||
name: "rooms",
|
||||
store: rooms,
|
||||
getKey: room => room.id,
|
||||
load: async (id: string) => {
|
||||
export const getRoom = (id: string) => getRoomsById().get(id)
|
||||
|
||||
export const loadRoom = call(() => {
|
||||
const _fetchRoom = async (id: string) => {
|
||||
const [url, h] = splitRoomId(id)
|
||||
|
||||
await load({
|
||||
relays: [url],
|
||||
filters: [{kinds: [ROOM_META], "#d": [h]}],
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
const _loadRoom = makeLoadItem(_fetchRoom, getRoom)
|
||||
|
||||
return (url: string, h: string) => _loadRoom(makeRoomId(url, h))
|
||||
})
|
||||
|
||||
export const deriveRoom = (url: string, h: string) =>
|
||||
derived(_deriveRoom(makeRoomId(url, h)), $meta => $meta || makeRoomMeta({h}))
|
||||
export const deriveRoom = call(() => {
|
||||
const _deriveRoom = makeDeriveItem(roomsById, loadRoom)
|
||||
|
||||
export const displayRoom = (url: string, h: string) =>
|
||||
roomsById.get().get(makeRoomId(url, h))?.name || h
|
||||
return (url: string, h: string) =>
|
||||
derived(_deriveRoom(makeRoomId(url, h)), room => room || makeRoomMeta({h}))
|
||||
})
|
||||
|
||||
export const displayRoom = (url: string, h: string) => getRoom(makeRoomId(url, h))?.name || h
|
||||
|
||||
export const roomComparator = (url: string) => (h: string) => displayRoom(url, h).toLowerCase()
|
||||
|
||||
// User space/room selections
|
||||
// User space/room lists
|
||||
|
||||
export const groupSelections = deriveEventsMapped<PublishedList>(repository, {
|
||||
export const groupListsByPubkey = deriveItemsByKey({
|
||||
repository,
|
||||
filters: [{kinds: [ROOMS]}],
|
||||
itemToEvent: item => item.event,
|
||||
getKey: list => list.event.pubkey,
|
||||
eventToItem: (event: TrustedEvent) => readList(asDecryptedEvent(event)),
|
||||
})
|
||||
|
||||
export const {
|
||||
indexStore: groupSelectionsByPubkey,
|
||||
deriveItem: deriveGroupSelections,
|
||||
loadItem: loadGroupSelections,
|
||||
} = collection({
|
||||
name: "groupSelections",
|
||||
store: groupSelections,
|
||||
getKey: list => list.event.pubkey,
|
||||
load: makeOutboxLoader(ROOMS),
|
||||
})
|
||||
export const getGroupListsByPubkey = getter(groupListsByPubkey)
|
||||
|
||||
export const groupSelectionsPubkeysByUrl = derived(groupSelections, $groupSelections => {
|
||||
export const getGroupList = (pubkey: string) => getGroupListsByPubkey().get(pubkey)
|
||||
|
||||
export const loadGroupList = makeLoadItem(makeOutboxLoader(ROOMS), getGroupList)
|
||||
|
||||
export const deriveGroupList = makeDeriveItem(groupListsByPubkey, loadGroupList)
|
||||
|
||||
export const groupListPubkeysByUrl = derived(groupListsByPubkey, $groupListsByPubkey => {
|
||||
const result = new Map<string, Set<string>>()
|
||||
|
||||
for (const list of $groupSelections) {
|
||||
for (const list of $groupListsByPubkey.values()) {
|
||||
const tags = getListTags(list)
|
||||
|
||||
for (const url of getRelayTagValues(tags)) {
|
||||
@@ -651,8 +587,11 @@ export const groupSelectionsPubkeysByUrl = derived(groupSelections, $groupSelect
|
||||
return result
|
||||
})
|
||||
|
||||
export const getSpaceUrlsFromGroupSelections = ($groupSelections: List | undefined) => {
|
||||
const tags = getListTags($groupSelections)
|
||||
export const deriveGroupListPubkeys = (url: string) =>
|
||||
derived(groupListPubkeysByUrl, $groupListPubkeysByUrl => new Set($groupListPubkeysByUrl.get(url)))
|
||||
|
||||
export const getSpaceUrlsFromGroupList = (groupList: List | undefined) => {
|
||||
const tags = getListTags(groupList)
|
||||
const urls = getRelayTagValues(tags)
|
||||
|
||||
for (const tag of getGroupTags(tags)) {
|
||||
@@ -666,13 +605,10 @@ export const getSpaceUrlsFromGroupSelections = ($groupSelections: List | undefin
|
||||
return uniq(urls.map(normalizeRelayUrl))
|
||||
}
|
||||
|
||||
export const getSpaceRoomsFromGroupSelections = (
|
||||
url: string,
|
||||
$groupSelections: List | undefined,
|
||||
) => {
|
||||
export const getSpaceRoomsFromGroupList = (url: string, groupList: List | undefined) => {
|
||||
const rooms: string[] = []
|
||||
|
||||
for (const [_, h, relay] of getGroupTags(getListTags($groupSelections))) {
|
||||
for (const [_, h, relay] of getGroupTags(getListTags(groupList))) {
|
||||
if (url === relay) {
|
||||
rooms.push(h)
|
||||
}
|
||||
@@ -681,20 +617,17 @@ export const getSpaceRoomsFromGroupSelections = (
|
||||
return sortBy(roomComparator(url), rooms)
|
||||
}
|
||||
|
||||
export const userGroupSelections = makeUserData({
|
||||
mapStore: groupSelectionsByPubkey,
|
||||
loadItem: loadGroupSelections,
|
||||
})
|
||||
export const userGroupList = makeUserData(groupListsByPubkey, loadGroupList)
|
||||
|
||||
export const loadUserGroupSelections = makeUserLoader(loadGroupSelections)
|
||||
export const loadUserGroupList = makeUserLoader(loadGroupList)
|
||||
|
||||
export const userSpaceUrls = derived(userGroupSelections, getSpaceUrlsFromGroupSelections)
|
||||
export const userSpaceUrls = derived(userGroupList, getSpaceUrlsFromGroupList)
|
||||
|
||||
export const deriveUserRooms = (url: string) =>
|
||||
derived([userGroupSelections, roomsById], ([$userGroupSelections, $roomsById]) => {
|
||||
derived([userGroupList, roomsById], ([$userGroupList, $roomsById]) => {
|
||||
const rooms: string[] = []
|
||||
|
||||
for (const h of getSpaceRoomsFromGroupSelections(url, $userGroupSelections)) {
|
||||
for (const h of getSpaceRoomsFromGroupList(url, $userGroupList)) {
|
||||
if ($roomsById.has(makeRoomId(url, h))) {
|
||||
rooms.push(h)
|
||||
}
|
||||
@@ -720,17 +653,15 @@ export const deriveOtherRooms = (url: string) =>
|
||||
|
||||
export const deriveSpaceMembers = (url: string) =>
|
||||
derived(
|
||||
deriveSignedEventsForUrl(url, [
|
||||
{kinds: [RELAY_ADD_MEMBER, RELAY_REMOVE_MEMBER, RELAY_MEMBERS]},
|
||||
]),
|
||||
deriveRelaySignedEvents(url, [{kinds: [RELAY_ADD_MEMBER, RELAY_REMOVE_MEMBER, RELAY_MEMBERS]}]),
|
||||
$events => {
|
||||
const membersEvent = $events.find(spec({kind: RELAY_MEMBERS}))
|
||||
|
||||
if (membersEvent) {
|
||||
return getTagValues("member", membersEvent.tags)
|
||||
return uniq(getTagValues("member", membersEvent.tags))
|
||||
}
|
||||
|
||||
const members = new Set()
|
||||
const members = new Set<string>()
|
||||
|
||||
for (const event of sortBy(e => e.created_at, $events)) {
|
||||
const pubkeys = getPubkeyTagValues(event.tags)
|
||||
@@ -752,43 +683,63 @@ export const deriveSpaceMembers = (url: string) =>
|
||||
},
|
||||
)
|
||||
|
||||
export const deriveRoomMembers = (url: string, h: string) =>
|
||||
derived(
|
||||
deriveEventsForUrl(url, [
|
||||
{kinds: [ROOM_MEMBERS], "#d": [h]},
|
||||
{kinds: [ROOM_ADD_MEMBER, ROOM_REMOVE_MEMBER], "#h": [h]},
|
||||
]),
|
||||
$events => {
|
||||
const membersEvent = $events.find(spec({kind: ROOM_MEMBERS}))
|
||||
export type BannedPubkeyItem = {
|
||||
pubkey: string
|
||||
reason: string
|
||||
}
|
||||
|
||||
if (membersEvent) {
|
||||
return getPubkeyTagValues(membersEvent.tags)
|
||||
}
|
||||
export const spaceBannedPubkeyItems = new Map<string, BannedPubkeyItem[]>()
|
||||
|
||||
const members = new Set()
|
||||
export const deriveSpaceBannedPubkeyItems = (url: string) => {
|
||||
const store = writable(spaceBannedPubkeyItems.get(url) || [])
|
||||
|
||||
for (const event of sortBy(e => -e.created_at, $events)) {
|
||||
const pubkeys = getPubkeyTagValues(event.tags)
|
||||
manageRelay(url, {method: ManagementMethod.ListBannedPubkeys, params: []}).then(res => {
|
||||
spaceBannedPubkeyItems.set(url, res.result)
|
||||
store.set(res.result)
|
||||
})
|
||||
|
||||
if (event.kind === ROOM_ADD_MEMBER) {
|
||||
for (const pubkey of pubkeys) {
|
||||
members.add(pubkey)
|
||||
}
|
||||
}
|
||||
return store
|
||||
}
|
||||
|
||||
if (event.kind === ROOM_REMOVE_MEMBER) {
|
||||
for (const pubkey of pubkeys) {
|
||||
members.delete(pubkey)
|
||||
}
|
||||
export const deriveRoomMembers = (url: string, h: string) => {
|
||||
const filters: Filter[] = [
|
||||
{kinds: [ROOM_MEMBERS], "#d": [h]},
|
||||
{kinds: [ROOM_ADD_MEMBER, ROOM_REMOVE_MEMBER], "#h": [h]},
|
||||
]
|
||||
|
||||
return derived(deriveEventsForUrl(url, filters), $events => {
|
||||
const membersEvent = find(spec({kind: ROOM_MEMBERS}), $events)
|
||||
|
||||
if (membersEvent) {
|
||||
return uniq(getPubkeyTagValues(membersEvent.tags))
|
||||
}
|
||||
|
||||
const members = new Set<string>()
|
||||
|
||||
for (const event of sortBy(e => -e.created_at, $events)) {
|
||||
const pubkeys = getPubkeyTagValues(event.tags)
|
||||
|
||||
if (event.kind === ROOM_ADD_MEMBER) {
|
||||
for (const pubkey of pubkeys) {
|
||||
members.add(pubkey)
|
||||
}
|
||||
}
|
||||
|
||||
return Array.from(members)
|
||||
},
|
||||
)
|
||||
if (event.kind === ROOM_REMOVE_MEMBER) {
|
||||
for (const pubkey of pubkeys) {
|
||||
members.delete(pubkey)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const deriveRoomAdmins = (url: string, h: string) =>
|
||||
derived(deriveEventsForUrl(url, [{kinds: [ROOM_ADMINS], "#d": [h]}]), $events => {
|
||||
return Array.from(members)
|
||||
})
|
||||
}
|
||||
|
||||
export const deriveRoomAdmins = (url: string, h: string) => {
|
||||
const filters: Filter[] = [{kinds: [ROOM_ADMINS], "#d": [h]}]
|
||||
|
||||
return derived(deriveEventsForUrl(url, filters), $events => {
|
||||
const adminsEvent = first($events)
|
||||
|
||||
if (adminsEvent) {
|
||||
@@ -797,6 +748,7 @@ export const deriveRoomAdmins = (url: string, h: string) =>
|
||||
|
||||
return []
|
||||
})
|
||||
}
|
||||
|
||||
// User membership status
|
||||
|
||||
@@ -806,18 +758,33 @@ export enum MembershipStatus {
|
||||
Granted,
|
||||
}
|
||||
|
||||
export const deriveUserSpaceMembershipStatus = (url: string) =>
|
||||
derived(
|
||||
export const deriveUserIsSpaceAdmin = memoize((url?: string) => {
|
||||
const store = writable(false)
|
||||
|
||||
if (url) {
|
||||
manageRelay(url, {method: ManagementMethod.SupportedMethods, params: []}).then(res =>
|
||||
store.set(Boolean(res.result?.length)),
|
||||
)
|
||||
}
|
||||
|
||||
return store
|
||||
})
|
||||
|
||||
export const deriveUserSpaceMembershipStatus = (url: string) => {
|
||||
const filters: Filter[] = [{kinds: [RELAY_JOIN, RELAY_LEAVE]}]
|
||||
|
||||
return derived(
|
||||
[
|
||||
pubkey,
|
||||
deriveSpaceMembers(url),
|
||||
deriveEventsForUrl(url, [{kinds: [RELAY_JOIN, RELAY_LEAVE]}]),
|
||||
deriveEventsForUrl(url, filters),
|
||||
deriveUserIsSpaceAdmin(url),
|
||||
],
|
||||
([$pubkey, $members, $events]) => {
|
||||
const isMember = $members.includes($pubkey)
|
||||
([$pubkey, $members, $events, $isAdmin]) => {
|
||||
const isMember = $members.includes($pubkey!) || $isAdmin
|
||||
|
||||
for (const event of $events) {
|
||||
if (!getPubkeyTagValues(event.tags).includes($pubkey!)) {
|
||||
if (event.pubkey !== $pubkey) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -833,19 +800,29 @@ export const deriveUserSpaceMembershipStatus = (url: string) =>
|
||||
return isMember ? MembershipStatus.Granted : MembershipStatus.Initial
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
export const deriveUserRoomMembershipStatus = (url: string, h: string) =>
|
||||
export const deriveUserIsRoomAdmin = (url: string, h: string) =>
|
||||
derived(
|
||||
[pubkey, deriveRoomAdmins(url, h), deriveUserIsSpaceAdmin(url)],
|
||||
([$pubkey, $admins, $isSpaceAdmin]) => $isSpaceAdmin || $admins.includes($pubkey!),
|
||||
)
|
||||
|
||||
export const deriveUserRoomMembershipStatus = (url: string, h: string) => {
|
||||
const filters: Filter[] = [{kinds: [ROOM_JOIN, ROOM_LEAVE], "#h": [h]}]
|
||||
|
||||
return derived(
|
||||
[
|
||||
pubkey,
|
||||
deriveRoomMembers(url, h),
|
||||
deriveEventsForUrl(url, [{kinds: [ROOM_JOIN, ROOM_LEAVE], "#h": [h]}]),
|
||||
deriveEventsForUrl(url, filters),
|
||||
deriveUserIsRoomAdmin(url, h),
|
||||
],
|
||||
([$pubkey, $members, $events]) => {
|
||||
const isMember = $members.includes($pubkey)
|
||||
([$pubkey, $members, $events, $isAdmin]) => {
|
||||
const isMember = $members.includes($pubkey!) || $isAdmin
|
||||
|
||||
for (const event of $events) {
|
||||
if (!getPubkeyTagValues(event.tags).includes($pubkey!)) {
|
||||
if (event.pubkey !== $pubkey) {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -861,28 +838,23 @@ export const deriveUserRoomMembershipStatus = (url: string, h: string) =>
|
||||
return isMember ? MembershipStatus.Granted : MembershipStatus.Initial
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
export const deriveUserCanCreateRoom = (url: string) =>
|
||||
derived(
|
||||
[pubkey, deriveEventsForUrl(url, [{kinds: [ROOM_CREATE_PERMISSION]}])],
|
||||
([$pubkey, $events]) => {
|
||||
const event = first($events)
|
||||
export const deriveUserCanCreateRoom = (url: string) => {
|
||||
const filters: Filter[] = [{kinds: [ROOM_CREATE_PERMISSION]}]
|
||||
|
||||
return event ? getPubkeyTagValues(event.tags).includes($pubkey!) : true
|
||||
return derived(
|
||||
[pubkey, deriveEventsForUrl(url, filters), deriveUserIsSpaceAdmin(url)],
|
||||
([$pubkey, $events, $isAdmin]) => {
|
||||
for (const event of $events) {
|
||||
if (getPubkeyTagValues(event.tags).includes($pubkey!)) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return $isAdmin
|
||||
},
|
||||
)
|
||||
|
||||
export const deriveUserIsRoomAdmin = (url: string, h: string) =>
|
||||
derived([pubkey, deriveRoomAdmins(url, h)], ([$pubkey, $admins]) => $admins.includes($pubkey!))
|
||||
|
||||
export const deriveUserIsSpaceAdmin = (url: string) => {
|
||||
const store = writable(false)
|
||||
|
||||
manageRelay(url, {method: ManagementMethod.SupportedMethods, params: []}).then(res =>
|
||||
store.set(Boolean(res.result?.length)),
|
||||
)
|
||||
|
||||
return store
|
||||
}
|
||||
|
||||
// Other utils
|
||||
@@ -902,13 +874,10 @@ export const displayReaction = (content: string) => {
|
||||
return content
|
||||
}
|
||||
|
||||
export const deriveSocket = (url: string) =>
|
||||
custom<Socket>(set => {
|
||||
const pool = Pool.get()
|
||||
const socket = pool.get(url)
|
||||
|
||||
set(socket)
|
||||
export const deriveSocket = (url: string) => {
|
||||
const socket = Pool.get().get(url)
|
||||
|
||||
return readable(socket, set => {
|
||||
const subs = [
|
||||
on(socket, SocketEvent.Error, () => set(socket)),
|
||||
on(socket, SocketEvent.Status, () => set(socket)),
|
||||
@@ -917,6 +886,7 @@ export const deriveSocket = (url: string) =>
|
||||
|
||||
return () => subs.forEach(call)
|
||||
})
|
||||
}
|
||||
|
||||
export const deriveSocketStatus = (url: string) =>
|
||||
throttled(
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import {call} from "@welshman/lib"
|
||||
import {Preferences} from "@capacitor/preferences"
|
||||
import {Filesystem, Directory} from "@capacitor/filesystem"
|
||||
import {IDB} from "@lib/indexeddb"
|
||||
|
||||
export const kv = call(() => {
|
||||
let p = Promise.resolve()
|
||||
|
||||
const get = async <T>(key: string): Promise<T | undefined> => {
|
||||
const result = await Preferences.get({key})
|
||||
if (!result.value) return undefined
|
||||
try {
|
||||
return JSON.parse(result.value)
|
||||
} catch (e) {
|
||||
return undefined
|
||||
}
|
||||
}
|
||||
|
||||
const set = async <T>(key: string, value: T): Promise<void> => {
|
||||
p = p.then(() => Preferences.set({key, value: JSON.stringify(value)}))
|
||||
|
||||
await p
|
||||
}
|
||||
|
||||
const clear = async () => {
|
||||
p = p.then(() => Preferences.clear())
|
||||
|
||||
await p
|
||||
}
|
||||
|
||||
return {get, set, clear}
|
||||
})
|
||||
|
||||
export const db = new IDB({name: "flotilla-9gl", version: 1})
|
||||
|
||||
// Migration - we used to use capacitor's filesystem for storage, clear it out since we're
|
||||
// going back to indexeddb
|
||||
call(async () => {
|
||||
const res = await Filesystem.readdir({
|
||||
path: "",
|
||||
directory: Directory.Data,
|
||||
})
|
||||
|
||||
await Promise.all(
|
||||
res.files.map(file =>
|
||||
Filesystem.deleteFile({
|
||||
path: file.name,
|
||||
directory: Directory.Data,
|
||||
}),
|
||||
),
|
||||
)
|
||||
})
|
||||
+68
-163
@@ -6,7 +6,6 @@ import {
|
||||
getListTags,
|
||||
getRelayTagValues,
|
||||
WRAP,
|
||||
MESSAGE,
|
||||
ROOM_META,
|
||||
ROOM_DELETE,
|
||||
ROOM_ADMINS,
|
||||
@@ -25,34 +24,33 @@ import {request, load, pull} from "@welshman/net"
|
||||
import {
|
||||
pubkey,
|
||||
loadRelay,
|
||||
userFollows,
|
||||
userRelaySelections,
|
||||
userInboxRelaySelections,
|
||||
loadRelaySelections,
|
||||
loadInboxRelaySelections,
|
||||
loadBlossomServers,
|
||||
loadFollows,
|
||||
loadMutes,
|
||||
userFollowList,
|
||||
userRelayList,
|
||||
userMessagingRelayList,
|
||||
loadRelayList,
|
||||
loadMessagingRelayList,
|
||||
loadBlossomServerList,
|
||||
loadFollowList,
|
||||
loadMuteList,
|
||||
loadProfile,
|
||||
tracker,
|
||||
repository,
|
||||
shouldUnwrap,
|
||||
hasNegentropy,
|
||||
relaysByUrl,
|
||||
} from "@welshman/app"
|
||||
import {
|
||||
REACTION_KINDS,
|
||||
MESSAGE_KINDS,
|
||||
CONTENT_KINDS,
|
||||
INDEXER_RELAYS,
|
||||
loadSettings,
|
||||
loadGroupSelections,
|
||||
loadGroupList,
|
||||
userSpaceUrls,
|
||||
userGroupSelections,
|
||||
userGroupList,
|
||||
bootstrapPubkeys,
|
||||
decodeRelay,
|
||||
getUrlsForEvent,
|
||||
hasNip29,
|
||||
getSpaceUrlsFromGroupSelections,
|
||||
getSpaceRoomsFromGroupSelections,
|
||||
getSpaceUrlsFromGroupList,
|
||||
getSpaceRoomsFromGroupList,
|
||||
makeCommentFilter,
|
||||
} from "@app/core/state"
|
||||
import {loadAlerts, loadAlertStatuses} from "@app/core/requests"
|
||||
@@ -67,7 +65,6 @@ type PullOpts = {
|
||||
}
|
||||
|
||||
const pullWithFallback = ({relays, filters, signal}: PullOpts) => {
|
||||
const $getUrlsForEvent = get(getUrlsForEvent)
|
||||
const [smart, dumb] = partition(hasNegentropy, relays)
|
||||
const events = repository.query(filters, {shouldSort: false}).filter(isSignedEvent)
|
||||
const promises: Promise<TrustedEvent[]>[] = [pull({relays: smart, filters, signal, events})]
|
||||
@@ -75,7 +72,7 @@ const pullWithFallback = ({relays, filters, signal}: PullOpts) => {
|
||||
// Since pulling from relays without negentropy is expensive, limit how many
|
||||
// duplicates we repeatedly download
|
||||
for (const url of dumb) {
|
||||
const urlEvents = events.filter(e => $getUrlsForEvent(e.id).includes(url))
|
||||
const urlEvents = events.filter(e => tracker.getRelays(e.id).has(url))
|
||||
|
||||
if (urlEvents.length >= 100) {
|
||||
filters = filters.map(assoc("since", sortBy(e => -e.created_at, urlEvents)[10]!.created_at))
|
||||
@@ -140,10 +137,9 @@ const syncUserSpaceMembership = (url: string) => {
|
||||
relays: [url],
|
||||
signal: controller.signal,
|
||||
filters: [
|
||||
{
|
||||
kinds: [RELAY_ADD_MEMBER, RELAY_REMOVE_MEMBER, ROOM_CREATE_PERMISSION],
|
||||
"#p": [$pubkey],
|
||||
},
|
||||
{kinds: [RELAY_ADD_MEMBER], "#p": [$pubkey], limit: 1},
|
||||
{kinds: [RELAY_REMOVE_MEMBER], "#p": [$pubkey], limit: 1},
|
||||
{kinds: [ROOM_CREATE_PERMISSION], "#p": [$pubkey], limit: 1},
|
||||
],
|
||||
})
|
||||
}
|
||||
@@ -160,11 +156,8 @@ const syncUserRoomMembership = (url: string, h: string) => {
|
||||
relays: [url],
|
||||
signal: controller.signal,
|
||||
filters: [
|
||||
{
|
||||
kinds: [ROOM_ADD_MEMBER, ROOM_REMOVE_MEMBER],
|
||||
"#p": [$pubkey],
|
||||
"#h": [h],
|
||||
},
|
||||
{kinds: [ROOM_ADD_MEMBER], "#p": [$pubkey], "#h": [h], limit: 1},
|
||||
{kinds: [ROOM_REMOVE_MEMBER], "#p": [$pubkey], "#h": [h], limit: 1},
|
||||
],
|
||||
})
|
||||
}
|
||||
@@ -175,20 +168,18 @@ const syncUserRoomMembership = (url: string, h: string) => {
|
||||
const syncUserData = () => {
|
||||
const unsubscribersByKey = new Map<string, Unsubscriber>()
|
||||
|
||||
const unsubscribeGroupSelections = userGroupSelections.subscribe($l => {
|
||||
const $pubkey = pubkey.get()
|
||||
|
||||
if ($pubkey) {
|
||||
const unsubscribeGroupList = userGroupList.subscribe($userGroupList => {
|
||||
if ($userGroupList) {
|
||||
const keys = new Set<string>()
|
||||
|
||||
for (const url of getSpaceUrlsFromGroupSelections($l)) {
|
||||
for (const url of getSpaceUrlsFromGroupList($userGroupList)) {
|
||||
if (!unsubscribersByKey.has(url)) {
|
||||
unsubscribersByKey.set(url, syncUserSpaceMembership(url))
|
||||
}
|
||||
|
||||
keys.add(url)
|
||||
|
||||
for (const h of getSpaceRoomsFromGroupSelections(url, $l)) {
|
||||
for (const h of getSpaceRoomsFromGroupList(url, $userGroupList)) {
|
||||
const key = `${url}'${h}`
|
||||
|
||||
if (!unsubscribersByKey.has(key)) {
|
||||
@@ -208,50 +199,41 @@ const syncUserData = () => {
|
||||
}
|
||||
})
|
||||
|
||||
const unsubscribeSelections = userRelaySelections.subscribe($l => {
|
||||
const $pubkey = pubkey.get()
|
||||
|
||||
if ($pubkey) {
|
||||
loadAlerts($pubkey)
|
||||
loadAlertStatuses($pubkey)
|
||||
loadBlossomServers($pubkey)
|
||||
loadFollows($pubkey)
|
||||
loadGroupSelections($pubkey)
|
||||
loadMutes($pubkey)
|
||||
loadProfile($pubkey)
|
||||
loadSettings($pubkey)
|
||||
const unsubscribeRelayList = userRelayList.subscribe($userRelayList => {
|
||||
if ($userRelayList) {
|
||||
loadAlerts($userRelayList.event.pubkey)
|
||||
loadAlertStatuses($userRelayList.event.pubkey)
|
||||
loadBlossomServerList($userRelayList.event.pubkey)
|
||||
loadFollowList($userRelayList.event.pubkey)
|
||||
loadGroupList($userRelayList.event.pubkey)
|
||||
loadMuteList($userRelayList.event.pubkey)
|
||||
loadProfile($userRelayList.event.pubkey)
|
||||
loadSettings($userRelayList.event.pubkey)
|
||||
}
|
||||
})
|
||||
|
||||
const unsubscribeFollows = userFollows.subscribe(async $l => {
|
||||
const unsubscribeFollows = userFollowList.subscribe(async $userFollowList => {
|
||||
for (const pubkeys of chunk(10, get(bootstrapPubkeys))) {
|
||||
// This isn't urgent, avoid clogging other stuff up
|
||||
await sleep(1000)
|
||||
|
||||
await Promise.all(
|
||||
pubkeys.map(async pk => {
|
||||
await loadRelaySelections(pk)
|
||||
await loadGroupSelections(pk)
|
||||
await loadRelayList(pk)
|
||||
await loadGroupList(pk)
|
||||
await loadProfile(pk)
|
||||
await loadFollows(pk)
|
||||
await loadMutes(pk)
|
||||
await loadFollowList(pk)
|
||||
await loadMuteList(pk)
|
||||
}),
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
const unsubscribePubkey = pubkey.subscribe($pubkey => {
|
||||
if ($pubkey) {
|
||||
loadRelaySelections($pubkey)
|
||||
}
|
||||
})
|
||||
|
||||
return () => {
|
||||
unsubscribersByKey.forEach(call)
|
||||
unsubscribeGroupSelections()
|
||||
unsubscribeSelections()
|
||||
unsubscribeGroupList()
|
||||
unsubscribeRelayList()
|
||||
unsubscribeFollows()
|
||||
unsubscribePubkey()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,11 +247,13 @@ const syncSpace = (url: string) => {
|
||||
signal: controller.signal,
|
||||
filters: [
|
||||
{kinds: [RELAY_MEMBERS]},
|
||||
{kinds: [ROOM_META, ROOM_DELETE]},
|
||||
{kinds: [ROOM_ADMINS, ROOM_MEMBERS]},
|
||||
{kinds: [ROOM_META, ROOM_DELETE], limit: 1000},
|
||||
{kinds: [ROOM_ADD_MEMBER, ROOM_REMOVE_MEMBER]},
|
||||
{kinds: [RELAY_ADD_MEMBER, RELAY_REMOVE_MEMBER]},
|
||||
...MESSAGE_KINDS.map(kind => ({kinds: [kind]})),
|
||||
makeCommentFilter(CONTENT_KINDS),
|
||||
{kinds: REACTION_KINDS, limit: 0},
|
||||
],
|
||||
})
|
||||
|
||||
@@ -277,116 +261,37 @@ const syncSpace = (url: string) => {
|
||||
}
|
||||
|
||||
const syncSpaces = () => {
|
||||
const membershipUnsubscribersByUrl = new Map<string, Unsubscriber>()
|
||||
const store = derived([userSpaceUrls, page], identity)
|
||||
const unsubscribersByUrl = new Map<string, Unsubscriber>()
|
||||
const unsubscribe = store.subscribe(([$userSpaceUrls, $page]) => {
|
||||
const urls = Array.from($userSpaceUrls)
|
||||
|
||||
if ($page.params.relay) {
|
||||
urls.push(decodeRelay($page.params.relay))
|
||||
}
|
||||
|
||||
const unsubscribeSpaceUrls = userSpaceUrls.subscribe(urls => {
|
||||
// stop syncing removed spaces
|
||||
for (const [url, unsubscribe] of membershipUnsubscribersByUrl.entries()) {
|
||||
for (const [url, unsubscribe] of unsubscribersByUrl.entries()) {
|
||||
if (!urls.includes(url)) {
|
||||
membershipUnsubscribersByUrl.delete(url)
|
||||
unsubscribersByUrl.delete(url)
|
||||
unsubscribe()
|
||||
}
|
||||
}
|
||||
|
||||
// Start syncing newly added spaces
|
||||
for (const url of urls) {
|
||||
if (!membershipUnsubscribersByUrl.has(url)) {
|
||||
membershipUnsubscribersByUrl.set(url, syncSpace(url))
|
||||
if (!unsubscribersByUrl.has(url)) {
|
||||
unsubscribersByUrl.set(url, syncSpace(url))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
const pageUnsubscribersByUrl = new Map<string, Unsubscriber>()
|
||||
|
||||
// Sync the space the user is currently visiting
|
||||
const unsubscribePage = page.subscribe($page => {
|
||||
if ($page.params.relay) {
|
||||
const url = decodeRelay($page.params.relay)
|
||||
|
||||
// Don't subscribe twice if the user is a member
|
||||
if (!pageUnsubscribersByUrl.has(url) && !get(userSpaceUrls).includes(url)) {
|
||||
pageUnsubscribersByUrl.set(url, syncSpace(url))
|
||||
}
|
||||
|
||||
// Clean up old subscriptions
|
||||
for (const [oldUrl, unsubscribe] of pageUnsubscribersByUrl.entries()) {
|
||||
if (url !== oldUrl) {
|
||||
pageUnsubscribersByUrl.delete(oldUrl)
|
||||
unsubscribe()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Array.from(pageUnsubscribersByUrl.values()).forEach(call)
|
||||
return () => {
|
||||
for (const unsubscriber of unsubscribersByUrl.values()) {
|
||||
unsubscriber()
|
||||
}
|
||||
})
|
||||
|
||||
return () => {
|
||||
Array.from(membershipUnsubscribersByUrl.values()).forEach(call)
|
||||
Array.from(pageUnsubscribersByUrl.values()).forEach(call)
|
||||
unsubscribeSpaceUrls()
|
||||
unsubscribePage()
|
||||
}
|
||||
}
|
||||
|
||||
// Chat
|
||||
|
||||
const syncRoom = (url: string, h: string) => {
|
||||
const controller = new AbortController()
|
||||
|
||||
pullAndListen({
|
||||
relays: [url],
|
||||
signal: controller.signal,
|
||||
filters: [
|
||||
{kinds: [ROOM_ADMINS, ROOM_MEMBERS], "#d": [h]},
|
||||
{kinds: [ROOM_ADD_MEMBER, ROOM_REMOVE_MEMBER], "#h": [h]},
|
||||
{kinds: [MESSAGE], "#h": [h]},
|
||||
],
|
||||
})
|
||||
|
||||
return () => controller.abort()
|
||||
}
|
||||
|
||||
const syncRooms = () => {
|
||||
const unsubscribersByKey = new Map<string, Unsubscriber>()
|
||||
|
||||
const unsubscribeSpaceUrls = derived([userGroupSelections, relaysByUrl], identity).subscribe(
|
||||
([$l, $relaysByUrl]) => {
|
||||
const keys = new Set<string>()
|
||||
const newUnsubscribersByKey = new Map<string, Unsubscriber>()
|
||||
|
||||
// Add new subscriptions, depending on whether nip 29 is supported
|
||||
for (const url of getRelayTagValues(getListTags($l))) {
|
||||
if (hasNip29($relaysByUrl.get(url))) {
|
||||
for (const h of getSpaceRoomsFromGroupSelections(url, $l)) {
|
||||
const key = `${url}'${h}`
|
||||
|
||||
if (!unsubscribersByKey.has(key)) {
|
||||
newUnsubscribersByKey.set(key, syncRoom(url, h))
|
||||
}
|
||||
|
||||
keys.add(key)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Stop syncing removed selections
|
||||
for (const [key, unsubscribe] of unsubscribersByKey.entries()) {
|
||||
if (!keys.has(key)) {
|
||||
unsubscribersByKey.delete(key)
|
||||
unsubscribe()
|
||||
}
|
||||
}
|
||||
|
||||
// Start syncing newly added spaces
|
||||
for (const [key, unsubscriber] of newUnsubscribersByKey.entries()) {
|
||||
unsubscribersByKey.set(key, unsubscriber)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
return () => {
|
||||
Array.from(unsubscribersByKey.values()).forEach(call)
|
||||
unsubscribeSpaceUrls()
|
||||
unsubscribe()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,10 +353,10 @@ const syncDMs = () => {
|
||||
unsubscribeAll()
|
||||
}
|
||||
|
||||
// If we have a pubkey, refresh our user's relay selections then sync our subscriptions
|
||||
// If we have a pubkey, refresh our user's relay list then sync our subscriptions
|
||||
if ($pubkey && $shouldUnwrap) {
|
||||
loadRelaySelections($pubkey)
|
||||
.then(() => loadInboxRelaySelections($pubkey))
|
||||
loadRelayList($pubkey)
|
||||
.then(() => loadMessagingRelayList($pubkey))
|
||||
.then($l => subscribeAll($pubkey, getRelayTagValues(getListTags($l))))
|
||||
}
|
||||
|
||||
@@ -459,27 +364,27 @@ const syncDMs = () => {
|
||||
},
|
||||
)
|
||||
|
||||
// When user inbox relays change, update synchronization
|
||||
const unsubscribeSelections = userInboxRelaySelections.subscribe($userInboxRelaySelections => {
|
||||
// When user messaging relays change, update synchronization
|
||||
const unsubscribeList = userMessagingRelayList.subscribe($userMessagingRelayList => {
|
||||
const $pubkey = pubkey.get()
|
||||
const $shouldUnwrap = shouldUnwrap.get()
|
||||
|
||||
if ($pubkey && $shouldUnwrap) {
|
||||
subscribeAll($pubkey, getRelayTagValues(getListTags($userInboxRelaySelections)))
|
||||
subscribeAll($pubkey, getRelayTagValues(getListTags($userMessagingRelayList)))
|
||||
}
|
||||
})
|
||||
|
||||
return () => {
|
||||
unsubscribeAll()
|
||||
unsubscribePubkey()
|
||||
unsubscribeSelections()
|
||||
unsubscribeList()
|
||||
}
|
||||
}
|
||||
|
||||
// Merge all synchronization functions
|
||||
|
||||
export const syncApplicationData = () => {
|
||||
const unsubscribers = [syncRelays(), syncUserData(), syncSpaces(), syncRooms(), syncDMs()]
|
||||
const unsubscribers = [syncRelays(), syncUserData(), syncSpaces(), syncDMs()]
|
||||
|
||||
return () => unsubscribers.forEach(call)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import type {NodeViewProps} from "@tiptap/core"
|
||||
import {removeNil} from "@welshman/lib"
|
||||
import {removeUndefined} from "@welshman/lib"
|
||||
import {deriveProfileDisplay} from "@welshman/app"
|
||||
|
||||
export const makeMentionNodeView =
|
||||
(url?: string) =>
|
||||
({node}: NodeViewProps) => {
|
||||
const dom = document.createElement("span")
|
||||
const display = deriveProfileDisplay(node.attrs.pubkey, removeNil([url]))
|
||||
const display = deriveProfileDisplay(node.attrs.pubkey, removeUndefined([url]))
|
||||
|
||||
dom.classList.add("tiptap-object")
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<script lang="ts">
|
||||
import {removeNil} from "@welshman/lib"
|
||||
import {removeUndefined} from "@welshman/lib"
|
||||
import {displayPubkey} from "@welshman/util"
|
||||
import {deriveHandleForPubkey, displayHandle, deriveProfileDisplay} from "@welshman/app"
|
||||
import WotScore from "@app/components/WotScore.svelte"
|
||||
@@ -13,7 +13,7 @@
|
||||
const {value, url}: Props = $props()
|
||||
|
||||
const pubkey = value
|
||||
const profileDisplay = deriveProfileDisplay(pubkey, removeNil([url]))
|
||||
const profileDisplay = deriveProfileDisplay(pubkey, removeUndefined([url]))
|
||||
const handle = deriveHandleForPubkey(pubkey)
|
||||
</script>
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ import {
|
||||
profiles,
|
||||
searchProfiles,
|
||||
handlesByNip05,
|
||||
maxWot,
|
||||
wotGraph,
|
||||
getMaxWot,
|
||||
getWotGraph,
|
||||
} from "@welshman/app"
|
||||
import type {FileAttributes} from "@welshman/editor"
|
||||
import {Editor, MentionSuggestion, WelshmanExtension} from "@welshman/editor"
|
||||
import {Editor, MentionSuggestion, WelshmanExtension, editorProps} from "@welshman/editor"
|
||||
import {makeMentionNodeView} from "@app/editor/MentionNodeView"
|
||||
import ProfileSuggestion from "@app/editor/ProfileSuggestion.svelte"
|
||||
import {uploadFile} from "@app/core/commands"
|
||||
@@ -62,10 +62,10 @@ export const makeEditor = async ({
|
||||
onSearch: searchProfiles,
|
||||
getValue: (profile: PublishedProfile) => profile.event.pubkey,
|
||||
sortFn: ({score = 1, item}) => {
|
||||
const wotScore = wotGraph.get().get(item.event.pubkey) || 0
|
||||
const wotScore = getWotGraph().get(item.event.pubkey) || 0
|
||||
const membershipScale = $spaceMembers.includes(item.event.pubkey) ? 2 : 1
|
||||
|
||||
return dec(score) * inc(wotScore / maxWot.get()) * membershipScale
|
||||
return dec(score) * inc(wotScore / getMaxWot()) * membershipScale
|
||||
},
|
||||
fuseOptions: {
|
||||
keys: [
|
||||
@@ -84,6 +84,7 @@ export const makeEditor = async ({
|
||||
return new Editor({
|
||||
content,
|
||||
autofocus,
|
||||
editorProps,
|
||||
element: document.createElement("div"),
|
||||
extensions: [
|
||||
WelshmanExtension.configure({
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import {Capacitor} from "@capacitor/core"
|
||||
import {Keyboard} from "@capacitor/keyboard"
|
||||
import {noop} from "@welshman/lib"
|
||||
|
||||
export const syncKeyboard = () => {
|
||||
if (!Capacitor.isNativePlatform()) return noop
|
||||
|
||||
const showListener = Keyboard.addListener("keyboardWillShow", () => {
|
||||
document.body.classList.add("keyboard-open")
|
||||
})
|
||||
|
||||
const hideListener = Keyboard.addListener("keyboardWillHide", () => {
|
||||
document.body.classList.remove("keyboard-open")
|
||||
})
|
||||
|
||||
return () => {
|
||||
showListener.then(listener => listener.remove())
|
||||
hideListener.then(listener => listener.remove())
|
||||
document.body.classList.remove("keyboard-open")
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,8 @@
|
||||
import {writable} from "svelte/store"
|
||||
import type {Nip46ResponseWithResult} from "@welshman/signer"
|
||||
import {Nip46Broker, makeSecret} from "@welshman/signer"
|
||||
import {
|
||||
NIP46_PERMS,
|
||||
PLATFORM_URL,
|
||||
PLATFORM_NAME,
|
||||
PLATFORM_LOGO,
|
||||
SIGNER_RELAYS,
|
||||
} from "@app/core/state"
|
||||
import {Nip46Broker} from "@welshman/signer"
|
||||
import {makeSecret} from "@welshman/util"
|
||||
import {PLATFORM_URL, PLATFORM_NAME, PLATFORM_LOGO, SIGNER_RELAYS} from "@app/core/state"
|
||||
import {pushToast} from "@app/util/toast"
|
||||
|
||||
export class Nip46Controller {
|
||||
@@ -25,7 +20,6 @@ export class Nip46Controller {
|
||||
|
||||
async start() {
|
||||
const url = await this.broker.makeNostrconnectUrl({
|
||||
perms: NIP46_PERMS,
|
||||
url: PLATFORM_URL,
|
||||
name: PLATFORM_NAME,
|
||||
image: PLATFORM_LOGO,
|
||||
|
||||
+164
-154
@@ -1,8 +1,10 @@
|
||||
import {derived, get} from "svelte/store"
|
||||
import {Badge} from "@capawesome/capacitor-badge"
|
||||
import {synced, throttled} from "@welshman/store"
|
||||
import {pubkey, relaysByUrl} from "@welshman/app"
|
||||
import {prop, spec, identity, now, groupBy} from "@welshman/lib"
|
||||
import {pubkey, tracker, repository, relaysByUrl} from "@welshman/app"
|
||||
import {prop, find, call, spec, first, identity, now, groupBy} from "@welshman/lib"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {deriveEventsByIdByUrl} from "@welshman/store"
|
||||
import {ZAP_GOAL, EVENT_TIME, MESSAGE, THREAD, COMMENT, getTagValue} from "@welshman/util"
|
||||
import {
|
||||
makeSpacePath,
|
||||
@@ -14,24 +16,21 @@ import {
|
||||
makeRoomPath,
|
||||
} from "@app/util/routes"
|
||||
import {
|
||||
chats,
|
||||
chatsById,
|
||||
hasNip29,
|
||||
getUrlsForEvent,
|
||||
repositoryStore,
|
||||
userSettingsValues,
|
||||
userGroupSelections,
|
||||
getSpaceUrlsFromGroupSelections,
|
||||
getSpaceRoomsFromGroupSelections,
|
||||
userGroupList,
|
||||
getSpaceUrlsFromGroupList,
|
||||
getSpaceRoomsFromGroupList,
|
||||
} from "@app/core/state"
|
||||
import {preferencesStorageProvider} from "@src/lib/storage"
|
||||
import {Badge} from "@capawesome/capacitor-badge"
|
||||
import {kv} from "@app/core/storage"
|
||||
|
||||
// Checked state
|
||||
|
||||
export const checked = synced<Record<string, number>>({
|
||||
key: "checked",
|
||||
defaultValue: {},
|
||||
storage: preferencesStorageProvider,
|
||||
storage: kv,
|
||||
})
|
||||
|
||||
export const deriveChecked = (key: string) => derived(checked, prop(key))
|
||||
@@ -40,159 +39,170 @@ export const setChecked = (key: string) => checked.update(state => ({...state, [
|
||||
|
||||
// Derived notifications state
|
||||
|
||||
export const notifications = derived(
|
||||
throttled(
|
||||
1000,
|
||||
derived(
|
||||
[pubkey, checked, chats, userGroupSelections, repositoryStore, getUrlsForEvent, relaysByUrl],
|
||||
identity,
|
||||
export const notifications = call(() => {
|
||||
const goalCommentFilters = [{kinds: [COMMENT], "#K": [String(ZAP_GOAL)]}]
|
||||
const threadCommentFilters = [{kinds: [COMMENT], "#K": [String(THREAD)]}]
|
||||
const calendarCommentFilters = [{kinds: [COMMENT], "#K": [String(EVENT_TIME)]}]
|
||||
const messageFilters = [{kinds: [MESSAGE, THREAD, ZAP_GOAL, EVENT_TIME]}]
|
||||
|
||||
return derived(
|
||||
throttled(
|
||||
1000,
|
||||
derived(
|
||||
[
|
||||
pubkey,
|
||||
checked,
|
||||
chatsById,
|
||||
userGroupList,
|
||||
relaysByUrl,
|
||||
deriveEventsByIdByUrl({tracker, repository, filters: goalCommentFilters}),
|
||||
deriveEventsByIdByUrl({tracker, repository, filters: threadCommentFilters}),
|
||||
deriveEventsByIdByUrl({tracker, repository, filters: calendarCommentFilters}),
|
||||
deriveEventsByIdByUrl({tracker, repository, filters: messageFilters}),
|
||||
],
|
||||
identity,
|
||||
),
|
||||
),
|
||||
),
|
||||
([
|
||||
$pubkey,
|
||||
$checked,
|
||||
$chats,
|
||||
$userGroupSelections,
|
||||
$repository,
|
||||
$getUrlsForEvent,
|
||||
$relaysByUrl,
|
||||
]) => {
|
||||
const hasNotification = (path: string, latestEvent: TrustedEvent | undefined) => {
|
||||
if (!latestEvent || latestEvent.pubkey === $pubkey) {
|
||||
return false
|
||||
}
|
||||
|
||||
for (const [entryPath, ts] of Object.entries($checked)) {
|
||||
const isMatch =
|
||||
entryPath === "*" ||
|
||||
entryPath.startsWith(path) ||
|
||||
(entryPath === "/chat/*" && path.startsWith("/chat/"))
|
||||
|
||||
if (isMatch && ts > latestEvent.created_at) {
|
||||
([
|
||||
$pubkey,
|
||||
$checked,
|
||||
$chatsById,
|
||||
$userGroupList,
|
||||
$relaysByUrl,
|
||||
goalCommentsByUrl,
|
||||
threadCommentsByUrl,
|
||||
calendarCommentsByUrl,
|
||||
messagesByUrl,
|
||||
]) => {
|
||||
const hasNotification = (path: string, latestEvent: TrustedEvent | undefined) => {
|
||||
if (!latestEvent || latestEvent.pubkey === $pubkey) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
for (const [entryPath, ts] of Object.entries($checked)) {
|
||||
const isMatch =
|
||||
entryPath === "*" ||
|
||||
entryPath.startsWith(path) ||
|
||||
(entryPath === "/chat/*" && path.startsWith("/chat/"))
|
||||
|
||||
const paths = new Set<string>()
|
||||
|
||||
for (const {pubkeys, messages} of $chats) {
|
||||
const chatPath = makeChatPath(pubkeys)
|
||||
|
||||
if (hasNotification(chatPath, messages[0])) {
|
||||
paths.add("/chat")
|
||||
paths.add(chatPath)
|
||||
}
|
||||
}
|
||||
|
||||
const allGoalComments = $repository.query([{kinds: [COMMENT], "#K": [String(ZAP_GOAL)]}])
|
||||
|
||||
const allThreadComments = $repository.query([{kinds: [COMMENT], "#K": [String(THREAD)]}])
|
||||
|
||||
const allCalendarComments = $repository.query([{kinds: [COMMENT], "#K": [String(EVENT_TIME)]}])
|
||||
|
||||
const allMessages = $repository.query([{kinds: [MESSAGE, THREAD, ZAP_GOAL, EVENT_TIME]}])
|
||||
|
||||
for (const url of getSpaceUrlsFromGroupSelections($userGroupSelections)) {
|
||||
const spacePath = makeSpacePath(url)
|
||||
const spacePathMobile = spacePath + ":mobile"
|
||||
const goalPath = makeGoalPath(url)
|
||||
const threadPath = makeThreadPath(url)
|
||||
const calendarPath = makeCalendarPath(url)
|
||||
const messagesPath = makeSpaceChatPath(url)
|
||||
const goalComments = allGoalComments.filter(e => $getUrlsForEvent(e.id).includes(url))
|
||||
const threadComments = allThreadComments.filter(e => $getUrlsForEvent(e.id).includes(url))
|
||||
const calendarComments = allCalendarComments.filter(e => $getUrlsForEvent(e.id).includes(url))
|
||||
const messages = allMessages.filter(e => $getUrlsForEvent(e.id).includes(url))
|
||||
|
||||
const commentsByGoalId = groupBy(
|
||||
e => getTagValue("E", e.tags),
|
||||
goalComments.filter(spec({kind: COMMENT})),
|
||||
)
|
||||
|
||||
for (const [goalId, [comment]] of commentsByGoalId.entries()) {
|
||||
const goalItemPath = makeGoalPath(url, goalId)
|
||||
|
||||
if (hasNotification(spacePathMobile, comment)) {
|
||||
paths.add(spacePathMobile)
|
||||
}
|
||||
|
||||
if (hasNotification(goalPath, comment)) {
|
||||
paths.add(goalPath)
|
||||
}
|
||||
|
||||
if (hasNotification(goalItemPath, comment)) {
|
||||
paths.add(goalItemPath)
|
||||
}
|
||||
}
|
||||
|
||||
const commentsByThreadId = groupBy(
|
||||
e => getTagValue("E", e.tags),
|
||||
threadComments.filter(spec({kind: COMMENT})),
|
||||
)
|
||||
|
||||
for (const [threadId, [comment]] of commentsByThreadId.entries()) {
|
||||
const threadItemPath = makeThreadPath(url, threadId)
|
||||
|
||||
if (hasNotification(spacePathMobile, comment)) {
|
||||
paths.add(spacePathMobile)
|
||||
}
|
||||
|
||||
if (hasNotification(threadPath, comment)) {
|
||||
paths.add(threadPath)
|
||||
}
|
||||
|
||||
if (hasNotification(threadItemPath, comment)) {
|
||||
paths.add(threadItemPath)
|
||||
}
|
||||
}
|
||||
|
||||
const commentsByEventId = groupBy(
|
||||
e => getTagValue("E", e.tags),
|
||||
calendarComments.filter(spec({kind: COMMENT})),
|
||||
)
|
||||
|
||||
for (const [eventId, [comment]] of commentsByEventId.entries()) {
|
||||
const calendarItemPath = makeCalendarPath(url, eventId)
|
||||
|
||||
if (hasNotification(spacePathMobile, comment)) {
|
||||
paths.add(spacePathMobile)
|
||||
}
|
||||
|
||||
if (hasNotification(calendarPath, comment)) {
|
||||
paths.add(calendarPath)
|
||||
}
|
||||
|
||||
if (hasNotification(calendarItemPath, comment)) {
|
||||
paths.add(calendarItemPath)
|
||||
}
|
||||
}
|
||||
|
||||
if (hasNip29($relaysByUrl.get(url))) {
|
||||
for (const h of getSpaceRoomsFromGroupSelections(url, $userGroupSelections)) {
|
||||
const roomPath = makeRoomPath(url, h)
|
||||
const latestEvent = messages.find(e => e.tags.some(spec(["h", h])))
|
||||
|
||||
if (hasNotification(roomPath, latestEvent)) {
|
||||
paths.add(spacePathMobile)
|
||||
paths.add(spacePath)
|
||||
paths.add(roomPath)
|
||||
if (isMatch && ts > latestEvent.created_at) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (hasNotification(messagesPath, messages[0])) {
|
||||
paths.add(spacePathMobile)
|
||||
paths.add(spacePath)
|
||||
paths.add(messagesPath)
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
const paths = new Set<string>()
|
||||
|
||||
for (const {pubkeys, messages} of $chatsById.values()) {
|
||||
const chatPath = makeChatPath(pubkeys)
|
||||
|
||||
if (hasNotification(chatPath, messages[0])) {
|
||||
paths.add("/chat")
|
||||
paths.add(chatPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return paths
|
||||
},
|
||||
)
|
||||
for (const url of getSpaceUrlsFromGroupList($userGroupList)) {
|
||||
const spacePath = makeSpacePath(url)
|
||||
const spacePathMobile = spacePath + ":mobile"
|
||||
const goalPath = makeGoalPath(url)
|
||||
const threadPath = makeThreadPath(url)
|
||||
const calendarPath = makeCalendarPath(url)
|
||||
const messagesPath = makeSpaceChatPath(url)
|
||||
const goalComments = goalCommentsByUrl.get(url)?.values() || []
|
||||
const threadComments = threadCommentsByUrl.get(url)?.values() || []
|
||||
const calendarComments = calendarCommentsByUrl.get(url)?.values() || []
|
||||
const messages = messagesByUrl.get(url)?.values() || []
|
||||
|
||||
const commentsByGoalId = groupBy(
|
||||
e => getTagValue("E", e.tags),
|
||||
goalComments.filter(spec({kind: COMMENT})),
|
||||
)
|
||||
|
||||
for (const [goalId, [comment]] of commentsByGoalId.entries()) {
|
||||
const goalItemPath = makeGoalPath(url, goalId)
|
||||
|
||||
if (hasNotification(spacePathMobile, comment)) {
|
||||
paths.add(spacePathMobile)
|
||||
}
|
||||
|
||||
if (hasNotification(goalPath, comment)) {
|
||||
paths.add(goalPath)
|
||||
}
|
||||
|
||||
if (hasNotification(goalItemPath, comment)) {
|
||||
paths.add(goalItemPath)
|
||||
}
|
||||
}
|
||||
|
||||
const commentsByThreadId = groupBy(
|
||||
e => getTagValue("E", e.tags),
|
||||
threadComments.filter(spec({kind: COMMENT})),
|
||||
)
|
||||
|
||||
for (const [threadId, [comment]] of commentsByThreadId.entries()) {
|
||||
const threadItemPath = makeThreadPath(url, threadId)
|
||||
|
||||
if (hasNotification(spacePathMobile, comment)) {
|
||||
paths.add(spacePathMobile)
|
||||
}
|
||||
|
||||
if (hasNotification(threadPath, comment)) {
|
||||
paths.add(threadPath)
|
||||
}
|
||||
|
||||
if (hasNotification(threadItemPath, comment)) {
|
||||
paths.add(threadItemPath)
|
||||
}
|
||||
}
|
||||
|
||||
const commentsByEventId = groupBy(
|
||||
e => getTagValue("E", e.tags),
|
||||
calendarComments.filter(spec({kind: COMMENT})),
|
||||
)
|
||||
|
||||
for (const [eventId, [comment]] of commentsByEventId.entries()) {
|
||||
const calendarItemPath = makeCalendarPath(url, eventId)
|
||||
|
||||
if (hasNotification(spacePathMobile, comment)) {
|
||||
paths.add(spacePathMobile)
|
||||
}
|
||||
|
||||
if (hasNotification(calendarPath, comment)) {
|
||||
paths.add(calendarPath)
|
||||
}
|
||||
|
||||
if (hasNotification(calendarItemPath, comment)) {
|
||||
paths.add(calendarItemPath)
|
||||
}
|
||||
}
|
||||
|
||||
if (hasNip29($relaysByUrl.get(url))) {
|
||||
for (const h of getSpaceRoomsFromGroupList(url, $userGroupList)) {
|
||||
const roomPath = makeRoomPath(url, h)
|
||||
const latestEvent = find(e => e.tags.some(spec(["h", h])), messages)
|
||||
|
||||
if (hasNotification(roomPath, latestEvent)) {
|
||||
paths.add(spacePathMobile)
|
||||
paths.add(spacePath)
|
||||
paths.add(roomPath)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (hasNotification(messagesPath, first(messages))) {
|
||||
paths.add(spacePathMobile)
|
||||
paths.add(spacePath)
|
||||
paths.add(messagesPath)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return paths
|
||||
},
|
||||
)
|
||||
})
|
||||
|
||||
export const badgeCount = derived(notifications, notifications => {
|
||||
return notifications.size
|
||||
|
||||
@@ -58,14 +58,18 @@ export const trustPolicy = (socket: Socket) => {
|
||||
export const mostlyRestrictedPolicy = (socket: Socket) => {
|
||||
let total = 0
|
||||
let restricted = 0
|
||||
let error = ""
|
||||
|
||||
const pending = new Set<string>()
|
||||
|
||||
const updateStatus = () =>
|
||||
relaysMostlyRestricted.update(
|
||||
restricted > total / 2 ? assoc(socket.url, error) : dissoc(socket.url),
|
||||
)
|
||||
const updateStatus = (error?: string) => {
|
||||
if (restricted > total / 2) {
|
||||
if (error) {
|
||||
return relaysMostlyRestricted.update(assoc(socket.url, error))
|
||||
}
|
||||
} else {
|
||||
relaysMostlyRestricted.update(dissoc(socket.url))
|
||||
}
|
||||
}
|
||||
|
||||
const unsubscribers = [
|
||||
on(socket, SocketEvent.Receive, (message: RelayMessage) => {
|
||||
@@ -83,8 +87,7 @@ export const mostlyRestrictedPolicy = (socket: Socket) => {
|
||||
|
||||
if (details.startsWith("restricted: ")) {
|
||||
restricted++
|
||||
error = details
|
||||
updateStatus()
|
||||
updateStatus(details)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,8 +106,7 @@ export const mostlyRestrictedPolicy = (socket: Socket) => {
|
||||
|
||||
if (details.startsWith("restricted: ")) {
|
||||
restricted++
|
||||
error = details
|
||||
updateStatus()
|
||||
updateStatus(details)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ import type {Page} from "@sveltejs/kit"
|
||||
import {get} from "svelte/store"
|
||||
import * as nip19 from "nostr-tools/nip19"
|
||||
import {goto} from "$app/navigation"
|
||||
import {nthEq, sleep} from "@welshman/lib"
|
||||
import {nthEq, remove, sleep} from "@welshman/lib"
|
||||
import type {TrustedEvent} from "@welshman/util"
|
||||
import {tracker, loadRelay} from "@welshman/app"
|
||||
import {pubkey, tracker, loadRelay} from "@welshman/app"
|
||||
import {scrollToEvent} from "@lib/html"
|
||||
import {identity} from "@welshman/lib"
|
||||
import {
|
||||
@@ -55,7 +55,11 @@ export const goToSpace = async (url: string) => {
|
||||
}
|
||||
}
|
||||
|
||||
export const makeChatPath = (pubkeys: string[]) => `/chat/${makeChatId(pubkeys)}`
|
||||
export const makeChatPath = (pubkeys: string[]) => {
|
||||
const id = makeChatId(remove(pubkey.get()!, pubkeys))
|
||||
|
||||
return `/chat/${id}`
|
||||
}
|
||||
|
||||
export const makeRoomPath = (url: string, h: string) => `/spaces/${encodeRelay(url)}/${h}`
|
||||
|
||||
|
||||
+186
-177
@@ -1,5 +1,5 @@
|
||||
import {prop, call, on, throttle, fromPairs, batch} from "@welshman/lib"
|
||||
import {throttled, freshness} from "@welshman/store"
|
||||
import {on, throttle, indexBy, fromPairs, batch} from "@welshman/lib"
|
||||
import {throttled} from "@welshman/store"
|
||||
import {
|
||||
ALERT_ANDROID,
|
||||
ALERT_EMAIL,
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
DIRECT_MESSAGE,
|
||||
EVENT_TIME,
|
||||
FOLLOWS,
|
||||
INBOX_RELAYS,
|
||||
MESSAGING_RELAYS,
|
||||
MESSAGE,
|
||||
MUTES,
|
||||
PROFILE,
|
||||
@@ -38,45 +38,27 @@ import type {Zapper, TrustedEvent, RelayProfile} from "@welshman/util"
|
||||
import type {RepositoryUpdate, WrapItem} from "@welshman/net"
|
||||
import type {Handle, RelayStats} from "@welshman/app"
|
||||
import {
|
||||
plaintext,
|
||||
tracker,
|
||||
relays,
|
||||
relayStats,
|
||||
plaintext,
|
||||
repository,
|
||||
handles,
|
||||
zappers,
|
||||
relaysByUrl,
|
||||
relayStatsByUrl,
|
||||
onRelayStats,
|
||||
handlesByNip05,
|
||||
zappersByLnurl,
|
||||
onZapper,
|
||||
onHandle,
|
||||
wrapManager,
|
||||
onRelay,
|
||||
} from "@welshman/app"
|
||||
import {Collection} from "@lib/storage"
|
||||
import {isMobile} from "@lib/html"
|
||||
import type {IDBTable} from "@lib/indexeddb"
|
||||
|
||||
const syncEvents = async () => {
|
||||
const collection = new Collection<TrustedEvent>({table: "events", getId: prop("id")})
|
||||
|
||||
const initialEvents = await collection.get()
|
||||
|
||||
// Mark events verified to avoid re-verification of signatures
|
||||
for (const event of initialEvents) {
|
||||
event[verifiedSymbol] = true
|
||||
}
|
||||
|
||||
repository.load(initialEvents)
|
||||
|
||||
const metaKinds = [
|
||||
PROFILE,
|
||||
FOLLOWS,
|
||||
MUTES,
|
||||
RELAYS,
|
||||
BLOSSOM_SERVERS,
|
||||
INBOX_RELAYS,
|
||||
APP_DATA,
|
||||
ROOMS,
|
||||
]
|
||||
const alertKinds = [ALERT_STATUS, ALERT_EMAIL, ALERT_WEB, ALERT_IOS, ALERT_ANDROID]
|
||||
const spaceKinds = [RELAY_ADD_MEMBER, RELAY_REMOVE_MEMBER, RELAY_MEMBERS, RELAY_JOIN, RELAY_LEAVE]
|
||||
const roomKinds = [
|
||||
const kinds = {
|
||||
meta: [PROFILE, FOLLOWS, MUTES, RELAYS, BLOSSOM_SERVERS, MESSAGING_RELAYS, APP_DATA, ROOMS],
|
||||
alert: [ALERT_STATUS, ALERT_EMAIL, ALERT_WEB, ALERT_IOS, ALERT_ANDROID],
|
||||
space: [RELAY_ADD_MEMBER, RELAY_REMOVE_MEMBER, RELAY_MEMBERS, RELAY_JOIN, RELAY_LEAVE],
|
||||
room: [
|
||||
ROOM_META,
|
||||
ROOM_DELETE,
|
||||
ROOM_ADMINS,
|
||||
@@ -84,178 +66,205 @@ const syncEvents = async () => {
|
||||
ROOM_ADD_MEMBER,
|
||||
ROOM_REMOVE_MEMBER,
|
||||
ROOM_CREATE_PERMISSION,
|
||||
]
|
||||
const contentKinds = [EVENT_TIME, THREAD, MESSAGE, ZAP_GOAL, DIRECT_MESSAGE, DIRECT_MESSAGE_FILE]
|
||||
],
|
||||
content: [EVENT_TIME, THREAD, MESSAGE, ZAP_GOAL, DIRECT_MESSAGE, DIRECT_MESSAGE_FILE],
|
||||
}
|
||||
|
||||
const rankEvent = (event: TrustedEvent) => {
|
||||
if (metaKinds.includes(event.kind)) return 9
|
||||
if (alertKinds.includes(event.kind)) return 8
|
||||
if (spaceKinds.includes(event.kind)) return 7
|
||||
if (roomKinds.includes(event.kind)) return 6
|
||||
if (!isMobile && contentKinds.includes(event.kind)) return 5
|
||||
return 0
|
||||
}
|
||||
const rankEvent = (event: TrustedEvent) => {
|
||||
if (kinds.meta.includes(event.kind)) return 9
|
||||
if (kinds.alert.includes(event.kind)) return 8
|
||||
if (kinds.space.includes(event.kind)) return 7
|
||||
if (kinds.room.includes(event.kind)) return 6
|
||||
if (!isMobile && kinds.content.includes(event.kind)) return 5
|
||||
return 0
|
||||
}
|
||||
|
||||
return on(
|
||||
repository,
|
||||
"update",
|
||||
batch(3000, async (updates: RepositoryUpdate[]) => {
|
||||
const add: TrustedEvent[] = []
|
||||
const remove = new Set<string>()
|
||||
const eventsAdapter = {
|
||||
name: "events",
|
||||
keyPath: "id",
|
||||
init: async (table: IDBTable<TrustedEvent>) => {
|
||||
const initialEvents = await table.getAll()
|
||||
|
||||
for (const update of updates) {
|
||||
for (const event of update.added) {
|
||||
if (rankEvent(event) > 0) {
|
||||
add.push(event)
|
||||
remove.delete(event.id)
|
||||
// Mark events verified to avoid re-verification of signatures
|
||||
for (const event of initialEvents) {
|
||||
event[verifiedSymbol] = true
|
||||
}
|
||||
|
||||
repository.load(initialEvents)
|
||||
|
||||
return on(
|
||||
repository,
|
||||
"update",
|
||||
batch(3000, async (updates: RepositoryUpdate[]) => {
|
||||
const add: TrustedEvent[] = []
|
||||
const remove = new Set<string>()
|
||||
|
||||
for (const update of updates) {
|
||||
for (const event of update.added) {
|
||||
if (rankEvent(event) > 0) {
|
||||
add.push(event)
|
||||
remove.delete(event.id)
|
||||
}
|
||||
}
|
||||
|
||||
for (const id of update.removed) {
|
||||
remove.add(id)
|
||||
}
|
||||
}
|
||||
|
||||
for (const id of update.removed) {
|
||||
remove.add(id)
|
||||
if (add.length > 0) {
|
||||
await table.bulkPut(add)
|
||||
}
|
||||
|
||||
if (remove.size > 0) {
|
||||
await table.bulkDelete(remove)
|
||||
}
|
||||
}),
|
||||
)
|
||||
},
|
||||
}
|
||||
|
||||
type TrackerItem = {id: string; relays: string[]}
|
||||
|
||||
const trackerAdapter = {
|
||||
name: "tracker",
|
||||
keyPath: "id",
|
||||
init: async (table: IDBTable<TrackerItem>) => {
|
||||
const relaysById = new Map<string, Set<string>>()
|
||||
|
||||
for (const {id, relays} of await table.getAll()) {
|
||||
relaysById.set(id, new Set(relays))
|
||||
}
|
||||
|
||||
tracker.load(relaysById)
|
||||
|
||||
const _onAdd = async (ids: Iterable<string>) => {
|
||||
const items: TrackerItem[] = []
|
||||
|
||||
for (const id of ids) {
|
||||
const event = repository.getEvent(id)
|
||||
|
||||
if (!event || rankEvent(event) === 0) continue
|
||||
|
||||
const relays = Array.from(tracker.getRelays(id))
|
||||
|
||||
if (relays.length === 0) continue
|
||||
|
||||
items.push({id, relays})
|
||||
}
|
||||
|
||||
await collection.update({add, remove})
|
||||
}),
|
||||
)
|
||||
await table.bulkPut(items)
|
||||
}
|
||||
|
||||
const _onRemove = async (ids: Iterable<string>) => {
|
||||
await table.bulkDelete(Array.from(ids))
|
||||
}
|
||||
|
||||
const onAdd = batch(3000, _onAdd)
|
||||
|
||||
const onRemove = batch(3000, _onRemove)
|
||||
|
||||
const onLoad = () => _onAdd(tracker.relaysById.keys())
|
||||
|
||||
const onClear = () => _onRemove(tracker.relaysById.keys())
|
||||
|
||||
tracker.on("add", onAdd)
|
||||
tracker.on("remove", onRemove)
|
||||
tracker.on("load", onLoad)
|
||||
tracker.on("clear", onClear)
|
||||
|
||||
return () => {
|
||||
tracker.off("add", onAdd)
|
||||
tracker.off("remove", onRemove)
|
||||
tracker.off("load", onLoad)
|
||||
tracker.off("clear", onClear)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
type TrackerItem = [string, string[]]
|
||||
const relaysAdapter = {
|
||||
name: "relays",
|
||||
keyPath: "url",
|
||||
init: async (table: IDBTable<RelayProfile>) => {
|
||||
relaysByUrl.set(indexBy(r => r.url, await table.getAll()))
|
||||
|
||||
const syncTracker = async () => {
|
||||
const collection = new Collection<TrackerItem>({
|
||||
table: "tracker",
|
||||
getId: (item: TrackerItem) => item[0],
|
||||
})
|
||||
|
||||
const relaysById = new Map<string, Set<string>>()
|
||||
|
||||
for (const [id, relays] of await collection.get()) {
|
||||
relaysById.set(id, new Set(relays))
|
||||
}
|
||||
|
||||
tracker.load(relaysById)
|
||||
|
||||
const updateOne = batch(3000, (ids: string[]) => {
|
||||
collection.add(ids.map(id => [id, Array.from(tracker.getRelays(id))]))
|
||||
})
|
||||
|
||||
const updateAll = throttle(3000, () => {
|
||||
collection.set(
|
||||
Array.from(tracker.relaysById.entries()).map(([id, relays]) => [id, Array.from(relays)]),
|
||||
)
|
||||
})
|
||||
|
||||
tracker.on("add", updateOne)
|
||||
tracker.on("remove", updateOne)
|
||||
tracker.on("load", updateAll)
|
||||
tracker.on("clear", updateAll)
|
||||
|
||||
return () => {
|
||||
tracker.off("add", updateOne)
|
||||
tracker.off("remove", updateOne)
|
||||
tracker.off("load", updateAll)
|
||||
tracker.off("clear", updateAll)
|
||||
}
|
||||
return onRelay(batch(1000, table.bulkPut))
|
||||
},
|
||||
}
|
||||
|
||||
const syncRelays = async () => {
|
||||
const collection = new Collection<RelayProfile>({table: "relays", getId: prop("url")})
|
||||
const relayStatsAdapter = {
|
||||
name: "relayStats",
|
||||
keyPath: "url",
|
||||
init: async (table: IDBTable<RelayStats>) => {
|
||||
relayStatsByUrl.set(indexBy(r => r.url, await table.getAll()))
|
||||
|
||||
relays.set(await collection.get())
|
||||
|
||||
return throttled(3000, relays).subscribe(collection.set)
|
||||
return onRelayStats(batch(1000, table.bulkPut))
|
||||
},
|
||||
}
|
||||
|
||||
const syncRelayStats = async () => {
|
||||
const collection = new Collection<RelayStats>({table: "relayStats", getId: prop("url")})
|
||||
const handlesAdapter = {
|
||||
name: "handles",
|
||||
keyPath: "nip05",
|
||||
init: async (table: IDBTable<Handle>) => {
|
||||
handlesByNip05.set(indexBy(r => r.nip05, await table.getAll()))
|
||||
|
||||
relayStats.set(await collection.get())
|
||||
|
||||
return throttled(3000, relayStats).subscribe(collection.set)
|
||||
return onHandle(batch(1000, table.bulkPut))
|
||||
},
|
||||
}
|
||||
|
||||
const syncHandles = async () => {
|
||||
const collection = new Collection<Handle>({table: "handles", getId: prop("nip05")})
|
||||
const zappersAdapter = {
|
||||
name: "zappers",
|
||||
keyPath: "lnurl",
|
||||
init: async (table: IDBTable<Zapper>) => {
|
||||
zappersByLnurl.set(indexBy(z => z.lnurl, await table.getAll()))
|
||||
|
||||
handles.set(await collection.get())
|
||||
|
||||
return onHandle(batch(3000, collection.add))
|
||||
return onZapper(batch(3000, table.bulkPut))
|
||||
},
|
||||
}
|
||||
|
||||
const syncZappers = async () => {
|
||||
const collection = new Collection<Zapper>({table: "zappers", getId: prop("lnurl")})
|
||||
type PlaintextItem = {key: string; value: string}
|
||||
|
||||
zappers.set(await collection.get())
|
||||
const plaintextAdapter = {
|
||||
name: "plaintext",
|
||||
keyPath: "key",
|
||||
init: async (table: IDBTable<PlaintextItem>) => {
|
||||
const initialRecords = await table.getAll()
|
||||
|
||||
return onZapper(batch(3000, collection.add))
|
||||
plaintext.set(fromPairs(initialRecords.map(({key, value}) => [key, value])))
|
||||
|
||||
return throttled(3000, plaintext).subscribe($plaintext => {
|
||||
table.bulkPut(Object.entries($plaintext).map(([key, value]) => ({key, value})))
|
||||
})
|
||||
},
|
||||
}
|
||||
|
||||
type FreshnessItem = [string, number]
|
||||
const wrapManagerAdapter = {
|
||||
name: "wrapManager",
|
||||
keyPath: "id",
|
||||
init: async (table: IDBTable<WrapItem>) => {
|
||||
wrapManager.load(await table.getAll())
|
||||
|
||||
const syncFreshness = async () => {
|
||||
const collection = new Collection<FreshnessItem>({
|
||||
table: "freshness",
|
||||
getId: (item: FreshnessItem) => item[0],
|
||||
})
|
||||
const addOne = batch(3000, table.bulkPut)
|
||||
|
||||
freshness.set(fromPairs(await collection.get()))
|
||||
const removeOne = throttle(3000, table.bulkDelete)
|
||||
|
||||
return throttled(3000, freshness).subscribe($freshness => {
|
||||
collection.set(Object.entries($freshness))
|
||||
})
|
||||
wrapManager.on("add", addOne)
|
||||
wrapManager.on("remove", removeOne)
|
||||
|
||||
return () => {
|
||||
wrapManager.off("add", addOne)
|
||||
wrapManager.off("remove", removeOne)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
type PlaintextItem = [string, string]
|
||||
|
||||
const syncPlaintext = async () => {
|
||||
const collection = new Collection<PlaintextItem>({
|
||||
table: "plaintext",
|
||||
getId: (item: PlaintextItem) => item[0],
|
||||
})
|
||||
|
||||
plaintext.set(fromPairs(await collection.get()))
|
||||
|
||||
return throttled(3000, plaintext).subscribe($plaintext => {
|
||||
collection.set(Object.entries($plaintext))
|
||||
})
|
||||
}
|
||||
|
||||
const syncWrapManager = async () => {
|
||||
const collection = new Collection<WrapItem>({table: "wraps", getId: prop("id")})
|
||||
|
||||
wrapManager.load(await collection.get())
|
||||
|
||||
const addOne = batch(3000, (wrapItems: WrapItem[]) => collection.add(wrapItems))
|
||||
|
||||
const updateAll = throttle(3000, () => collection.set(wrapManager.dump()))
|
||||
|
||||
wrapManager.on("add", addOne)
|
||||
wrapManager.on("remove", updateAll)
|
||||
|
||||
return () => {
|
||||
wrapManager.off("add", addOne)
|
||||
wrapManager.off("remove", updateAll)
|
||||
}
|
||||
}
|
||||
|
||||
export const syncDataStores = async () => {
|
||||
const promises = [
|
||||
syncEvents(),
|
||||
syncTracker(),
|
||||
syncRelays(),
|
||||
syncHandles(),
|
||||
syncZappers(),
|
||||
syncPlaintext(),
|
||||
syncWrapManager(),
|
||||
]
|
||||
|
||||
if (!isMobile) {
|
||||
promises.push(syncFreshness(), syncRelayStats())
|
||||
}
|
||||
|
||||
const unsubscribers = await Promise.all(promises)
|
||||
|
||||
return () => unsubscribers.forEach(call)
|
||||
}
|
||||
export const adapters = [
|
||||
eventsAdapter,
|
||||
trackerAdapter,
|
||||
relaysAdapter,
|
||||
relayStatsAdapter,
|
||||
handlesAdapter,
|
||||
zappersAdapter,
|
||||
plaintextAdapter,
|
||||
wrapManagerAdapter,
|
||||
]
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import {preferencesStorageProvider} from "@src/lib/storage"
|
||||
import {kv} from "@app/core/storage"
|
||||
import {synced} from "@welshman/store"
|
||||
|
||||
export const theme = synced({
|
||||
key: "theme",
|
||||
defaultValue: window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light",
|
||||
storage: preferencesStorageProvider,
|
||||
storage: kv,
|
||||
})
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,30 +0,0 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import UserRounded from "@assets/icons/user-rounded.svg?dataurl"
|
||||
|
||||
const {src = "", size = 7, icon = UserRounded, style = "", ...restProps} = $props()
|
||||
|
||||
let element: HTMLElement
|
||||
|
||||
const rem = $derived(size * 4)
|
||||
|
||||
onMount(() => {
|
||||
if (src) {
|
||||
const image = new Image()
|
||||
|
||||
image.addEventListener("error", () => {
|
||||
element?.querySelector(".hidden")?.classList.remove("hidden")
|
||||
})
|
||||
|
||||
image.src = src
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<div
|
||||
bind:this={element}
|
||||
class="{restProps.class} relative !flex shrink-0 items-center justify-center overflow-hidden rounded-full bg-cover bg-center"
|
||||
style="width: {rem}px; height: {rem}px; min-width: {rem}px; background-image: url({src}); {style}">
|
||||
<Icon {icon} class={src ? "hidden" : ""} size={Math.round(size * 0.8)} />
|
||||
</div>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user