diff --git a/shared/components/rstack-space-switcher.ts b/shared/components/rstack-space-switcher.ts index 14e94be..353c332 100644 --- a/shared/components/rstack-space-switcher.ts +++ b/shared/components/rstack-space-switcher.ts @@ -9,7 +9,7 @@ * Passes auth token so the API returns private spaces the user can access. */ -import { isAuthenticated, getAccessToken } from "./rstack-identity"; +import { isAuthenticated, getAccessToken, getUsername } from "./rstack-identity"; import { rspaceNavUrl, getCurrentModule as getModule } from "../url-helpers"; interface SpaceInfo { @@ -117,26 +117,47 @@ export class RStackSpaceSwitcher extends HTMLElement { } #renderMenu(menu: HTMLElement, current: string) { + const auth = isAuthenticated(); + if (this.#spaces.length === 0) { + let cta = ""; + if (!auth) { + cta = this.#yourSpaceCTAhtml("Sign in to create →"); + } else { + cta = this.#yourSpaceCTAhtml("Create (you)rSpace →"); + } menu.innerHTML = ` + ${cta} +
+ Create new space `; + this.#attachYourSpaceCTA(menu); return; } const moduleId = this.#getCurrentModule(); - const auth = isAuthenticated(); // 3-section split const mySpaces = this.#spaces.filter((s) => s.role); const publicSpaces = this.#spaces.filter((s) => s.accessible !== false && !s.role); const discoverSpaces = this.#spaces.filter((s) => s.accessible === false); + const hasOwnedSpace = mySpaces.some((s) => s.relationship === "owner"); + let html = ""; + // ── Create (you)rSpace CTA — only if user has no owned spaces ── + if (!auth) { + html += this.#yourSpaceCTAhtml("Sign in to create →"); + html += ``; + } else if (!hasOwnedSpace) { + html += this.#yourSpaceCTAhtml("Create (you)rSpace →"); + html += ``; + } + // ── Your spaces ── if (mySpaces.length > 0) { html += `Collaborative community spaces powered by FolkJS
-