From 57656c513e72646c4b55fd44b1ff2cdc96624c3f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Fri, 9 Oct 2026 08:36:12 -0700 Subject: Feeds: Everything and Follows + lists are no longer built-in chips; any custom feed can be one. The editor gains "Everyone on my lists and packs" (the people of all your other feeds and packs, read fresh each time the feed opens) and "Posts from anyone on hashtags I follow" (your topic feeds' tags and your kind-10015 interests, OR'd in beside the feed's people, or the whole feed when it has no people). The editor reads a feed as saved, never expanded, so the lists don't get copied into it Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01MgAFLnkF7KrdhuyCLMNgtL --- src/features/messages.js | 70 ++++++++++++++++++++++++++++++++++-------------- src/i18n.js | 5 ++-- 2 files changed, 53 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/features/messages.js b/src/features/messages.js index 59133dc..3a65725 100644 --- a/src/features/messages.js +++ b/src/features/messages.js @@ -442,9 +442,9 @@ export function messagesFeature(ctx) { // A feed added, edited or deleted here goes out on the next sync. let feedsPush = null; const feedsChanged = () => { - // Everything and Follows + lists are built from the other feeds: a - // changed list rebuilds them next time they're opened - for (const id of [MIX, FOLLOWS_LISTS]) { const c = feedStates.get(id); if (c && c !== feed) feedStates.delete(id); } + // a feed that takes in your lists is built from the other feeds: a + // changed list rebuilds it next time it's opened + for (const f of st().feeds) if (expands(f)) { const c = feedStates.get(f.id); if (c && c !== feed) feedStates.delete(f.id); } clearTimeout(feedsPush); feedsPush = setTimeout(() => { try { wallet.saveCache(); } catch {} }, 1000); }; @@ -4735,11 +4735,12 @@ export function messagesFeature(ctx) { // relay carries. Each remembers its own relay choice in the state. const EVERYTHING = 'all'; // Amethyst's feed model, for the people who asked: everyone you follow plus - // everyone on your lists, and on top of that ("Everything") posts from - // anyone on a hashtag you follow — your topic feeds' tags and your NIP-51 - // interests (kind 10015). Built from your feeds each time, never stored; - // offered once there's something beyond your follows to add. - const MIX = 'mix', FOLLOWS_LISTS = 'follows-lists', INTERESTS_KIND = 10015; + // everyone on your lists, and on top of that posts from anyone on a + // hashtag you follow — your topic feeds' tags and your NIP-51 interests + // (kind 10015). Not chips of their own: a custom feed ticks "everyone on + // my lists" (f.lists) and/or "hashtags I follow" (f.interests), and is + // expanded from your other feeds each time it's read, never stored so. + const INTERESTS_KIND = 10015; const INTERESTS = 'interests'; // feature state: { tags, at } from your kind 10015 function listsUnion() { const authors = new Set(), priv = new Set(), packs = new Map(); @@ -4760,20 +4761,38 @@ export function messagesFeature(ctx) { out.delete(''); return [...out].slice(0, 30); } + const expands = (f) => !!f && (!!f.lists || !!f.interests); + function expandFeed(f) { + if (!expands(f) || f.all) return f; + const out = { ...f }; + if (f.lists) { + const u = listsUnion(); + out.authors = [...new Set([...(f.authors || []), ...u.authors])]; + out.priv = [...new Set([...(f.priv || []), ...u.priv])]; + const packs = new Map((f.packs || []).map((p) => [packKey(p), p])); + for (const p of u.packs) packs.set(packKey(p), p); + out.packs = [...packs.values()]; + } + if (f.interests) { + const tags = followedTopics(); + // nobody to read: the hashtags ARE the feed (posts from anyone on them) + const people = out.follows || (out.authors || []).length || (out.priv || []).length || (out.packs || []).length; + if (people) out.orTopics = tags; + else out.topics = [...new Set([...(f.topics || []), ...tags])]; + } + return out; + } const feedList = () => { const br = st().builtinRelays || {}; - const lists = listsUnion(), orTopics = followedTopics(); - const hasLists = lists.authors.length || lists.priv.length || lists.packs.length; return [ - ...(hasLists || orTopics.length ? [{ id: MIX, name: t('feedMixName'), follows: true, ...lists, orTopics, builtin: true, relays: br[MIX] || [] }] : []), - ...(hasLists && orTopics.length ? [{ id: FOLLOWS_LISTS, name: t('feedFollowsListsName'), follows: true, ...lists, builtin: true, relays: br[FOLLOWS_LISTS] || [] }] : []), { id: FOLLOWING, name: t('feedFollowingName'), follows: true, builtin: true, relays: br[FOLLOWING] || [] }, { id: EVERYTHING, name: t('feedPopular'), follows: false, authors: [], packs: [], topics: [], all: true, curated: true, builtin: true, relays: oldPopularDefault(br[EVERYTHING]) ? [] : br[EVERYTHING] || [] }, - ...st().feeds]; + ...st().feeds.map(expandFeed)]; }; function feedDef(id = curFeedId) { - if (id === FOLLOWING || id === EVERYTHING || id === MIX || id === FOLLOWS_LISTS) return feedList().find((f) => f.id === id) || null; - return st().feeds.find((f) => f.id === id) || adhocFeeds.get(id) || null; + if (id === FOLLOWING || id === EVERYTHING) return feedList().find((f) => f.id === id) || null; + const own = st().feeds.find((f) => f.id === id); + return own ? expandFeed(own) : adhocFeeds.get(id) || null; } const normTopic = (x) => String(x || '').trim().replace(/^#/, '').toLowerCase(); // ---- follow packs (NIP-51 kind 39089, what following.space publishes) --- @@ -5028,7 +5047,7 @@ export function messagesFeature(ctx) { const prev = wallet.loadFeatureState(INTERESTS, {}) || {}; if (!(prev.at >= interest.created_at)) { wallet.saveFeatureState(INTERESTS, { tags: interest.tags.filter((x) => x[0] === 't' && x[1]).map((x) => normTopic(x[1])), at: interest.created_at }); - feedStates.delete(MIX); + for (const f of st().feeds) if (f.interests && feedStates.get(f.id) !== feed) feedStates.delete(f.id); scheduleRepaint(); } } @@ -11217,11 +11236,12 @@ export function messagesFeature(ctx) { // a new feed of people is a list from the start; a feed made before // lists existed stays private until its owner says otherwise const isNew = !def || adhocFeeds.has(def.id); + def = (def && st().feeds.find((f) => f.id === def.id)) || def; // as saved, not expanded ui.feedEdit = def - ? { id: def.id, name: def.name || '', follows: !!def.follows, authors: [...(def.authors || [])], priv: [...(def.priv || [])], packs: [...(def.packs || [])], + ? { id: def.id, name: def.name || '', follows: !!def.follows, lists: !!def.lists, interests: !!def.interests, authors: [...(def.authors || [])], priv: [...(def.priv || [])], packs: [...(def.packs || [])], topics: feedTopics(def).map((x) => '#' + x).join(' '), q: '', rows: null, pq: '', packRows: null, isNew, d: def.d || null, publish: isNew || !!def.d, relays: (def.relays || []).map((r) => r.replace(/^wss:\/\//, '')).join(' '), all: !!def.all && !def.builtin, curated: !!def.curated } - : { id: null, name: '', follows: false, authors: [], priv: [], packs: [], topics: '', q: '', rows: null, pq: '', packRows: null, isNew: true, d: null, publish: true, + : { id: null, name: '', follows: false, lists: false, interests: false, authors: [], priv: [], packs: [], topics: '', q: '', rows: null, pq: '', packRows: null, isNew: true, d: null, publish: true, relays: '', all: false, curated: false }; render(); } @@ -11239,15 +11259,17 @@ export function messagesFeature(ctx) { if (relays.length < words.length) { toast(t('feedRelayBad')); return; } // every post on its relays: a firehose needs the relays, nothing else if (e.all && !relays.length) { toast(t('feedAllNeedsRelays')); return; } - if (!e.all && !e.follows && !e.authors.length && !e.packs.length && !topics.length) { toast(t('feedNoQuery')); return; } + if (!e.all && !e.follows && !e.lists && !e.interests && !e.authors.length && !e.packs.length && !topics.length) { toast(t('feedNoQuery')); return; } const name = e.name.trim().slice(0, 40) || (e.all ? relays[0].replace(/^wss:\/\//, '') : topics.length ? '#' + topics[0] : t('feedNewName')); const s = st(); const keep = e.id && !adhocFeeds.has(e.id) && s.feeds.some((f) => f.id === e.id); const id = keep ? e.id : 'f' + Date.now().toString(36) + Math.random().toString(36).slice(2, 6); const def = e.all ? { id, name, follows: false, authors: [], packs: [], topics: [], all: true, curated: !!e.curated, relays, at: Date.now() } - : { id, name, follows: e.follows, authors: e.authors.slice(0, FEED_AUTHORS_MAX), packs: e.packs.slice(0, 20), topics, relays, all: false, curated: false, at: Date.now() }; + : { id, name, follows: e.follows, lists: !!e.lists, interests: !!e.interests, authors: e.authors.slice(0, FEED_AUTHORS_MAX), packs: e.packs.slice(0, 20), topics, relays, all: false, curated: false, at: Date.now() }; if (!relays.length) delete def.relays; + if (!def.lists) delete def.lists; + if (!def.interests) delete def.interests; const prev = keep ? s.feeds.find((f) => f.id === id) : null; // d, listAt, listContent and priv ride along from the previous copy if (keep) s.feeds = s.feeds.map((f) => (f.id === id ? { ...f, ...def } : f)); else s.feeds.push(def); @@ -11365,6 +11387,9 @@ export function messagesFeature(ctx) { h('label', { class: 'row gap6', style: 'align-items:center;cursor:pointer' }, h('input', { type: 'checkbox', checked: e.follows, style: 'width:18px;height:18px;accent-color:var(--accent);margin:0', onChange: (ev) => { e.follows = ev.target.checked; render(); } }), h('span', {}, t('feedFollowsToggle'))), + h('label', { class: 'row gap6', style: 'align-items:center;cursor:pointer' }, + h('input', { type: 'checkbox', class: 'feed-lists-toggle', checked: !!e.lists, style: 'width:18px;height:18px;accent-color:var(--accent);margin:0', onChange: (ev) => { e.lists = ev.target.checked; } }), + h('span', {}, t('feedListsToggle'))), ...e.authors.map(person), // a list's private members, kept where they were made ...(e.priv || []).map((pk) => h('div', { class: 'row gap6', style: 'align-items:center', title: t('feedPrivateMember') }, @@ -11401,6 +11426,11 @@ export function messagesFeature(ctx) { h('span', { class: 'small muted' }, t('feedTopics')), h('input', { type: 'text', value: e.topics, placeholder: t('feedTopicsHint'), autocapitalize: 'none', autocomplete: 'off', onInput: (ev) => { e.topics = ev.target.value; } }), h('div', { class: 'small faint' }, t('feedTopicsHelp'))), + e.all ? null : h('div', { class: 'col', style: 'gap:4px' }, + h('label', { class: 'row gap6', style: 'align-items:center;cursor:pointer' }, + h('input', { type: 'checkbox', class: 'feed-interests-toggle', checked: !!e.interests, style: 'width:18px;height:18px;accent-color:var(--accent);margin:0', onChange: (ev) => { e.interests = ev.target.checked; } }), + h('span', {}, t('feedInterestsToggle'))), + h('div', { class: 'small faint' }, t('feedInterestsHelp'))), // a feed of people is a nostr list (NIP-51 follow set) unless told not to be !e.all && (e.authors.length || (e.priv || []).length || e.d) ? h('div', { class: 'col', style: 'gap:4px' }, diff --git a/src/i18n.js b/src/i18n.js index 6081c2d..e078677 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -272,8 +272,6 @@ const STR = { currencyLabel: 'Show amounts in', feedTitle: 'Feed', feedFollowingName: 'Following', - feedMixName: 'Everything', - feedFollowsListsName: 'Follows + lists', feedNew: 'New feed', feedNewName: 'New feed', feedEdit: 'Edit feed', @@ -281,6 +279,9 @@ const STR = { feedNameHint: 'e.g. Bitcoin builders', feedPeople: 'People', feedFollowsToggle: 'Everyone I follow', + feedListsToggle: 'Everyone on my lists and packs', + feedInterestsToggle: 'Posts from anyone on hashtags I follow', + feedInterestsHelp: 'Your topic feeds\' hashtags and the interests on your nostr profile.', feedAddPerson: 'Add someone…', feedTopics: 'Topics', feedTopicsHint: '#bitcoin #nostr', -- cgit v1.2.3