diff --git a/README.md b/README.md index 20ab4df..37a35e6 100644 --- a/README.md +++ b/README.md @@ -2,5 +2,4 @@ A discord-like nostr client. WIP. - Figure out state management. Add fetched_at to all events. `fetch` batches and loads, `get` gets the value, `derive` returns a store. For optimization, create getters for everything that uses `get` a lot. diff --git a/src/app.css b/src/app.css index 386b8cf..7459402 100644 --- a/src/app.css +++ b/src/app.css @@ -53,27 +53,27 @@ } .center { - @apply flex justify-center items-center; + @apply flex items-center justify-center; } .content { - @apply max-w-3xl w-full p-12 m-auto; + @apply m-auto w-full max-w-3xl p-12; } .heading { - @apply text-2xl text-center; + @apply text-center text-2xl; } .subheading { - @apply text-xl text-center; + @apply text-center text-xl; } .superheading { - @apply text-4xl text-center; + @apply text-center text-4xl; } .link { - @apply text-primary underline cursor-pointer; + @apply cursor-pointer text-primary underline; } .input input::placeholder { diff --git a/src/app/base.ts b/src/app/base.ts index 2275eb1..c033ea4 100644 --- a/src/app/base.ts +++ b/src/app/base.ts @@ -1,15 +1,15 @@ import {derived, writable} from "svelte/store" -import {memoize, assoc} from '@welshman/lib' -import type {CustomEvent} from '@welshman/util' +import {memoize, assoc} from "@welshman/lib" +import type {CustomEvent} from "@welshman/util" import {Repository, createEvent, Relay} from "@welshman/util" import {withGetter} from "@welshman/store" import {NetworkContext, Tracker} from "@welshman/net" import type {ISigner} from "@welshman/signer" -import {Nip46Broker, Nip46Signer, Nip07Signer, Nip01Signer} from '@welshman/signer' -import {synced} from '@lib/util' +import {Nip46Broker, Nip46Signer, Nip07Signer, Nip01Signer} from "@welshman/signer" +import {synced} from "@lib/util" import type {Session} from "@app/types" -export const INDEXER_RELAYS = ["wss://purplepag.es", "wss://relay.damus.io", 'wss://nos.lol'] +export const INDEXER_RELAYS = ["wss://purplepag.es", "wss://relay.damus.io", "wss://nos.lol"] export const DUFFLEPUD_URL = "https://dufflepud.onrender.com" @@ -19,11 +19,13 @@ export const relay = new Relay(repository) export const tracker = new Tracker() -export const pk = withGetter(synced('pk', null)) +export const pk = withGetter(synced("pk", null)) -export const sessions = withGetter(synced>('sessions', {})) +export const sessions = withGetter(synced>("sessions", {})) -export const session = withGetter(derived([pk, sessions], ([$pk, $sessions]) => $pk ? $sessions[$pk] : null)) +export const session = withGetter( + derived([pk, sessions], ([$pk, $sessions]) => ($pk ? $sessions[$pk] : null)), +) export const getSession = (pubkey: string) => sessions.get()[pubkey] @@ -73,4 +75,3 @@ Object.assign(NetworkContext, { return event }, }) - diff --git a/src/app/commands.ts b/src/app/commands.ts index 7af8665..5cc5f08 100644 --- a/src/app/commands.ts +++ b/src/app/commands.ts @@ -1,9 +1,17 @@ -import {goto} from '$app/navigation' -import {append, uniqBy, now} from '@welshman/lib' +import {goto} from "$app/navigation" +import {append, uniqBy, now} from "@welshman/lib" import {GROUPS, asDecryptedEvent, readList, editList, makeList, createList} from "@welshman/util" -import {pushToast} from '@app/toast' -import {pk, signer, repository, INDEXER_RELAYS} from '@app/base' -import {splitGroupId, loadRelay, loadGroup, getWriteRelayUrls, loadRelaySelections, publish, ensurePlaintext} from '@app/state' +import {pushToast} from "@app/toast" +import {pk, signer, repository, INDEXER_RELAYS} from "@app/base" +import { + splitGroupId, + loadRelay, + loadGroup, + getWriteRelayUrls, + loadRelaySelections, + publish, + ensurePlaintext, +} from "@app/state" export type ModifyTags = (tags: string[][]) => string[][] @@ -37,5 +45,8 @@ export const updateList = async (kind: number, modifyTags: ModifyTags) => { await publish({event, relays}) } -export const updateGroupMemberships = (newTags: string[][]) => - updateList(GROUPS, (tags: string[][]) => uniqBy(t => t.join(''), [...tags, ...newTags])) +export const addGroupMemberships = (newTags: string[][]) => + updateList(GROUPS, (tags: string[][]) => uniqBy(t => t.join(""), [...tags, ...newTags])) + +export const removeGroupMemberships = (noms: string[]) => + updateList(GROUPS, (tags: string[][]) => tags.filter(t => !noms.includes(t[1]))) diff --git a/src/app/components/GroupNote.svelte b/src/app/components/GroupNote.svelte index 37b5430..1ea88ab 100644 --- a/src/app/components/GroupNote.svelte +++ b/src/app/components/GroupNote.svelte @@ -1,35 +1,37 @@ -
+
{#if event.kind === GROUP_REPLY} -
-
- - -

{displayProfile($parentProfile, displayPubkey($parentEvent.pubkey))}

-

{$parentEvent.content}

-
+
+ + +

{displayProfile($parentProfile, displayPubkey(parentPubkey))}

+

+

+ + {$parentEvent?.content || "View note"} +

{/if}
@@ -40,9 +42,22 @@ {/if}
{#if showPubkey} - {displayProfile($profile, displayPubkey(event.pubkey))} + {displayProfile($profile, displayPubkey(event.pubkey))} {/if}

{event.content}

+
+ + + +
diff --git a/src/app/components/InfoNip29.svelte b/src/app/components/InfoNip29.svelte index a9dc37c..65de2d5 100644 --- a/src/app/components/InfoNip29.svelte +++ b/src/app/components/InfoNip29.svelte @@ -1,8 +1,8 @@
@@ -15,18 +15,17 @@ This means that anyone can host their own data, making the web more decentralized and resilient.

- Only some relays support spaces. You can find a list of suggested relays below, - or you can host your own. - If you do decide to join someone else's, make sure to follow their directions for registering + Only some relays support spaces. You can find a list of suggested relays below, or you can host your own. If you do decide to join someone else's, make sure to follow their directions for registering as a user.

groups.fiatjaf.com -
- +
diff --git a/src/app/components/InfoNostr.svelte b/src/app/components/InfoNostr.svelte index a4edd4d..2c8c1ac 100644 --- a/src/app/components/InfoNostr.svelte +++ b/src/app/components/InfoNostr.svelte @@ -1,8 +1,8 @@
@@ -11,15 +11,13 @@

Nostr is way to build social apps that talk to eachother. - Users own their social identity instead of renting it from a tech company, and can bring it with them from - app to app. + Users own their social identity instead of renting it from a tech company, and can bring it with + them from app to app.

- This can be a little confusing when you're just getting started, but as long as you're using Flotilla, it - will work just like a normal app. When you're ready to start exploring nostr, visit your settings page to - learn more. + This can be a little confusing when you're just getting started, but as long as you're using + Flotilla, it will work just like a normal app. When you're ready to start exploring nostr, visit + your settings page to learn more.

- +
diff --git a/src/app/components/Landing.svelte b/src/app/components/Landing.svelte index 7386263..255bf1a 100644 --- a/src/app/components/Landing.svelte +++ b/src/app/components/Landing.svelte @@ -1,8 +1,8 @@
-
+
- + {#each $userGroupsByNom.entries() as [nom, qualifiedGroups] (nom)} {@const qualifiedGroup = qualifiedGroups[0]} diff --git a/src/app/components/SecondaryNav.svelte b/src/app/components/SecondaryNav.svelte index b66c9f1..2b9deff 100644 --- a/src/app/components/SecondaryNav.svelte +++ b/src/app/components/SecondaryNav.svelte @@ -1,50 +1,59 @@ -
- {#if getPrimaryNavItem($page) === 'discover'} -
- - Spaces - -
-
- - Themes - -
- {:else if getPrimaryNavItem($page) === 'space'} - - {:else if getPrimaryNavItem($page) === 'settings'} +
+ {#if getPrimaryNavItem($page) === "discover"} + +
+ + Spaces + +
+
+ + Themes + +
+
+ {:else if getPrimaryNavItem($page) === "space"} + {#key $page.params.nom} + + {/key} + {:else if getPrimaryNavItem($page) === "settings"} {:else} -
- - Home - -
-
- - People - -
-
- - Saved Notes - -
-
- Conversations -
- + +
+ + Home +
-
+
+ + People + +
+
+ + Saved Notes + +
+
+ + Conversations +
+ +
+
+
+ {/if}
diff --git a/src/app/components/SecondaryNavForSpace.svelte b/src/app/components/SecondaryNavForSpace.svelte new file mode 100644 index 0000000..9b6e5f3 --- /dev/null +++ b/src/app/components/SecondaryNavForSpace.svelte @@ -0,0 +1,70 @@ + + + +
+ + {$group?.name || "[no name]"} + + + {#if showMenu} + + + + {/if} +
+
+ + Rooms +
+ +
+
+
+ + Spaces + +
+
+ + Themes + +
+ diff --git a/src/app/components/SignUp.svelte b/src/app/components/SignUp.svelte index 8b13789..e69de29 100644 --- a/src/app/components/SignUp.svelte +++ b/src/app/components/SignUp.svelte @@ -1 +0,0 @@ - diff --git a/src/app/components/SpaceAdd.svelte b/src/app/components/SpaceAdd.svelte index 17b2f40..e78fbb3 100644 --- a/src/app/components/SpaceAdd.svelte +++ b/src/app/components/SpaceAdd.svelte @@ -1,9 +1,9 @@ + +
+

+ You are leaving {$group?.name || "[no name]"} +

+

+ Are you sure you want to leave? +

+
+ + +
+
diff --git a/src/app/components/SpaceJoin.svelte b/src/app/components/SpaceJoin.svelte index e73bb0b..ec75a84 100644 --- a/src/app/components/SpaceJoin.svelte +++ b/src/app/components/SpaceJoin.svelte @@ -1,17 +1,17 @@
{#if src} {:else} - + {/if}
diff --git a/src/lib/components/Button.svelte b/src/lib/components/Button.svelte index fd43c21..ad17ede 100644 --- a/src/lib/components/Button.svelte +++ b/src/lib/components/Button.svelte @@ -1,4 +1,3 @@ - diff --git a/src/lib/components/CardButton.svelte b/src/lib/components/CardButton.svelte index 27ea598..094c795 100644 --- a/src/lib/components/CardButton.svelte +++ b/src/lib/components/CardButton.svelte @@ -1,5 +1,5 @@ - +{/if} diff --git a/src/lib/components/SecondaryNavSection.svelte b/src/lib/components/SecondaryNavSection.svelte new file mode 100644 index 0000000..eae9f52 --- /dev/null +++ b/src/lib/components/SecondaryNavSection.svelte @@ -0,0 +1,3 @@ +
+ +
diff --git a/src/lib/components/Spinner.svelte b/src/lib/components/Spinner.svelte index 601182a..0fcf7c8 100644 --- a/src/lib/components/Spinner.svelte +++ b/src/lib/components/Spinner.svelte @@ -1,12 +1,12 @@ {#if loading} - + {/if} diff --git a/src/lib/util.ts b/src/lib/util.ts index 08f5d16..25e9049 100644 --- a/src/lib/util.ts +++ b/src/lib/util.ts @@ -1,9 +1,9 @@ import Fuse from "fuse.js" -import type {IFuseOptions, FuseResult} from 'fuse.js' -import {throttle} from 'throttle-debounce' -import {writable} from 'svelte/store' -import {sortBy} from '@welshman/lib' -import {browser} from '$app/environment' +import type {IFuseOptions, FuseResult} from "fuse.js" +import {throttle} from "throttle-debounce" +import {writable} from "svelte/store" +import {sortBy} from "@welshman/lib" +import {browser} from "$app/environment" export const parseJson = (json: string) => { if (!json) return null @@ -15,8 +15,7 @@ export const parseJson = (json: string) => { } } -export const getJson = (k: string) => - browser ? parseJson(localStorage.getItem(k) || "") : null +export const getJson = (k: string) => (browser ? parseJson(localStorage.getItem(k) || "") : null) export const setJson = (k: string, v: any) => { if (browser) { @@ -61,7 +60,6 @@ export const createSearch = (data: T[], opts: SearchOptions) => { } } - export const secondsToDate = (ts: number) => new Date(ts * 1000) export const dateToSeconds = (date: Date) => Math.round(date.valueOf() / 1000) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index a58e3b9..9ab8482 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,8 +1,8 @@ -
-
-
-
- {#each elements as {type, id, value, showPubkey} (id)} +
+
+
+ {#each elements as { type, id, value, showPubkey } (id)} {#if type === "date"} -
+

{value}

@@ -72,7 +71,7 @@ {/if} {/each} -

+

{#if loading} Looking for messages... @@ -82,7 +81,5 @@

-
-
+
- diff --git a/src/routes/themes/+page.svelte b/src/routes/themes/+page.svelte index cd8f969..5390742 100644 --- a/src/routes/themes/+page.svelte +++ b/src/routes/themes/+page.svelte @@ -1,9 +1,9 @@