feat: default zap pool amount
This commit is contained in:
parent
e627cddd24
commit
cf6aa6b134
@ -8,6 +8,7 @@
|
||||
"appleTouchIconUrl": "/nostrich_512.png",
|
||||
"httpCache": "",
|
||||
"animalNamePlaceholders": false,
|
||||
"defaultZapPoolFee": 0.5,
|
||||
"features": {
|
||||
"analytics": true,
|
||||
"subscriptions": true,
|
||||
|
38
packages/app/src/Tasks/NoticeZapPool.tsx
Normal file
38
packages/app/src/Tasks/NoticeZapPool.tsx
Normal file
@ -0,0 +1,38 @@
|
||||
import { FormattedMessage, FormattedNumber } from "react-intl";
|
||||
import { Link } from "react-router-dom";
|
||||
import { BaseUITask } from "Tasks";
|
||||
|
||||
export class NoticeZapPoolDefault extends BaseUITask {
|
||||
id = "zap-pool-default";
|
||||
|
||||
check(): boolean {
|
||||
return !this.state.muted && CONFIG.defaultZapPoolFee !== undefined;
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<>
|
||||
<p>
|
||||
<FormattedMessage
|
||||
defaultMessage="A default Zap Pool split of {n} has been configured for {site} developers, you can disable it at any time in {link}"
|
||||
values={{
|
||||
site: CONFIG.appNameCapitalized,
|
||||
n: (
|
||||
<FormattedNumber
|
||||
value={(CONFIG.defaultZapPoolFee ?? 0) / 100}
|
||||
style="percent"
|
||||
maximumFractionDigits={2}
|
||||
/>
|
||||
),
|
||||
link: (
|
||||
<Link to="/zap-pool">
|
||||
<FormattedMessage defaultMessage="Zap Pool" />
|
||||
</Link>
|
||||
),
|
||||
}}
|
||||
/>
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
3
packages/app/src/Tasks/TaskList.css
Normal file
3
packages/app/src/Tasks/TaskList.css
Normal file
@ -0,0 +1,3 @@
|
||||
.task-list a {
|
||||
text-decoration: underline;
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
import "./TaskList.css";
|
||||
import { useState } from "react";
|
||||
import { useUserProfile } from "@snort/system-react";
|
||||
|
||||
@ -7,8 +8,9 @@ import { UITask } from "Tasks";
|
||||
import { DonateTask } from "./DonateTask";
|
||||
import { Nip5Task } from "./Nip5Task";
|
||||
import { RenewSubTask } from "./RenewSubscription";
|
||||
import { NoticeZapPoolDefault } from "./NoticeZapPool";
|
||||
|
||||
const AllTasks: Array<UITask> = [new Nip5Task(), new DonateTask()];
|
||||
const AllTasks: Array<UITask> = [new Nip5Task(), new DonateTask(), new NoticeZapPoolDefault()];
|
||||
if (CONFIG.features.subscriptions) {
|
||||
AllTasks.push(new RenewSubTask());
|
||||
}
|
||||
@ -25,7 +27,7 @@ export const TaskList = () => {
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="task-list">
|
||||
{AllTasks.filter(a => (user ? a.check(user, session) : false)).map(a => {
|
||||
return (
|
||||
<div key={a.id} className="card">
|
||||
@ -39,6 +41,6 @@ export const TaskList = () => {
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
@ -2,7 +2,8 @@ import { UserCache } from "Cache";
|
||||
import { LNURL, ExternalStore, unixNow } from "@snort/shared";
|
||||
import { Toastore } from "Toaster";
|
||||
import { LNWallet, WalletInvoiceState, Wallets } from "Wallet";
|
||||
import { getDisplayName } from "SnortUtils";
|
||||
import { bech32ToHex, getDisplayName } from "SnortUtils";
|
||||
import { SnortPubKey } from "Const";
|
||||
|
||||
export enum ZapPoolRecipientType {
|
||||
Generic = 0,
|
||||
@ -103,10 +104,11 @@ class ZapPool extends ExternalStore<Array<ZapPoolRecipient>> {
|
||||
this.notifyChange();
|
||||
}
|
||||
|
||||
getOrDefault(rcpt: ZapPoolRecipient) {
|
||||
getOrDefault(rcpt: ZapPoolRecipient): ZapPoolRecipient {
|
||||
const k = this.#key(rcpt);
|
||||
if (this.#store.has(k)) {
|
||||
return { ...this.#store.get(k) };
|
||||
const existing = this.#store.get(k);
|
||||
if (existing) {
|
||||
return { ...existing };
|
||||
}
|
||||
return rcpt;
|
||||
}
|
||||
@ -137,6 +139,18 @@ class ZapPool extends ExternalStore<Array<ZapPoolRecipient>> {
|
||||
if (existing) {
|
||||
const arr = JSON.parse(existing) as Array<ZapPoolRecipient>;
|
||||
this.#store = new Map(arr.map(a => [`${a.pubkey}-${a.type}`, a]));
|
||||
} else if (CONFIG.defaultZapPoolFee) {
|
||||
this.#store = new Map([
|
||||
[
|
||||
`${bech32ToHex(SnortPubKey)}-${ZapPoolRecipientType.Generic}`,
|
||||
{
|
||||
type: ZapPoolRecipientType.Generic,
|
||||
split: CONFIG.defaultZapPoolFee,
|
||||
pubkey: bech32ToHex(SnortPubKey),
|
||||
sum: 0,
|
||||
},
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
const lastPayout = self.localStorage.getItem("zap-pool-last-payout");
|
||||
|
@ -1068,6 +1068,9 @@
|
||||
"deEeEI": {
|
||||
"defaultMessage": "Register"
|
||||
},
|
||||
"dmsiLv": {
|
||||
"defaultMessage": "A default Zap Pool split of {n} has been configured for {site} developers, you can disable it at any time in {link}"
|
||||
},
|
||||
"e61Jf3": {
|
||||
"defaultMessage": "Coming soon"
|
||||
},
|
||||
|
@ -349,6 +349,7 @@
|
||||
"d7d0/x": "LN Address",
|
||||
"dOQCL8": "Display name",
|
||||
"deEeEI": "Register",
|
||||
"dmsiLv": "A default Zap Pool split of {n} has been configured for {site} developers, you can disable it at any time in {link}",
|
||||
"e61Jf3": "Coming soon",
|
||||
"e7VmYP": "Enter pin to unlock your private key",
|
||||
"e7qqly": "Mark All Read",
|
||||
|
Loading…
x
Reference in New Issue
Block a user