diff --git a/package-lock.json b/package-lock.json index 24b9497..284c812 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23,12 +23,12 @@ "@tiptap/extension-text": "^2.6.6", "@tiptap/suggestion": "^2.6.4", "@types/throttle-debounce": "^5.0.2", - "@welshman/app": "^0.0.5", + "@welshman/app": "^0.0.7", "@welshman/lib": "^0.0.17", "@welshman/net": "^0.0.22", "@welshman/signer": "^0.0.5", - "@welshman/store": "^0.0.6", - "@welshman/util": "^0.0.31", + "@welshman/store": "^0.0.7", + "@welshman/util": "^0.0.33", "daisyui": "^4.12.10", "date-picker-svelte": "^2.13.0", "fuse.js": "^7.0.0", @@ -1655,14 +1655,14 @@ } }, "node_modules/@welshman/app": { - "version": "0.0.5", - "resolved": "https://registry.npmjs.org/@welshman/app/-/app-0.0.5.tgz", - "integrity": "sha512-T7iXybwBnFN9E1GWeGQ6ZxvFrQ3EUUWHsZdG3Q+s57YxBDqDkRy+eOtxaDb2EBmgyflheERaggOlzFFTsmUjyA==", + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@welshman/app/-/app-0.0.7.tgz", + "integrity": "sha512-37dTcUDe+6wLhCFClexuJZKCZyGHgGoiFBvm8EL6ig4UHRMRWH2NCeddftScq0gEIl2GVWuq96iCni9COc7nRw==", "dependencies": { "@welshman/lib": "0.0.17", "@welshman/net": "0.0.22", "@welshman/signer": "0.0.5", - "@welshman/store": "0.0.6", + "@welshman/store": "0.0.7", "@welshman/util": "0.0.31", "fuse.js": "^7.0.0", "idb": "^8.0.0", @@ -1670,6 +1670,15 @@ "throttle-debounce": "^5.0.2" } }, + "node_modules/@welshman/app/node_modules/@welshman/util": { + "version": "0.0.31", + "resolved": "https://registry.npmjs.org/@welshman/util/-/util-0.0.31.tgz", + "integrity": "sha512-nUv/Mto6maQx6vbCaZ0HKQRvLYRWqQzPTLsKoxSDX0HkeFP653T6raFx8TvWt+op/qBuuT8sANJactc2/qGoYg==", + "dependencies": { + "@welshman/lib": "0.0.17", + "nostr-tools": "^2.7.2" + } + }, "node_modules/@welshman/lib": { "version": "0.0.17", "resolved": "https://registry.npmjs.org/@welshman/lib/-/lib-0.0.17.tgz", @@ -1693,6 +1702,15 @@ "ws": "^8.16.0" } }, + "node_modules/@welshman/net/node_modules/@welshman/util": { + "version": "0.0.31", + "resolved": "https://registry.npmjs.org/@welshman/util/-/util-0.0.31.tgz", + "integrity": "sha512-nUv/Mto6maQx6vbCaZ0HKQRvLYRWqQzPTLsKoxSDX0HkeFP653T6raFx8TvWt+op/qBuuT8sANJactc2/qGoYg==", + "dependencies": { + "@welshman/lib": "0.0.17", + "nostr-tools": "^2.7.2" + } + }, "node_modules/@welshman/signer": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/@welshman/signer/-/signer-0.0.5.tgz", @@ -1725,16 +1743,16 @@ } }, "node_modules/@welshman/store": { - "version": "0.0.6", - "resolved": "https://registry.npmjs.org/@welshman/store/-/store-0.0.6.tgz", - "integrity": "sha512-yZDnXcIZ2fcqvK+1W9OTRXJy3IPKE3ykFp5VnUT5bGMSRSTIyHnPO5swsgDLofe5Zswdee0lJTwE5IQBthf0pQ==", + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/@welshman/store/-/store-0.0.7.tgz", + "integrity": "sha512-Ltx2RYwMicCeGWBdl3+Wr+pilIdofmNSDKTqgOqtPanOgSarGn7uqZnPzDz9N+P0htg2TDSogg7YkBWf5drhDw==", "dependencies": { "@welshman/lib": "0.0.17", "@welshman/util": "0.0.31", "svelte": "^4.2.18" } }, - "node_modules/@welshman/util": { + "node_modules/@welshman/store/node_modules/@welshman/util": { "version": "0.0.31", "resolved": "https://registry.npmjs.org/@welshman/util/-/util-0.0.31.tgz", "integrity": "sha512-nUv/Mto6maQx6vbCaZ0HKQRvLYRWqQzPTLsKoxSDX0HkeFP653T6raFx8TvWt+op/qBuuT8sANJactc2/qGoYg==", @@ -1743,6 +1761,15 @@ "nostr-tools": "^2.7.2" } }, + "node_modules/@welshman/util": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/@welshman/util/-/util-0.0.33.tgz", + "integrity": "sha512-dUt6H6Bi3cwhLup7G6MsfZymwX4C/EGvm6X/9KvaoTGZhy9z66lpoa1MebLGOTaQDyMs8nrIckXMp9eAi/c15Q==", + "dependencies": { + "@welshman/lib": "0.0.17", + "nostr-tools": "^2.7.2" + } + }, "node_modules/acorn": { "version": "8.12.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", diff --git a/package.json b/package.json index c19056b..319b35a 100644 --- a/package.json +++ b/package.json @@ -48,12 +48,12 @@ "@tiptap/extension-text": "^2.6.6", "@tiptap/suggestion": "^2.6.4", "@types/throttle-debounce": "^5.0.2", - "@welshman/app": "^0.0.5", "@welshman/lib": "^0.0.17", + "@welshman/util": "^0.0.33", + "@welshman/store": "^0.0.7", "@welshman/net": "^0.0.22", "@welshman/signer": "^0.0.5", - "@welshman/store": "^0.0.6", - "@welshman/util": "^0.0.31", + "@welshman/app": "^0.0.7", "daisyui": "^4.12.10", "date-picker-svelte": "^2.13.0", "fuse.js": "^7.0.0", diff --git a/src/app.css b/src/app.css index 85454d5..7bec838 100644 --- a/src/app.css +++ b/src/app.css @@ -43,7 +43,7 @@ } .card2 { - @apply rounded-box bg-base-100 p-6 text-base-content; + @apply rounded-box bg-base-100 p-6 text-base-content overflow-hidden text-ellipsis; } .card2.card2-sm { @@ -90,6 +90,10 @@ @apply shadow-[0_20px_25px_-5px_rgb(0,0,0,0.1)_0_8px_10px_-6px_rgb(0,0,0,0.1)]; } +.modal-box .z-feature { + @apply z-modal-feature; +} + /* tiptap */ .input-editor, .chat-editor { diff --git a/src/app/components/EventCard.svelte b/src/app/components/EventCard.svelte new file mode 100644 index 0000000..2daba51 --- /dev/null +++ b/src/app/components/EventCard.svelte @@ -0,0 +1,32 @@ + + +
+ {meta.title || meta.name} +
+ + {timeFmt.format(startDate)} — {isSingleDay ? timeFmt.format(endDate) : formatTimestamp(end)} +
+
diff --git a/src/app/components/EventCreate.svelte b/src/app/components/EventCreate.svelte index f9b1424..f1ca033 100644 --- a/src/app/components/EventCreate.svelte +++ b/src/app/components/EventCreate.svelte @@ -4,21 +4,22 @@ import {writable} from "svelte/store" import {createEditor, type Editor, EditorContent} from "svelte-tiptap" import {NProfileExtension, ImageExtension} from "nostr-editor" + import {randomId} from "@welshman/lib" import {createEvent, EVENT_DATE, EVENT_TIME} from "@welshman/util" - import {publishThunk, makeThunk} from "@welshman/app" + import {publishThunk, makeThunk, dateToSeconds} from "@welshman/app" import {findNodes} from "@lib/tiptap" import Icon from "@lib/components/Icon.svelte" import Field from "@lib/components/Field.svelte" import Button from "@lib/components/Button.svelte" import DateTimeInput from "@lib/components/DateTimeInput.svelte" import {makeMention, makeIMeta} from "@app/commands" - import {getNoteEditorOptions, addFile} from "@app/editor" - import {pushModal} from "@app/modal" + import {getNoteEditorOptions, addFile, uploadFiles} from "@app/editor" + import {pushModal, clearModal} from "@app/modal" import {pushToast} from "@app/toast" export let url - const next = () => null + const submit = () => uploadFiles($editor) const back = () => history.back() @@ -50,12 +51,20 @@ const event = createEvent(kind, { content: $editor.getText(), - tags: [["-"], ...mentionTags, ...imetaTags], + tags: [ + ["-"], + ["d", randomId()], + ["title", title], + ["location", location], + ["start", dateToSeconds(start).toString()], + ["end", dateToSeconds(end).toString()], + ...mentionTags, + ...imetaTags, + ], }) publishThunk(makeThunk({event, relays: [url]})) - - $editor.chain().clearContent().run() + clearModal() } let editor: Readable @@ -71,7 +80,7 @@ }) -
+

Create an Event

Invite other group members to events online or in real life.

@@ -118,7 +127,7 @@

Location (optional)

@@ -127,8 +136,7 @@ Go back
diff --git a/src/assets/icons/Clock Circle.svg b/src/assets/icons/Clock Circle.svg new file mode 100644 index 0000000..750a87c --- /dev/null +++ b/src/assets/icons/Clock Circle.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/lib/components/DateTimeInput.svelte b/src/lib/components/DateTimeInput.svelte index cae240a..d0884be 100644 --- a/src/lib/components/DateTimeInput.svelte +++ b/src/lib/components/DateTimeInput.svelte @@ -20,17 +20,21 @@ } -
- + diff --git a/src/lib/components/Divider.svelte b/src/lib/components/Divider.svelte new file mode 100644 index 0000000..f6a5a63 --- /dev/null +++ b/src/lib/components/Divider.svelte @@ -0,0 +1,5 @@ +
+
+

+
+
diff --git a/src/lib/components/Icon.svelte b/src/lib/components/Icon.svelte index 8792fe7..8e9d297 100644 --- a/src/lib/components/Icon.svelte +++ b/src/lib/components/Icon.svelte @@ -26,6 +26,7 @@ import ChatRound from "@assets/icons/Chat Round.svg?dataurl" import CheckCircle from "@assets/icons/Check Circle.svg?dataurl" import ClipboardText from "@assets/icons/Clipboard Text.svg?dataurl" + import ClockCircle from "@assets/icons/Clock Circle.svg?dataurl" import CloseCircle from "@assets/icons/Close Circle.svg?dataurl" import Copy from "@assets/icons/Copy.svg?dataurl" import Compass from "@assets/icons/Compass.svg?dataurl" @@ -90,6 +91,7 @@ "chat-round": ChatRound, "check-circle": CheckCircle, "clipboard-text": ClipboardText, + "clock-circle": ClockCircle, "close-circle": CloseCircle, copy: Copy, compass: Compass, diff --git a/src/lib/tiptap/Suggestions.ts b/src/lib/tiptap/Suggestions.ts index b547387..b39835e 100644 --- a/src/lib/tiptap/Suggestions.ts +++ b/src/lib/tiptap/Suggestions.ts @@ -68,7 +68,7 @@ export const createSuggestions = (options: SuggestionsOptions) => popover = tippy("body", { getReferenceClientRect: props.clientRect as any, - appendTo: document.body, + appendTo: document.querySelector('dialog[open]') || document.body, content: target, showOnCreate: true, interactive: true, diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 34df8b0..7ac1501 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -6,6 +6,7 @@ import {goto} from "$app/navigation" import {browser} from "$app/environment" import {sleep} from "@welshman/lib" + import {throttled} from "@welshman/store" import { relays, handles, @@ -22,7 +23,6 @@ tracker, } from "@welshman/app" import * as app from "@welshman/app" - import {createEventStore} from "@welshman/store" import ModalBox from "@lib/components/ModalBox.svelte" import Toast from "@app/components/Toast.svelte" import Landing from "@app/components/Landing.svelte" @@ -64,22 +64,13 @@ ready = db ? Promise.resolve() - : initStorage("flotilla", 3, { - events: { - keyPath: "id", - store: createEventStore(repository), - }, - relays: { - keyPath: "url", - store: relays, - }, - handles: { - keyPath: "nip05", - store: handles, - }, + : initStorage("flotilla", 4, { + events: storageAdapters.fromRepository(repository, {throttle: 300}), + relays: {keyPath: "url", store: throttled(1000, relays)}, + handles: {keyPath: "nip05", store: throttled(1000, handles)}, publishStatus: storageAdapters.fromObjectStore(publishStatusData), - freshness: storageAdapters.fromObjectStore(freshness), - plaintext: storageAdapters.fromObjectStore(plaintext), + freshness: storageAdapters.fromObjectStore(freshness, {throttle: 1000}), + plaintext: storageAdapters.fromObjectStore(plaintext, {throttle: 1000}), tracker: storageAdapters.fromTracker(tracker), }).then(() => sleep(300)) // Wait an extra few ms because of repository throttle diff --git a/src/routes/spaces/[nrelay]/[[topic]]/+page.svelte b/src/routes/spaces/[nrelay]/[[topic]]/+page.svelte index e19afcd..63dc849 100644 --- a/src/routes/spaces/[nrelay]/[[topic]]/+page.svelte +++ b/src/routes/spaces/[nrelay]/[[topic]]/+page.svelte @@ -15,6 +15,7 @@ import Icon from "@lib/components/Icon.svelte" import Button from "@lib/components/Button.svelte" import Spinner from "@lib/components/Spinner.svelte" + import Divider from "@lib/components/Divider.svelte" import ChatMessage from "@app/components/ChatMessage.svelte" import ChatCompose from "@app/components/ChatCompose.svelte" import {userMembership, decodeNRelay, makeChatId, deriveChat} from "@app/state" @@ -90,11 +91,7 @@
{#each elements as { type, id, value, showPubkey } (id)} {#if type === "date"} -
-
-

{value}

-
-
+ {value} {:else} {/if} diff --git a/src/routes/spaces/[nrelay]/calendar/+page.svelte b/src/routes/spaces/[nrelay]/calendar/+page.svelte index df3a200..3547eb4 100644 --- a/src/routes/spaces/[nrelay]/calendar/+page.svelte +++ b/src/routes/spaces/[nrelay]/calendar/+page.svelte @@ -1,29 +1,39 @@