diff --git a/.env b/.env index 9b861961..c0e3342b 100644 --- a/.env +++ b/.env @@ -2,5 +2,6 @@ VITE_THEME_DARK=transparent:transparent,black:#0f0f0e,white:#FFFFFF,accent:#EB5E VITE_THEME_LIGHT=transparent:transparent,black:#0f0f0e,white:#FFFFFF,accent:#EB5E28,accent-light:#FB652C,gray-8:#FFFFFF,gray-7:#FAF6F1,gray-6:#F2EBE1,gray-5:#B3AA98,gray-4:#B3AA98,gray-3:#565249,gray-2:#393530,gray-1:#252422,danger:#ff0000,warning:#ebd112,success:#37ab51,input:#FAF6F1,input-hover:#F2EBE1 VITE_DUFFLEPUD_URL=https://dufflepud.onrender.com VITE_DEFAULT_FOLLOWS=97c70a44366a6535c145b333f973ea86dfdc2d7a99da618c40c64705ad98e322,3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d,82341f882b6eabcd2ba7f1ef90aad961cf074af15b9ef44a09f9d2a8fbfbe6a2,6e468422dfb74a5738702a8823b9b28168abab8655faacb6853cd0ee15deee93 +VITE_ENABLE_ZAPS=true VITE_FORCE_RELAYS= VITE_LOGO_URL= diff --git a/src/agent/network.ts b/src/agent/network.ts index 51a6cfaf..8ad4d67f 100644 --- a/src/agent/network.ts +++ b/src/agent/network.ts @@ -15,6 +15,7 @@ import { import {personKinds, appDataKeys, findReplyId} from "src/util/nostr" import {chunk, ensurePlural} from "hurdak/lib/hurdak" import {batch, now, timedelta} from "src/util/misc" +import {enableZaps} from "src/agent/settings" import { getRelaysForEventParent, getAllPubkeyWriteRelays, @@ -252,6 +253,7 @@ const loadParents = (notes, opts = {}) => { const streamContext = ({notes, onChunk, maxDepth = 2}) => { const subs = [] const seen = new Set() + const kinds = enableZaps ? [1, 7, 9735] : [1, 7] const relays = sampleRelays(aggregateScores(notes.map(getRelaysForEventChildren))) const loadChunk = (events, depth) => { @@ -274,7 +276,7 @@ const streamContext = ({notes, onChunk, maxDepth = 2}) => { subs.push( listen({ relays, - filter: [{kinds: [1, 7, 9735], "#e": ids, since: now()}], + filter: [{kinds, "#e": ids, since: now()}], onChunk: newEvents => { onChunk(newEvents) @@ -296,7 +298,7 @@ const streamContext = ({notes, onChunk, maxDepth = 2}) => { chunk(256, newIds).forEach(ids => { load({ relays, - filter: [{kinds: [1, 7, 9735], "#e": ids}], + filter: [{kinds, "#e": ids}], onChunk: newEvents => { onChunk(newEvents) diff --git a/src/agent/settings.ts b/src/agent/settings.ts new file mode 100644 index 00000000..364e1fc5 --- /dev/null +++ b/src/agent/settings.ts @@ -0,0 +1 @@ +export const enableZaps = JSON.parse(import.meta.env.VITE_ENABLE_ZAPS) diff --git a/src/app/shared/NoteActions.svelte b/src/app/shared/NoteActions.svelte index 3e9d6988..0e8a5264 100644 --- a/src/app/shared/NoteActions.svelte +++ b/src/app/shared/NoteActions.svelte @@ -15,6 +15,7 @@ import CopyValue from "src/partials/CopyValue.svelte" import PersonBadge from "src/app/shared/PersonBadge.svelte" import RelayCard from "src/app/shared/RelayCard.svelte" + import {enableZaps} from "src/agent/settings" import {getEventPublishRelays} from "src/agent/relays" import {getPersonWithFallback} from "src/agent/db" import pool from "src/agent/pool" @@ -126,16 +127,18 @@ })} /> {$likesCount} - + {#if enableZaps} + + {/if}
{#if pool.forceUrls.length === 0} diff --git a/src/app/state.ts b/src/app/state.ts index eff88f73..82aa72be 100644 --- a/src/app/state.ts +++ b/src/app/state.ts @@ -13,6 +13,7 @@ import {Tags, isNotification, userKinds} from "src/util/nostr" import {findReplyId} from "src/util/nostr" import {modal, toast} from "src/partials/state" import {notifications, watch, userEvents, contacts, rooms} from "src/agent/db" +import {enableZaps} from "src/agent/settings" import keys from "src/agent/keys" import network from "src/agent/network" import pool from "src/agent/pool" @@ -168,6 +169,7 @@ export const listen = async () => { const pubkey = user.getPubkey() const {roomsJoined} = user.getProfile() const since = now() - timedelta(30, "days") + const kinds = enableZaps ? [1, 4, 7, 9735] : [1, 4, 7] const eventIds = doPipe(userEvents.all({kind: 1, created_at: {$gt: since}}), [ sortBy(e => -e.created_at), slice(0, 256), @@ -180,8 +182,8 @@ export const listen = async () => { relays: getUserReadRelays(), filter: [ {kinds: [1, 4], authors: [pubkey], since}, - {kinds: [1, 7, 4, 9735], "#p": [pubkey], since}, - {kinds: [1, 7, 4, 9735], "#e": eventIds, since}, + {kinds, "#p": [pubkey], since}, + {kinds, "#e": eventIds, since}, {kinds: [42], "#e": roomsJoined, since}, ], onChunk: async events => {