Allow for multiple platform relays

This commit is contained in:
Jon Staab
2025-05-29 13:37:23 -07:00
parent ac8530bd9a
commit 6d2e9a037d
7 changed files with 100 additions and 80 deletions

View File

@@ -5,7 +5,7 @@ VITE_PLATFORM_TERMS=https://flotilla.social/terms
VITE_PLATFORM_PRIVACY=https://flotilla.social/privacy VITE_PLATFORM_PRIVACY=https://flotilla.social/privacy
VITE_PLATFORM_NAME=Flotilla VITE_PLATFORM_NAME=Flotilla
VITE_PLATFORM_LOGO=static/flotilla.png VITE_PLATFORM_LOGO=static/flotilla.png
VITE_PLATFORM_RELAY= VITE_PLATFORM_RELAYS=
VITE_PLATFORM_ACCENT="#7161FF" VITE_PLATFORM_ACCENT="#7161FF"
VITE_PLATFORM_SECONDARY="#EB5E28" VITE_PLATFORM_SECONDARY="#EB5E28"
VITE_PLATFORM_DESCRIPTION="Flotilla is nostr — for communities." VITE_PLATFORM_DESCRIPTION="Flotilla is nostr — for communities."

View File

@@ -12,7 +12,7 @@ You can also optionally create an `.env` file and populate it with the following
- `VITE_PLATFORM_URL` - The url where the app will be hosted. This is only used for build-time population of meta tags. - `VITE_PLATFORM_URL` - The url where the app will be hosted. This is only used for build-time population of meta tags.
- `VITE_PLATFORM_NAME` - The name of the app - `VITE_PLATFORM_NAME` - The name of the app
- `VITE_PLATFORM_LOGO` - A logo url for the app - `VITE_PLATFORM_LOGO` - A logo url for the app
- `VITE_PLATFORM_RELAY` - A relay url that will make flotilla operate in "platform mode". Disables all space browse/add/select functionality and makes the platform relay the home page. - `VITE_PLATFORM_RELAYS` - A list of comma-separated relay urls that will make flotilla operate in "platform mode". Disables all space browse/add/select functionality and makes the first platform relay the home page.
- `VITE_PLATFORM_ACCENT` - A hex color for the app's accent color - `VITE_PLATFORM_ACCENT` - A hex color for the app's accent color
- `VITE_PLATFORM_DESCRIPTION` - A description of the app - `VITE_PLATFORM_DESCRIPTION` - A description of the app
- `VITE_GLITCHTIP_API_KEY` - A Sentry DSN for use with glitchtip (error reporting) - `VITE_GLITCHTIP_API_KEY` - A Sentry DSN for use with glitchtip (error reporting)

View File

@@ -5,13 +5,16 @@
import CardButton from "@lib/components/CardButton.svelte" import CardButton from "@lib/components/CardButton.svelte"
import MenuSpacesItem from "@app/components/MenuSpacesItem.svelte" import MenuSpacesItem from "@app/components/MenuSpacesItem.svelte"
import SpaceAdd from "@app/components/SpaceAdd.svelte" import SpaceAdd from "@app/components/SpaceAdd.svelte"
import {userRoomsByUrl} from "@app/state" import {userRoomsByUrl, PLATFORM_RELAYS} from "@app/state"
import {pushModal} from "@app/modal" import {pushModal} from "@app/modal"
const addSpace = () => pushModal(SpaceAdd) const addSpace = () => pushModal(SpaceAdd)
</script> </script>
<div class="column menu gap-2"> <div class="column menu gap-2">
{#each PLATFORM_RELAYS as url (url)}
<MenuSpacesItem {url} />
{:else}
{#if $userRoomsByUrl.size > 0} {#if $userRoomsByUrl.size > 0}
{#each $userRoomsByUrl.keys() as url (url)} {#each $userRoomsByUrl.keys() as url (url)}
<MenuSpacesItem {url} /> <MenuSpacesItem {url} />
@@ -31,4 +34,5 @@
{/snippet} {/snippet}
</CardButton> </CardButton>
</Button> </Button>
{/each}
</div> </div>

View File

@@ -13,7 +13,7 @@
import MenuOtherSpaces from "@app/components/MenuOtherSpaces.svelte" import MenuOtherSpaces from "@app/components/MenuOtherSpaces.svelte"
import MenuSettings from "@app/components/MenuSettings.svelte" import MenuSettings from "@app/components/MenuSettings.svelte"
import PrimaryNavItemSpace from "@app/components/PrimaryNavItemSpace.svelte" import PrimaryNavItemSpace from "@app/components/PrimaryNavItemSpace.svelte"
import {userRoomsByUrl, canDecrypt, PLATFORM_RELAY, PLATFORM_LOGO} from "@app/state" import {userRoomsByUrl, canDecrypt, PLATFORM_RELAYS, PLATFORM_LOGO} from "@app/state"
import {pushModal} from "@app/modal" import {pushModal} from "@app/modal"
import {makeSpacePath} from "@app/routes" import {makeSpacePath} from "@app/routes"
import {notifications} from "@app/notifications" import {notifications} from "@app/notifications"
@@ -57,8 +57,8 @@
class="ml-sai mt-sai mb-sai relative z-nav hidden w-14 flex-shrink-0 bg-base-200 pt-4 md:block"> class="ml-sai mt-sai mb-sai relative z-nav hidden w-14 flex-shrink-0 bg-base-200 pt-4 md:block">
<div class="flex h-full flex-col justify-between"> <div class="flex h-full flex-col justify-between">
<div> <div>
{#if PLATFORM_RELAY} {#each PLATFORM_RELAYS as url (url)}
<PrimaryNavItemSpace url={PLATFORM_RELAY} /> <PrimaryNavItemSpace {url} />
{:else} {:else}
<PrimaryNavItem title="Home" href="/home" class="tooltip-right"> <PrimaryNavItem title="Home" href="/home" class="tooltip-right">
<Avatar src={PLATFORM_LOGO} class="!h-10 !w-10" /> <Avatar src={PLATFORM_LOGO} class="!h-10 !w-10" />
@@ -79,7 +79,7 @@
<PrimaryNavItem title="Add Space" onclick={addSpace} class="tooltip-right"> <PrimaryNavItem title="Add Space" onclick={addSpace} class="tooltip-right">
<Avatar icon="settings-minimalistic" class="!h-10 !w-10" /> <Avatar icon="settings-minimalistic" class="!h-10 !w-10" />
</PrimaryNavItem> </PrimaryNavItem>
{/if} {/each}
</div> </div>
<div> <div>
<PrimaryNavItem <PrimaryNavItem
@@ -120,7 +120,7 @@
notification={$notifications.has("/chat")}> notification={$notifications.has("/chat")}>
<Avatar icon="letter" class="!h-10 !w-10" /> <Avatar icon="letter" class="!h-10 !w-10" />
</PrimaryNavItem> </PrimaryNavItem>
{#if !PLATFORM_RELAY} {#if PLATFORM_RELAYS.length !== 1}
<PrimaryNavItem <PrimaryNavItem
title="Spaces" title="Spaces"
onclick={showSpacesMenu} onclick={showSpacesMenu}

View File

@@ -102,7 +102,7 @@ export const PLATFORM_LOGO = PLATFORM_URL + "/pwa-192x192.png"
export const PLATFORM_NAME = import.meta.env.VITE_PLATFORM_NAME export const PLATFORM_NAME = import.meta.env.VITE_PLATFORM_NAME
export const PLATFORM_RELAY = import.meta.env.VITE_PLATFORM_RELAY export const PLATFORM_RELAYS = fromCsv(import.meta.env.VITE_PLATFORM_RELAYS)
export const PLATFORM_ACCENT = import.meta.env.VITE_PLATFORM_ACCENT export const PLATFORM_ACCENT = import.meta.env.VITE_PLATFORM_ACCENT

View File

@@ -8,19 +8,18 @@
import SpaceAdd from "@app/components/SpaceAdd.svelte" import SpaceAdd from "@app/components/SpaceAdd.svelte"
import {pushModal} from "@app/modal" import {pushModal} from "@app/modal"
import {makeSpacePath} from "@app/routes" import {makeSpacePath} from "@app/routes"
import {PLATFORM_NAME, PLATFORM_RELAY} from "@app/state" import {PLATFORM_NAME, PLATFORM_RELAYS} from "@app/state"
const addSpace = () => pushModal(SpaceAdd) const addSpace = () => pushModal(SpaceAdd)
onMount(() => { onMount(() => {
if (PLATFORM_RELAY) { if (PLATFORM_RELAYS.length > 0) {
goto(makeSpacePath(PLATFORM_RELAY)) goto(makeSpacePath(PLATFORM_RELAYS[0]))
} }
}) })
</script> </script>
{#if !PLATFORM_RELAY} <div class="hero min-h-screen overflow-auto pb-8">
<div class="hero min-h-screen overflow-auto pb-8">
<div class="hero-content"> <div class="hero-content">
<div class="column content gap-4"> <div class="column content gap-4">
<h1 class="text-center text-5xl">Welcome to</h1> <h1 class="text-center text-5xl">Welcome to</h1>
@@ -68,5 +67,4 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
{/if}

View File

@@ -299,7 +299,25 @@
{/snippet} {/snippet}
{#snippet action()} {#snippet action()}
<div class="row-2"> <div class="row-2">
{#if $membershipStatus !== MembershipStatus.Initial} {#if $membershipStatus === MembershipStatus.Initial}
<Button
class="btn btn-neutral btn-sm tooltip tooltip-left"
data-tip="Request to be added to the member list"
disabled={joining}
onclick={join}>
{#if joining}
<span class="loading loading-spinner loading-sm"></span>
{:else}
<Icon size={4} icon="login-2" />
{/if}
</Button>
{:else if $membershipStatus === MembershipStatus.Pending}
<Button
class="btn btn-neutral btn-sm tooltip tooltip-left"
data-tip="Membership is pending">
<Icon size={4} icon="clock-circle" />
</Button>
{:else}
<Button <Button
class="btn btn-neutral btn-sm tooltip tooltip-left" class="btn btn-neutral btn-sm tooltip tooltip-left"
data-tip="Request to be removed from member list" data-tip="Request to be removed from member list"