feat: more feature flags
This commit is contained in:
parent
1a507679f3
commit
281785952d
@ -9,6 +9,9 @@
|
||||
"httpCache": "",
|
||||
"animalNamePlaceholders": false,
|
||||
"features": {
|
||||
"subscriptions": true
|
||||
"analytics": true,
|
||||
"subscriptions": true,
|
||||
"deck": true,
|
||||
"zapPool": true
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,9 @@
|
||||
"httpCache": "https://api.iris.to",
|
||||
"animalNamePlaceholders": true,
|
||||
"features": {
|
||||
"subscriptions": false
|
||||
"analytics": true,
|
||||
"subscriptions": false,
|
||||
"deck": true,
|
||||
"zapPool": true
|
||||
}
|
||||
}
|
||||
|
4
packages/app/custom.d.ts
vendored
4
packages/app/custom.d.ts
vendored
@ -45,7 +45,11 @@ declare const CONFIG: {
|
||||
appleTouchIconUrl: string;
|
||||
httpCache: string;
|
||||
animalNamePlaceholders: boolean;
|
||||
defaultZapPoolFee?: number;
|
||||
features: {
|
||||
analytics: boolean;
|
||||
subscriptions: boolean;
|
||||
deck: boolean;
|
||||
zapPool: boolean;
|
||||
};
|
||||
};
|
||||
|
@ -80,7 +80,7 @@ export default function WriteMessage({ chat }: { chat: Chat }) {
|
||||
|
||||
return (
|
||||
<>
|
||||
<button className="circle flex flex-center" onClick={() => attachFile()}>
|
||||
<button className="circle flex f-center" onClick={() => attachFile()}>
|
||||
{uploading ? <Spinner width={20} /> : <Icon name="attachment" size={20} />}
|
||||
</button>
|
||||
<div className="w-max">
|
||||
@ -97,7 +97,7 @@ export default function WriteMessage({ chat }: { chat: Chat }) {
|
||||
/>
|
||||
{error && <b className="error">{error}</b>}
|
||||
</div>
|
||||
<button className="circle flex flex-center" onClick={() => sendMessage()}>
|
||||
<button className="circle flex f-center" onClick={() => sendMessage()}>
|
||||
{sending ? <Spinner width={20} /> : <Icon name="arrow-right" size={20} />}
|
||||
</button>
|
||||
</>
|
||||
|
@ -1,11 +1,12 @@
|
||||
import "./Markdown.css";
|
||||
|
||||
import { ReactNode, forwardRef, useMemo } from "react";
|
||||
import { transformText } from "@snort/system";
|
||||
import { marked, Token } from "marked";
|
||||
import { Link } from "react-router-dom";
|
||||
import markedFootnote, { Footnotes, Footnote, FootnoteRef } from "marked-footnote";
|
||||
|
||||
import { ProxyImg } from "Element/ProxyImg";
|
||||
import { transformText } from "@snort/system";
|
||||
import Mention from "Element/Embed/Mention";
|
||||
import NostrLink from "Element/Embed/NostrLink";
|
||||
|
||||
|
@ -159,7 +159,9 @@ export default function NoteFooter(props: NoteFooterProps) {
|
||||
const result = await zapper.send(wallet, targets, amount);
|
||||
const totalSent = result.reduce((acc, v) => (acc += v.sent), 0);
|
||||
if (totalSent > 0) {
|
||||
ZapPoolController.allocate(totalSent);
|
||||
if (CONFIG.features.zapPool) {
|
||||
ZapPoolController?.allocate(totalSent);
|
||||
}
|
||||
await interactionCache.zap();
|
||||
}
|
||||
});
|
||||
|
@ -78,7 +78,7 @@ export default function Layout() {
|
||||
onClick={() => {
|
||||
LoginStore.removeSession(id);
|
||||
}}>
|
||||
<button type="button" className="circle flex flex-center">
|
||||
<button type="button" className="circle flex f-center">
|
||||
<Icon name="close" />
|
||||
</button>
|
||||
</div>
|
||||
|
@ -34,6 +34,7 @@ const DataProviders = [
|
||||
];
|
||||
|
||||
function ZapTarget({ target }: { target: ZapPoolRecipient }) {
|
||||
if (!ZapPoolController) return;
|
||||
const login = useLogin();
|
||||
const profile = useUserProfile(target.pubkey);
|
||||
const hasAddress = profile?.lud16 || profile?.lud06;
|
||||
@ -54,7 +55,7 @@ function ZapTarget({ target }: { target: ZapPoolRecipient }) {
|
||||
max={100}
|
||||
value={target.split}
|
||||
onChange={e =>
|
||||
ZapPoolController.set({
|
||||
ZapPoolController?.set({
|
||||
...target,
|
||||
split: e.target.valueAsNumber,
|
||||
})
|
||||
@ -70,11 +71,12 @@ function ZapTarget({ target }: { target: ZapPoolRecipient }) {
|
||||
}
|
||||
|
||||
export default function ZapPoolPage() {
|
||||
if (!ZapPoolController) return;
|
||||
const login = useLogin();
|
||||
const { system } = useEventPublisher();
|
||||
const zapPool = useSyncExternalStore(
|
||||
c => ZapPoolController.hook(c),
|
||||
() => ZapPoolController.snapshot(),
|
||||
c => unwrap(ZapPoolController).hook(c),
|
||||
() => unwrap(ZapPoolController).snapshot(),
|
||||
);
|
||||
const { wallet } = useWallet();
|
||||
|
||||
@ -146,7 +148,7 @@ export default function ZapPoolPage() {
|
||||
</p>
|
||||
<p>
|
||||
{wallet && (
|
||||
<AsyncButton onClick={() => ZapPoolController.payout(wallet)}>
|
||||
<AsyncButton onClick={() => ZapPoolController?.payout(wallet)}>
|
||||
<FormattedMessage defaultMessage="Payout Now" />
|
||||
</AsyncButton>
|
||||
)}
|
||||
|
@ -207,7 +207,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) {
|
||||
<Avatar pubkey={id} user={user} image={picture} />
|
||||
<AsyncButton
|
||||
type="button"
|
||||
className="circle flex flex-center"
|
||||
className="circle flex f-center"
|
||||
onClick={() => setNewAvatar()}
|
||||
disabled={readonly}>
|
||||
<Icon name="upload-01" />
|
||||
|
@ -92,11 +92,13 @@ const SettingsIndex = () => {
|
||||
<FormattedMessage {...messages.Donate} />
|
||||
<Icon name="arrowFront" size={16} />
|
||||
</div>
|
||||
{CONFIG.features.zapPool && (
|
||||
<div className="settings-row" onClick={() => navigate("/zap-pool")}>
|
||||
<Icon name="piggy-bank" size={24} />
|
||||
<FormattedMessage defaultMessage="Zap Pool" />
|
||||
<Icon name="arrowFront" size={16} />
|
||||
</div>
|
||||
)}
|
||||
<div className="settings-row" onClick={handleLogout}>
|
||||
<Icon name="logout" size={24} />
|
||||
<FormattedMessage {...messages.LogOut} />
|
||||
|
@ -168,4 +168,4 @@ class ZapPool extends ExternalStore<Array<ZapPoolRecipient>> {
|
||||
}
|
||||
}
|
||||
|
||||
export const ZapPoolController = new ZapPool();
|
||||
export const ZapPoolController = CONFIG.features.zapPool ? new ZapPool() : undefined;
|
||||
|
@ -7,7 +7,7 @@ import WasmPath from "@snort/system-wasm/pkg/system_wasm_bg.wasm";
|
||||
|
||||
import { StrictMode } from "react";
|
||||
import * as ReactDOM from "react-dom/client";
|
||||
import { createBrowserRouter, RouterProvider } from "react-router-dom";
|
||||
import { createBrowserRouter, RouteObject, RouterProvider } from "react-router-dom";
|
||||
import {
|
||||
NostrSystem,
|
||||
ProfileLoaderService,
|
||||
@ -148,7 +148,7 @@ async function initSite() {
|
||||
|
||||
// inject analytics script
|
||||
// <script defer data-domain="snort.social" src="http://analytics.v0l.io/js/script.js"></script>
|
||||
if (login.preferences.telemetry ?? true) {
|
||||
if (CONFIG.features.analytics && (login.preferences.telemetry ?? true)) {
|
||||
const sc = document.createElement("script");
|
||||
sc.src = "https://analytics.v0l.io/js/script.js";
|
||||
sc.defer = true;
|
||||
@ -159,18 +159,7 @@ async function initSite() {
|
||||
}
|
||||
|
||||
let didInit = false;
|
||||
export const router = createBrowserRouter([
|
||||
{
|
||||
element: <Layout />,
|
||||
errorElement: <ErrorPage />,
|
||||
loader: async () => {
|
||||
if (!didInit) {
|
||||
didInit = true;
|
||||
return await initSite();
|
||||
}
|
||||
return null;
|
||||
},
|
||||
children: [
|
||||
const mainRoutes = [
|
||||
...RootRoutes,
|
||||
{
|
||||
path: "/login",
|
||||
@ -217,24 +206,48 @@ export const router = createBrowserRouter([
|
||||
path: "/search/:keyword?",
|
||||
element: <SearchPage />,
|
||||
},
|
||||
{
|
||||
path: "/zap-pool",
|
||||
element: <ZapPoolPage />,
|
||||
},
|
||||
{
|
||||
path: "/list-feed/:id",
|
||||
element: <ListFeedPage />,
|
||||
},
|
||||
...NewUserRoutes,
|
||||
...WalletRoutes,
|
||||
...(CONFIG.features.subscriptions ? SubscribeRoutes : []),
|
||||
{
|
||||
] as Array<RouteObject>;
|
||||
|
||||
if (CONFIG.features.zapPool) {
|
||||
mainRoutes.push({
|
||||
path: "/zap-pool",
|
||||
element: <ZapPoolPage />,
|
||||
});
|
||||
}
|
||||
|
||||
if (CONFIG.features.subscriptions) {
|
||||
mainRoutes.push(...SubscribeRoutes);
|
||||
}
|
||||
|
||||
// add catch all route
|
||||
mainRoutes.push({
|
||||
path: "/*",
|
||||
element: <NostrLinkHandler />,
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
const routes = [
|
||||
{
|
||||
element: <Layout />,
|
||||
errorElement: <ErrorPage />,
|
||||
loader: async () => {
|
||||
if (!didInit) {
|
||||
didInit = true;
|
||||
return await initSite();
|
||||
}
|
||||
return null;
|
||||
},
|
||||
children: mainRoutes,
|
||||
},
|
||||
] as Array<RouteObject>;
|
||||
|
||||
if (CONFIG.features.deck) {
|
||||
routes.push({
|
||||
path: "/deck",
|
||||
element: <SnortDeckLayout />,
|
||||
loader: async () => {
|
||||
@ -245,8 +258,10 @@ export const router = createBrowserRouter([
|
||||
return null;
|
||||
},
|
||||
children: RootTabRoutes,
|
||||
},
|
||||
]);
|
||||
} as RouteObject);
|
||||
}
|
||||
|
||||
export const router = createBrowserRouter(routes);
|
||||
|
||||
const root = ReactDOM.createRoot(unwrap(document.getElementById("root")));
|
||||
root.render(
|
||||
|
Loading…
x
Reference in New Issue
Block a user