feature flags config / typed app config
This commit is contained in:
@ -12,7 +12,7 @@ const ExtendedFormattedMessage: FC<ExtendedProps> = props => {
|
||||
useEffect(() => {
|
||||
const translatedMessage = formatMessage({ id, defaultMessage }, values);
|
||||
if (typeof translatedMessage === "string") {
|
||||
setProcessedMessage(translatedMessage.replace("Snort", process.env.APP_NAME_CAPITALIZED || "Snort"));
|
||||
setProcessedMessage(translatedMessage.replace("Snort", CONFIG.appNameCapitalized || "Snort"));
|
||||
}
|
||||
}, [id, defaultMessage, values, formatMessage]);
|
||||
|
||||
|
@ -4,7 +4,7 @@ const Logo = () => {
|
||||
const navigate = useNavigate();
|
||||
return (
|
||||
<h1 className="logo" onClick={() => navigate("/")}>
|
||||
{process.env.APP_NAME}
|
||||
{CONFIG.appNameCapitalized}
|
||||
</h1>
|
||||
);
|
||||
};
|
||||
|
@ -145,7 +145,7 @@ export function LoginUnlock() {
|
||||
<FormattedMessage
|
||||
defaultMessage="Enter a pin to encrypt your private key, you must enter this pin every time you open {site}."
|
||||
values={{
|
||||
site: process.env.APP_NAME_CAPITALIZED,
|
||||
site: CONFIG.appNameCapitalized,
|
||||
}}
|
||||
/>
|
||||
</p>
|
||||
|
@ -1,6 +1,6 @@
|
||||
import "./DisplayName.css";
|
||||
|
||||
import React, { useMemo } from "react";
|
||||
import { useMemo } from "react";
|
||||
import { HexKey, UserMetadata, NostrPrefix } from "@snort/system";
|
||||
import AnimalName from "Element/User/AnimalName";
|
||||
import { hexToBech32 } from "SnortUtils";
|
||||
@ -22,7 +22,7 @@ export function getDisplayNameOrPlaceHolder(user: UserMetadata | undefined, pubk
|
||||
name = user.display_name;
|
||||
} else if (typeof user?.name === "string" && user.name.length > 0) {
|
||||
name = user.name;
|
||||
} else if (pubkey && process.env.ANIMAL_NAME_PLACEHOLDERS) {
|
||||
} else if (pubkey && CONFIG.animalNamePlaceholders) {
|
||||
name = AnimalName(pubkey);
|
||||
isPlaceHolder = true;
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ export default function useLoginFeed() {
|
||||
leaveOpen: true,
|
||||
});
|
||||
b.withFilter().authors([pubKey]).kinds([EventKind.ContactList]);
|
||||
if (!login.readonly) {
|
||||
if (CONFIG.features.subscriptions && !login.readonly) {
|
||||
b.withFilter().authors([pubKey]).kinds([EventKind.AppData]).tag("d", ["snort"]);
|
||||
b.withFilter()
|
||||
.relay("wss://relay.snort.social")
|
||||
|
@ -94,13 +94,13 @@ const DonatePage = () => {
|
||||
<h2>
|
||||
<FormattedMessage
|
||||
defaultMessage="Help fund the development of {site}"
|
||||
values={{ site: process.env.APP_NAME_CAPITALIZED }}
|
||||
values={{ site: CONFIG.appNameCapitalized }}
|
||||
/>
|
||||
</h2>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="{site} is an open source project built by passionate people in their free time"
|
||||
values={{ site: process.env.APP_NAME_CAPITALIZED }}
|
||||
values={{ site: CONFIG.appNameCapitalized }}
|
||||
/>
|
||||
</p>
|
||||
<p>
|
||||
|
@ -209,7 +209,7 @@ function LogoHeader() {
|
||||
|
||||
return (
|
||||
<Link to="/" className="logo">
|
||||
<h1>{process.env.APP_NAME}</h1>
|
||||
<h1>{CONFIG.appName}</h1>
|
||||
{currentSubscription && (
|
||||
<small className="flex">
|
||||
<Icon name="diamond" size={10} className="mr5" />
|
||||
|
@ -143,7 +143,7 @@ export default function LoginPage() {
|
||||
|
||||
function generateNip46() {
|
||||
const meta = {
|
||||
name: process.env.APP_NAME_CAPITALIZED,
|
||||
name: CONFIG.appNameCapitalized,
|
||||
url: window.location.href,
|
||||
};
|
||||
|
||||
@ -287,7 +287,7 @@ export default function LoginPage() {
|
||||
<div>
|
||||
<div className="login-container">
|
||||
<h1 className="logo" onClick={() => navigate("/")}>
|
||||
{process.env.APP_NAME}
|
||||
{CONFIG.appName}
|
||||
</h1>
|
||||
<h1 dir="auto">
|
||||
<FormattedMessage defaultMessage="Login" description="Login header" />
|
||||
@ -342,7 +342,7 @@ export default function LoginPage() {
|
||||
<FormattedMessage
|
||||
defaultMessage="Secure your private key with a PIN, ensuring enhanced protection on {site}. You'll be prompted to enter this PIN each time you access the site."
|
||||
values={{
|
||||
site: process.env.APP_NAME_CAPITALIZED,
|
||||
site: CONFIG.appNameCapitalized,
|
||||
}}
|
||||
/>
|
||||
</p>
|
||||
|
@ -25,7 +25,7 @@ export default function NostrLinkHandler() {
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
const pubkey = await getNip05PubKey(`${link}@${process.env.NIP05_DOMAIN}`);
|
||||
const pubkey = await getNip05PubKey(`${link}@${CONFIG.nip05Domain}`);
|
||||
if (pubkey) {
|
||||
setRenderComponent(<ProfilePage id={pubkey} />); // Directly render ProfilePage
|
||||
}
|
||||
|
@ -139,8 +139,8 @@ export default function ProfilePage({ id: propId }: ProfilePageProps) {
|
||||
|
||||
useEffect(() => {
|
||||
if (user?.nip05 && user?.isNostrAddressValid) {
|
||||
if (user.nip05.endsWith(`@${process.env.NIP05_DOMAIN}`)) {
|
||||
const username = user.nip05?.replace(`@${process.env.NIP05_DOMAIN}`, "");
|
||||
if (user.nip05.endsWith(`@${CONFIG.nip05Domain}`)) {
|
||||
const username = user.nip05?.replace(`@${CONFIG.nip05Domain}`, "");
|
||||
navigate(`/${username}`, { replace: true });
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,11 @@ export default defineMessages({
|
||||
KeysSaved: { defaultMessage: "I have saved my keys, continue" },
|
||||
WhatIsSnort: {
|
||||
defaultMessage: "What is {site} and how does it work?",
|
||||
values: { site: process.env.APP_NAME_CAPITALIZED },
|
||||
values: { site: CONFIG.appNameCapitalized },
|
||||
},
|
||||
WhatIsSnortIntro: {
|
||||
defaultMessage: `{site} is a Nostr UI, nostr is a decentralised protocol for saving and distributing "notes".`,
|
||||
values: { site: process.env.APP_NAME_CAPITALIZED },
|
||||
values: { site: CONFIG.appNameCapitalized },
|
||||
},
|
||||
WhatIsSnortNotes: {
|
||||
defaultMessage: `Notes hold text content, the most popular usage of these notes is to store "tweet like" messages.`,
|
||||
@ -26,7 +26,7 @@ export default defineMessages({
|
||||
|
||||
WhatIsSnortExperience: {
|
||||
defaultMessage: "{site} is designed to have a similar experience to Twitter.",
|
||||
values: { site: process.env.APP_NAME_CAPITALIZED },
|
||||
values: { site: CONFIG.appNameCapitalized },
|
||||
},
|
||||
HowKeysWork: { defaultMessage: "How do keys work?" },
|
||||
DigitalSignatures: {
|
||||
@ -70,9 +70,9 @@ export default defineMessages({
|
||||
NameSquatting: {
|
||||
defaultMessage:
|
||||
"Name-squatting and impersonation is not allowed. {site} and our partners reserve the right to terminate your handle (not your account - nobody can take that away) for violating this rule.",
|
||||
values: { site: process.env.APP_NAME_CAPITALIZED },
|
||||
values: { site: CONFIG.appNameCapitalized },
|
||||
},
|
||||
PreviewOnSnort: { defaultMessage: "Preview on {site}", values: { site: process.env.APP_NAME_CAPITALIZED } },
|
||||
PreviewOnSnort: { defaultMessage: "Preview on {site}", values: { site: CONFIG.appNameCapitalized } },
|
||||
GetSnortId: { defaultMessage: "Get a Snort identifier" },
|
||||
GetSnortIdHelp: {
|
||||
defaultMessage:
|
||||
|
@ -6,9 +6,9 @@ import Icon from "Icons/Icon";
|
||||
import { LoginStore, logout } from "Login";
|
||||
import useLogin from "Hooks/useLogin";
|
||||
import { getCurrentSubscription } from "Subscription";
|
||||
import usePageWidth from "Hooks/usePageWidth";
|
||||
|
||||
import messages from "./messages";
|
||||
import usePageWidth from "Hooks/usePageWidth";
|
||||
|
||||
const SettingsIndex = () => {
|
||||
const login = useLogin();
|
||||
@ -61,11 +61,13 @@ const SettingsIndex = () => {
|
||||
<FormattedMessage defaultMessage="Nostr Adddress" />
|
||||
<Icon name="arrowFront" size={16} />
|
||||
</div>
|
||||
<div className="settings-row" onClick={() => navigate("/subscribe/manage")}>
|
||||
<Icon name="diamond" size={24} />
|
||||
<FormattedMessage defaultMessage="Subscription" />
|
||||
<Icon name="arrowFront" size={16} />
|
||||
</div>
|
||||
{CONFIG.features.subscriptions && (
|
||||
<div className="settings-row" onClick={() => navigate("/subscribe/manage")}>
|
||||
<Icon name="diamond" size={24} />
|
||||
<FormattedMessage defaultMessage="Subscription" />
|
||||
<Icon name="arrowFront" size={16} />
|
||||
</div>
|
||||
)}
|
||||
{sub && (
|
||||
<div className="settings-row" onClick={() => navigate("accounts")}>
|
||||
<Icon name="code-circle" size={24} />
|
||||
|
@ -15,7 +15,7 @@ export class DonateTask extends BaseUITask {
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="Thanks for using {site}, please consider donating if you can."
|
||||
values={{ site: process.env.APP_NAME_CAPITALIZED }}
|
||||
values={{ site: CONFIG.appNameCapitalized }}
|
||||
/>
|
||||
</p>
|
||||
<Link to="/donate">
|
||||
|
@ -16,6 +16,7 @@ import {
|
||||
ReqFilter,
|
||||
PowMiner,
|
||||
NostrEvent,
|
||||
mapEventToProfile,
|
||||
} from "@snort/system";
|
||||
import { SnortContext } from "@snort/system-react";
|
||||
|
||||
@ -87,6 +88,29 @@ export const System = new NostrSystem({
|
||||
},
|
||||
});
|
||||
|
||||
async function fetchProfile(key: string) {
|
||||
const rsp = await fetch(`${CONFIG.httpCache}/profile/${key}`);
|
||||
if (rsp.ok) {
|
||||
try {
|
||||
const data = (await rsp.json()) as NostrEvent;
|
||||
if (data) {
|
||||
return mapEventToProfile(data);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add profile loader fn
|
||||
*/
|
||||
if (CONFIG.httpCache) {
|
||||
System.ProfileLoader.loaderFn = async (keys: Array<string>) => {
|
||||
return (await Promise.all(keys.map(a => fetchProfile(a)))).filter(a => a !== undefined).map(a => unwrap(a));
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Singleton user profile loader
|
||||
*/
|
||||
@ -191,7 +215,7 @@ export const router = createBrowserRouter([
|
||||
},
|
||||
...NewUserRoutes,
|
||||
...WalletRoutes,
|
||||
...SubscribeRoutes,
|
||||
...(CONFIG.features.subscriptions ? SubscribeRoutes : []),
|
||||
{
|
||||
path: "/debug",
|
||||
element: <DebugPage />,
|
||||
|
Reference in New Issue
Block a user