From 1f0d17112c81a1d4f0239a49e4fd0f30f77d0be7 Mon Sep 17 00:00:00 2001 From: Kieran Date: Thu, 20 Apr 2023 22:05:11 +0100 Subject: [PATCH] feat: profile only-zaps --- packages/app/src/Element/NoteFooter.tsx | 4 ++-- packages/app/src/Feed/ThreadFeed.ts | 2 +- packages/app/src/Feed/TimelineFeed.ts | 4 +++- packages/app/src/Pages/settings/Profile.tsx | 14 ++++++++++++++ packages/app/src/lang.json | 18 ++++++++++++++++++ packages/app/src/translations/en.json | 8 +++++++- packages/nostr/src/legacy/index.ts | 1 + 7 files changed, 46 insertions(+), 5 deletions(-) diff --git a/packages/app/src/Element/NoteFooter.tsx b/packages/app/src/Element/NoteFooter.tsx index 0bfa1007..9245fd97 100644 --- a/packages/app/src/Element/NoteFooter.tsx +++ b/packages/app/src/Element/NoteFooter.tsx @@ -264,7 +264,7 @@ export default function NoteFooter(props: NoteFooterProps) { } function reactionIcons() { - if (!prefs.enableReactions) { + if (!prefs.enableReactions || author?.reactions === false) { return null; } return ( @@ -275,7 +275,6 @@ export default function NoteFooter(props: NoteFooterProps) {
{formatShort(positive.length)}
- {repostIcon()} ); } @@ -426,6 +425,7 @@ export default function NoteFooter(props: NoteFooterProps) {
{tipButton()} {reactionIcons()} + {repostIcon()}
diff --git a/packages/app/src/Feed/ThreadFeed.ts b/packages/app/src/Feed/ThreadFeed.ts index c2675e99..101c6e20 100644 --- a/packages/app/src/Feed/ThreadFeed.ts +++ b/packages/app/src/Feed/ThreadFeed.ts @@ -22,7 +22,7 @@ export default function useThreadFeed(link: NostrLink) { .kinds( pref.enableReactions ? [EventKind.Reaction, EventKind.TextNote, EventKind.Repost, EventKind.ZapReceipt] - : [EventKind.TextNote, EventKind.ZapReceipt] + : [EventKind.TextNote, EventKind.ZapReceipt, EventKind.Repost] ) .tag("e", allEvents); diff --git a/packages/app/src/Feed/TimelineFeed.ts b/packages/app/src/Feed/TimelineFeed.ts index 847a0024..fe1845ca 100644 --- a/packages/app/src/Feed/TimelineFeed.ts +++ b/packages/app/src/Feed/TimelineFeed.ts @@ -128,7 +128,9 @@ export default function useTimelineFeed(subject: TimelineSubject, options: Timel if (trackingEvents.length > 0) { rb.withFilter() .kinds( - pref.enableReactions ? [EventKind.Reaction, EventKind.Repost, EventKind.ZapReceipt] : [EventKind.ZapReceipt] + pref.enableReactions + ? [EventKind.Reaction, EventKind.Repost, EventKind.ZapReceipt] + : [EventKind.ZapReceipt, EventKind.Repost] ) .tag("e", trackingEvents); } diff --git a/packages/app/src/Pages/settings/Profile.tsx b/packages/app/src/Pages/settings/Profile.tsx index 44605e33..b797eab3 100644 --- a/packages/app/src/Pages/settings/Profile.tsx +++ b/packages/app/src/Pages/settings/Profile.tsx @@ -36,6 +36,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) { const [website, setWebsite] = useState(); const [nip05, setNip05] = useState(); const [lud16, setLud16] = useState(); + const [reactions, setReactions] = useState(); const avatarPicture = (picture?.length ?? 0) === 0 ? Nostrich : picture; @@ -49,6 +50,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) { setWebsite(user.website); setNip05(user.nip05); setLud16(user.lud16); + setReactions(user.reactions); } }, [user]); @@ -64,6 +66,7 @@ export default function ProfileSettings(props: ProfileSettingsProps) { website, nip05, lud16, + reactions, } as Record; delete userCopy["loaded"]; delete userCopy["created"]; @@ -166,6 +169,17 @@ export default function ProfileSettings(props: ProfileSettingsProps) { setLud16(e.target.value)} />
+
+
+ : + + + +
+
+ setReactions(!e.target.checked)} /> +
+
diff --git a/packages/app/src/lang.json b/packages/app/src/lang.json index 134af5c7..500c8bcd 100644 --- a/packages/app/src/lang.json +++ b/packages/app/src/lang.json @@ -5,6 +5,9 @@ "+aZY2h": { "defaultMessage": "Zap Type" }, + "+vA//S": { + "defaultMessage": "Logins" + }, "+vIQlC": { "defaultMessage": "Please make sure to save the following password in order to manage your handle in the future" }, @@ -304,12 +307,18 @@ "EnCOBJ": { "defaultMessage": "Buy" }, + "EqRgFp": { + "defaultMessage": "Some clients will only allow zaps on your notes" + }, "Eqjl5K": { "defaultMessage": "Only Snort and our integration partner identifier gives you a colorful domain name, but you are welcome to use other services too." }, "F+B3x1": { "defaultMessage": "We have also partnered with nostrplebs.com to give you more options" }, + "F3l7xL": { + "defaultMessage": "Add Account" + }, "FDguSC": { "defaultMessage": "{n} Zaps" }, @@ -334,6 +343,9 @@ "FpxElY": { "defaultMessage": "Verification" }, + "FvanT6": { + "defaultMessage": "Accounts" + }, "G/yZLu": { "defaultMessage": "Remove" }, @@ -913,6 +925,9 @@ "mfe8RW": { "defaultMessage": "Option: {n}" }, + "n1Whvj": { + "defaultMessage": "Switch" + }, "nDejmx": { "defaultMessage": "Unblock" }, @@ -1053,6 +1068,9 @@ "ut+2Cd": { "defaultMessage": "Get a partner identifier" }, + "v48Uwm": { + "defaultMessage": "OnlyZaps" + }, "vOKedj": { "defaultMessage": "{n,plural,=1{& {n} other} other{& {n} others}}" }, diff --git a/packages/app/src/translations/en.json b/packages/app/src/translations/en.json index d41ce8de..93bcfc3d 100644 --- a/packages/app/src/translations/en.json +++ b/packages/app/src/translations/en.json @@ -1,6 +1,7 @@ { "+D82kt": "Are you sure you want to repost: {id}", "+aZY2h": "Zap Type", + "+vA//S": "Logins", "+vIQlC": "Please make sure to save the following password in order to manage your handle in the future", "+vVZ/G": "Connect", "/4tOwT": "Skip", @@ -99,8 +100,10 @@ "Ebl/B2": "Translate to {lang}", "EcglP9": "Key", "EnCOBJ": "Buy", + "EqRgFp": "Some clients will only allow zaps on your notes", "Eqjl5K": "Only Snort and our integration partner identifier gives you a colorful domain name, but you are welcome to use other services too.", "F+B3x1": "We have also partnered with nostrplebs.com to give you more options", + "F3l7xL": "Add Account", "FDguSC": "{n} Zaps", "FP+D3H": "LNURL to forward zaps to", "FS3b54": "Done!", @@ -109,6 +112,7 @@ "FfYsOb": "An error has occured!", "FmXUJg": "follows you", "FpxElY": "Verification", + "FvanT6": "Accounts", "G/yZLu": "Remove", "G1BGCg": "Select Wallet", "GFOoEE": "Salt", @@ -299,6 +303,7 @@ "mKhgP9": "{n,plural,=0{} =1{zapped} other{zapped}}", "mLcajD": "Snort Subscription", "mfe8RW": "Option: {n}", + "n1Whvj": "Switch", "nDejmx": "Unblock", "nGBrvw": "Bookmarks", "nN9XTz": "Share your thoughts with {link}", @@ -345,6 +350,7 @@ "uSV4Ti": "Reposts need to be manually confirmed", "usAvMr": "Edit Profile", "ut+2Cd": "Get a partner identifier", + "v48Uwm": "OnlyZaps", "vOKedj": "{n,plural,=1{& {n} other} other{& {n} others}}", "vU71Ez": "Paying with {wallet}", "vZ4quW": "NIP-05 is a DNS based verification spec which helps to validate you as a real user.", @@ -377,4 +383,4 @@ "zjJZBd": "You're ready!", "zonsdq": "Failed to load LNURL service", "zvCDao": "Automatically show latest notes" -} +} \ No newline at end of file diff --git a/packages/nostr/src/legacy/index.ts b/packages/nostr/src/legacy/index.ts index 61f9af03..3c512cf5 100644 --- a/packages/nostr/src/legacy/index.ts +++ b/packages/nostr/src/legacy/index.ts @@ -70,6 +70,7 @@ export type UserMetadata = { nip05?: string; lud06?: string; lud16?: string; + reactions?: boolean; }; /**