Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

guestShareAvailability.ts

18 lines796 Bytes

1import type { EnvironmentId } from "@t3tools/contracts";
2import { Atom } from "effect/reactivity";
3​
4import { environmentPresentations } from "~/state/presentation";
5import { serverEnvironment } from "~/state/server";
6​
7/**
8 * Whether this environment offers "Share with guest": the user may create links there, and its
9 * Guest links beta is on (Settings > Labs). The server refuses links while the beta is off.
10 */
11export const canShareWithGuestAtom = Atom.family((environmentId: EnvironmentId) =>
12 Atom.make(
13 (get) =>
14 get(serverEnvironment.createGuestShare.permissionAtom(environmentId)) &&
15 get(environmentPresentations.serverConfigsAtom).get(environmentId)?.settings
16 .guestSharingEnabled === true,
17 ).pipe(Atom.withLabel(`guest-share:available:${environmentId}`)),
18);