Files
ihasmail-inbuxa/web/src/lib/brand.ts
T
jcoffey-dev fdcf27f3ea Merge public ihasmail: the app's name comes from APP_NAME everywhere
Upstream's {app} placeholder (#406) replaces most of the fork's own
renamed strings: the user menu, the About heading and its version line
now say INBUXA because APP_NAME does, not because the fork wrote it in.

Kept from the fork: inbuxa.org rather than ihasmail.org, no Documentation
entry until INBUXA has its own, the INBUXA mark and wordmark, the "Built
on ihasmail" credit, and the About note that says nothing about the
server software. DEFAULT_APP_NAME stays INBUXA.

The credit's placeholder is {project} now, so the name of the project is
not spelled inside a key that upstream's new test reads as a hard-coded
app name.
2026-09-19 14:29:43 -07:00

39 lines
1.7 KiB
TypeScript

import { useSession } from "@/store/session";
/**
* What this instance calls itself, when nothing has said otherwise yet.
*
* `APP_NAME` is a runtime environment variable, so the real answer arrives
* from the server -- on `/api/config` before anybody signs in, and on the
* session afterwards. This is what stands in until it does, and what stands
* for good if the request fails: a sign-in form with no name on it would be
* worse than one with the wrong name.
*
* One constant rather than the string written out at each of them, because
* three copies of a default is how two of them end up stale.
*/
// ihasmail-inbuxa: INBUXA's webmail goes by INBUXA, so it can't be taken for
// public ihasmail. APP_NAME still names a deployment whatever it likes.
export const DEFAULT_APP_NAME = "INBUXA";
/**
* What this instance calls itself, right now.
*
* Text that names the app reads it from here rather than writing "ihasmail"
* into the sentence, so an instance renamed with `APP_NAME` is called by its
* name everywhere, not only on the sign-in page and in the title bar. The
* name goes into the sentence as the `{app}` placeholder, which also lets a
* translator put it where their language wants it.
*
* Two shapes for the same fact: the hook for components, and the plain
* function for the few places that build strings outside React (the service
* worker's facts, for one). Both fall back to the default until the session
* arrives.
*/
export function useAppName(): string {
return useSession((s) => s.session?.ihasmail?.appName)?.trim() || DEFAULT_APP_NAME;
}
export function currentAppName(): string {
return useSession.getState().session?.ihasmail?.appName?.trim() || DEFAULT_APP_NAME;
}