@estiva-app/interop 0.100.0 → 0.101.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/loadQuery.d.ts.map +1 -1
- package/dist/loadQuery.js +64 -0
- package/dist/loadQuery.js.map +1 -1
- package/dist/projection.d.ts +8 -0
- package/dist/projection.d.ts.map +1 -1
- package/dist/projection.js +6 -4
- package/dist/projection.js.map +1 -1
- package/dist/yourTopics.d.ts.map +1 -1
- package/dist/yourTopics.js +35 -28
- package/dist/yourTopics.js.map +1 -1
- package/package.json +1 -1
- package/src/loadQuery.ts +72 -0
- package/src/projection.ts +14 -4
- package/src/yourTopics.ts +32 -27
package/dist/yourTopics.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yourTopics.d.ts","sourceRoot":"","sources":["../src/yourTopics.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"yourTopics.d.ts","sourceRoot":"","sources":["../src/yourTopics.ts"],"names":[],"mappings":"AA6BA,OAAO,EAQL,KAAK,eAAe,EACpB,KAAK,OAAO,EACb,MAAM,iBAAiB,CAAA;AACxB,OAAO,EAcL,KAAK,eAAe,EACpB,KAAK,SAAS,EACf,MAAM,aAAa,CAAA;AACpB,OAAO,EAAiD,KAAK,OAAO,EAAE,MAAM,eAAe,CAAA;AAQ3F,sCAAsC;AACtC,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAA;IACV;;;;;;OAMG;IACH,MAAM,EAAE,SAAS,EAAE,CAAA;IACnB,iEAAiE;IACjE,EAAE,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvB,iJAAiJ;IACjJ,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,SAAS,CAAA;CACvC;AAED;;;;;;;;;GASG;AACH,wBAAsB,cAAc,CAClC,KAAK,EAAE,OAAO,EACd,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,eAAe,GAAG;IACzB,OAAO,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAA;IAC5D,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,eAAe,CAAA;IACvB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,kIAAkI;IAClI,KAAK,CAAC,EAAE,OAAO,CAAA;CAChB,GACA,OAAO,CAAC,cAAc,CAAC,CAwFzB"}
|
package/dist/yourTopics.js
CHANGED
|
@@ -9,13 +9,16 @@
|
|
|
9
9
|
*
|
|
10
10
|
* 1. every topic's root, and the viewer's mute list, in one request;
|
|
11
11
|
* 2. the changes naming the viewer on any topic and the team lists naming
|
|
12
|
-
* them
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* them, in one request: whether the viewer is in a topic does not depend on
|
|
13
|
+
* its fields, so this says which topics could be theirs;
|
|
14
|
+
* 3. only those topics' current fields, by the list read (alone: a relay
|
|
15
|
+
* refuses a list read mixed with other filters) — each topic's title,
|
|
16
|
+
* archive and parent come from that answer, and only the topics the viewer
|
|
17
|
+
* is in are read further. Every topic's fields were 0.13 MB of Ship's
|
|
18
|
+
* sidebar on Miky's workspace, 64 topics for the 25 he is in (ALO-22);
|
|
19
|
+
* 4. their listed ids, what the list read skipped and the manifests of their
|
|
17
20
|
* parents, in one request;
|
|
18
|
-
*
|
|
21
|
+
* 5. their parents, a level a request by the list read, to see whether one is
|
|
19
22
|
* archived, while their activity is read.
|
|
20
23
|
*
|
|
21
24
|
* Without the list read (the relay does not advertise it), round 2 reads each
|
|
@@ -56,7 +59,7 @@ export async function readYourTopics(query, me, options) {
|
|
|
56
59
|
const addresses = [...roots.keys()];
|
|
57
60
|
if (addresses.length === 0)
|
|
58
61
|
return { me, topics: [], at: new Map(), muted: await mutedOpened };
|
|
59
|
-
// 2. How the viewer is in each, which are spaces, and each topic's fields.
|
|
62
|
+
// 2. How the viewer is in each, which are spaces, and (without the list read) each topic's fields.
|
|
60
63
|
const second = gathered(query);
|
|
61
64
|
const partRead = readAll(second.query, [changesNamingFilter(me, addresses)]);
|
|
62
65
|
const statesRead = readAll(second.query, teamListFilters(roots));
|
|
@@ -64,32 +67,36 @@ export async function readYourTopics(query, me, options) {
|
|
|
64
67
|
const objectChangesRead = listRead ? Promise.resolve([]) : second.query(addresses.map(plainChangesFilter));
|
|
65
68
|
const listChangesRead = listRead ? Promise.resolve([]) : readAll(second.query, addresses.map(topicListFilter));
|
|
66
69
|
second.send();
|
|
67
|
-
const [part, states,
|
|
68
|
-
partRead,
|
|
69
|
-
statesRead,
|
|
70
|
-
listRead ? newestChanges(query, addresses) : Promise.resolve([]),
|
|
71
|
-
objectChangesRead,
|
|
72
|
-
listChangesRead,
|
|
73
|
-
mutedOpened,
|
|
74
|
-
]);
|
|
70
|
+
const [part, states, objectChanges, listChanges] = await Promise.all([partRead, statesRead, objectChangesRead, listChangesRead]);
|
|
75
71
|
const spaces = spacesOf(states, addresses);
|
|
76
72
|
const byTopic = eventsByTopic(part);
|
|
77
73
|
const facts = { roots, byTopic, states, spaces };
|
|
78
|
-
const
|
|
74
|
+
const inIt = (object) => {
|
|
79
75
|
const topic = readTopicOf(object, me, facts);
|
|
80
|
-
return topic && topic.yours && (options.spaces || !topic.space)
|
|
76
|
+
return topic && topic.yours && (options.spaces || !topic.space) ? topic : undefined;
|
|
81
77
|
};
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
const byList = listRead ? addresses.filter((address) => answered.has(address)) : addresses;
|
|
85
|
-
const objects = projectTopics([...byList.map((address) => roots.get(address)), ...(listRead ? listed : objectChanges)], listRead);
|
|
78
|
+
let objects;
|
|
79
|
+
let listed = [];
|
|
86
80
|
if (listRead) {
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
81
|
+
// 3. Whether the viewer is in a topic does not depend on its fields, so its root alone says which could be theirs:
|
|
82
|
+
// only those are read as their current fields, not every topic in the workspace (ALO-22: 25 of Miky's 64). The
|
|
83
|
+
// mute list is not waited for: muting leaves out a topic below, and decides nothing here.
|
|
84
|
+
const maybe = projectTopics([...roots.values()], false).flatMap((object) => (inIt(object) ? [object.address] : []));
|
|
85
|
+
listed = maybe.length > 0 ? await newestChanges(query, maybe) : [];
|
|
86
|
+
const answered = new Set(topicRoots(listed).keys());
|
|
87
|
+
objects = projectTopics([...maybe.filter((address) => answered.has(address)).map((address) => roots.get(address)), ...listed], true);
|
|
88
|
+
// A topic the list read did not answer (deleted) is read plain, as a parent is.
|
|
89
|
+
const unanswered = maybe.filter((address) => !answered.has(address));
|
|
90
|
+
if (unanswered.length > 0)
|
|
91
|
+
objects.push(...projectTopics([...unanswered.map((address) => roots.get(address)), ...(await query(unanswered.map(plainChangesFilter)))], false));
|
|
92
92
|
}
|
|
93
|
+
else
|
|
94
|
+
objects = projectTopics([...roots.values(), ...objectChanges], false);
|
|
95
|
+
const muted = await mutedOpened;
|
|
96
|
+
const mine = (object) => {
|
|
97
|
+
const topic = inIt(object);
|
|
98
|
+
return topic && !muted?.has(topic.address) ? topic : undefined;
|
|
99
|
+
};
|
|
93
100
|
const candidates = [];
|
|
94
101
|
for (const object of objects) {
|
|
95
102
|
const topic = mine(object);
|
|
@@ -98,7 +105,7 @@ export async function readYourTopics(query, me, options) {
|
|
|
98
105
|
}
|
|
99
106
|
if (candidates.length === 0)
|
|
100
107
|
return { me, topics: [], at: new Map(), muted };
|
|
101
|
-
//
|
|
108
|
+
// 4. Their listed ids, what the list read skipped, and their parents' manifests.
|
|
102
109
|
const asked = candidates.map((topic) => topic.address);
|
|
103
110
|
const listEvents = listRead ? listed : listChanges;
|
|
104
111
|
const plan = listReadPlan(asked, roots, listEvents, listRead);
|
|
@@ -114,7 +121,7 @@ export async function readYourTopics(query, me, options) {
|
|
|
114
121
|
const [resolved, again] = await Promise.all([resolvedRead, againRead, seeded]);
|
|
115
122
|
const lists = listsFrom(asked, roots, [...listEvents, ...again], resolved);
|
|
116
123
|
const topics = candidates.map((topic) => ({ ...topic, listed: lists.get(topic.address) ?? [] }));
|
|
117
|
-
//
|
|
124
|
+
// 5. Their parents, while their activity is read: one archived with a parent is left out after.
|
|
118
125
|
const [activity] = await Promise.all([
|
|
119
126
|
readTopicActivity(query, activityTopics(topics), { nowSeconds: options.nowSeconds, times: options.times }),
|
|
120
127
|
markTopicsArchivedWith(topics.map((topic) => topic.object), query, cache, listRead ? FILE_KINDS : []),
|
package/dist/yourTopics.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"yourTopics.js","sourceRoot":"","sources":["../src/yourTopics.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"yourTopics.js","sourceRoot":"","sources":["../src/yourTopics.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACnF,OAAO,EAAE,UAAU,EAAoB,MAAM,sBAAsB,CAAA;AACnE,OAAO,EACL,gBAAgB,EAChB,qBAAqB,EACrB,UAAU,EACV,sBAAsB,EACtB,aAAa,EACb,aAAa,GAId,MAAM,iBAAiB,CAAA;AACxB,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,aAAa,EACb,YAAY,EACZ,SAAS,EACT,aAAa,EACb,OAAO,EACP,WAAW,EACX,UAAU,EACV,QAAQ,EACR,eAAe,EACf,eAAe,EACf,UAAU,GAGX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,iBAAiB,EAAgB,MAAM,eAAe,CAAA;AAE3F,MAAM,UAAU,GAAG,KAAK,CAAA;AACxB,MAAM,WAAW,GAAG,IAAI,CAAA;AACxB,MAAM,aAAa,GAAG,KAAK,CAAA;AAC3B,sFAAsF;AACtF,MAAM,mB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|
2
2
|
"name": "@estiva-app/interop",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.101.1",
|
|
4
4
|
"description": "Render and act on another app's objects from its published NIP-89 manifest. The owner defines the projection; the consumer decides how it looks.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
package/src/loadQuery.ts
CHANGED
|
@@ -81,6 +81,42 @@ function wholeKindsOf(filter: Filter, paged: boolean): WholeKinds | null {
|
|
|
81
81
|
return { kinds, limit: limit ?? RELAY_PAGE_CEILING }
|
|
82
82
|
}
|
|
83
83
|
|
|
84
|
+
/**
|
|
85
|
+
* SPEC §6.13's list read of files by address, `{ kinds: [kind], authors:
|
|
86
|
+
* [pubkey], '#d': ds, limit, fields: 'newest' }` (with `text: true`, the text
|
|
87
|
+
* too): each `d` answers one file, its first record and its fields' current
|
|
88
|
+
* changes, and `limit` counts first records. So a page with room for every
|
|
89
|
+
* file named holds each one whole, or says it has none (deleted, or not this
|
|
90
|
+
* reader's).
|
|
91
|
+
*/
|
|
92
|
+
interface ListRead {
|
|
93
|
+
kind: number
|
|
94
|
+
author: string
|
|
95
|
+
ds: string[]
|
|
96
|
+
text: boolean
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function listReadOf(filter: Filter): ListRead | null {
|
|
100
|
+
const { kinds, authors, limit, fields, text, ...rest } = filter
|
|
101
|
+
const ds = rest['#d']
|
|
102
|
+
if (Object.keys(rest).length !== 1 || fields !== 'newest' || (text !== undefined && text !== true)) return null
|
|
103
|
+
if (!Array.isArray(kinds) || kinds.length !== 1 || typeof kinds[0] !== 'number') return null
|
|
104
|
+
if (!Array.isArray(authors) || authors.length !== 1 || typeof authors[0] !== 'string') return null
|
|
105
|
+
if (!Array.isArray(ds) || ds.length === 0 || !ds.every((d) => typeof d === 'string')) return null
|
|
106
|
+
const files = new Set(ds).size
|
|
107
|
+
if (typeof limit !== 'number' || limit < files || files > RELAY_PAGE_CEILING) return null
|
|
108
|
+
return { kind: kinds[0], author: authors[0], ds, text: text === true }
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/** A list read's answer for one file: its first record (by `d`) and the changes whose file it is (their first `a`, §6.10). */
|
|
112
|
+
function fileOf(read: ListRead, d: string, answer: SignedEvent[]): SignedEvent[] {
|
|
113
|
+
const address = `${read.kind}:${read.author}:${d}`
|
|
114
|
+
return answer.filter((event) => {
|
|
115
|
+
if (event.kind === read.kind && event.pubkey === read.author) return event.tags.find((tag) => tag[0] === 'd')?.[1] === d
|
|
116
|
+
return event.tags.find((tag) => tag[0] === 'a')?.[1] === address
|
|
117
|
+
})
|
|
118
|
+
}
|
|
119
|
+
|
|
84
120
|
/**
|
|
85
121
|
* The tags a whole read answers a later read by: the ones the relay matches as
|
|
86
122
|
* NIP-01 does, on every kind. Never `h`, which is a Folder's scope on the relay
|
|
@@ -163,6 +199,9 @@ export function createLoadQuery(query: QueryFn, options: LoadQueryOptions = {}):
|
|
|
163
199
|
const known = new Map<string, Held>()
|
|
164
200
|
// Per kind: every event of it, read by a filter naming only kinds.
|
|
165
201
|
const wholes = new Map<number, Held>()
|
|
202
|
+
// Per file a list read asked for, `<text|list>:<kind>:<author>:<d>`: what the relay answered for it (APP-11).
|
|
203
|
+
const files = new Map<string, Promise<SignedEvent[]>>()
|
|
204
|
+
const fileKey = (read: ListRead, d: string) => `${read.text ? 'text' : 'list'}:${read.kind}:${read.author}:${d}`
|
|
166
205
|
const flights = new Map<string, Promise<SignedEvent[]>>()
|
|
167
206
|
|
|
168
207
|
const remember = <K>(memo: Map<K, Held>, key: K, entry: Held) => {
|
|
@@ -192,7 +231,30 @@ export function createLoadQuery(query: QueryFn, options: LoadQueryOptions = {}):
|
|
|
192
231
|
// Answered from a held read; `again` is what to ask if that read's page came back full.
|
|
193
232
|
const joined: { again: Filter; entry: Promise<SignedEvent[] | null> }[] = []
|
|
194
233
|
const joinedByTag: { shape: ByTag; value: string; entry: Promise<SignedEvent[] | null> }[] = []
|
|
234
|
+
const askedFiles: ListRead[] = []
|
|
235
|
+
// A Set, and the files this call asks, so a file two of its filters name is answered and asked once.
|
|
236
|
+
const joinedFiles = new Set<Promise<SignedEvent[]>>()
|
|
237
|
+
const askedHere = new Set<string>()
|
|
195
238
|
for (const filter of filters) {
|
|
239
|
+
// Several Folders list the same files: each is read once per load, the rest of a list read goes on (APP-11).
|
|
240
|
+
const list = listReadOf(filter)
|
|
241
|
+
if (list) {
|
|
242
|
+
const fresh: string[] = []
|
|
243
|
+
for (const d of new Set(list.ds)) {
|
|
244
|
+
const key = fileKey(list, d)
|
|
245
|
+
const held = files.get(key)
|
|
246
|
+
if (held) joinedFiles.add(held)
|
|
247
|
+
else if (!askedHere.has(key)) {
|
|
248
|
+
askedHere.add(key)
|
|
249
|
+
fresh.push(d)
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
if (fresh.length === 0) continue
|
|
253
|
+
// `limit` counts first records: one per file asked.
|
|
254
|
+
send.push({ ...filter, '#d': fresh, limit: fresh.length })
|
|
255
|
+
askedFiles.push({ ...list, ds: fresh })
|
|
256
|
+
continue
|
|
257
|
+
}
|
|
196
258
|
const whole = wholeKindsOf(filter, paged)
|
|
197
259
|
if (whole) {
|
|
198
260
|
const held = whole.kinds.map((kind) => wholes.get(kind))
|
|
@@ -226,6 +288,15 @@ export function createLoadQuery(query: QueryFn, options: LoadQueryOptions = {}):
|
|
|
226
288
|
}
|
|
227
289
|
|
|
228
290
|
const answer = send.length ? ask(send) : Promise.resolve([])
|
|
291
|
+
for (const read of askedFiles) {
|
|
292
|
+
for (const d of read.ds) {
|
|
293
|
+
const key = fileKey(read, d)
|
|
294
|
+
const entry = answer.then((events) => fileOf(read, d, events))
|
|
295
|
+
files.set(key, entry)
|
|
296
|
+
// A refused read is forgotten, so the next ask goes to the relay.
|
|
297
|
+
entry.catch(() => files.get(key) === entry && files.delete(key))
|
|
298
|
+
}
|
|
299
|
+
}
|
|
229
300
|
for (const shape of askedWhole) {
|
|
230
301
|
const split = answer.then((events) => completeWhole(shape, events, paged))
|
|
231
302
|
for (const kind of shape.kinds) {
|
|
@@ -240,6 +311,7 @@ export function createLoadQuery(query: QueryFn, options: LoadQueryOptions = {}):
|
|
|
240
311
|
}
|
|
241
312
|
|
|
242
313
|
const out = [...(await answer)]
|
|
314
|
+
for (const entry of joinedFiles) out.push(...(await entry))
|
|
243
315
|
const again: Filter[] = []
|
|
244
316
|
for (const { again: filter, entry } of joined) {
|
|
245
317
|
const events = await entry
|
package/src/projection.ts
CHANGED
|
@@ -3748,7 +3748,7 @@ export async function resolveForeignObjects(
|
|
|
3748
3748
|
: []
|
|
3749
3749
|
const [read, opened, creatorLists, fileLists] = await Promise.all([
|
|
3750
3750
|
queryChunked(filters, query),
|
|
3751
|
-
openedEvents(plans.map(({ plan }) => plan), query),
|
|
3751
|
+
openedEvents(plans.map(({ plan }) => plan), query, !options.withoutText),
|
|
3752
3752
|
Promise.all(kinds.map((kind) => creatorsOrNone(kind, query, cache))),
|
|
3753
3753
|
Promise.all(folders.map((folder) => folderFilesOf(folder, query, lookupPeople, cache))),
|
|
3754
3754
|
])
|
|
@@ -3794,13 +3794,15 @@ export async function resolveForeignObjects(
|
|
|
3794
3794
|
// it happened to be resolved beside.
|
|
3795
3795
|
const own: People = {}
|
|
3796
3796
|
for (const key of peopleOf(built)) if (key in people) own[key] = people[key]
|
|
3797
|
-
|
|
3797
|
+
const object = withFiles(
|
|
3798
3798
|
withBorrowed(
|
|
3799
3799
|
withPeople(built, own),
|
|
3800
3800
|
borrowedActions(plan.pointer.kind, plan.resolved, creatorsByKind.get(plan.pointer.kind) ?? []),
|
|
3801
3801
|
),
|
|
3802
3802
|
plan.pointer.kind === KIND_CHANNEL_METADATA ? filesByFolder.get(plan.pointer.identifier) : undefined,
|
|
3803
3803
|
)
|
|
3804
|
+
// Opened without its text: what it says was not read, as a list read's (APP-11).
|
|
3805
|
+
results[reference] = options.withoutText && plan.opened ? textUnread([object])[0]! : object
|
|
3804
3806
|
}
|
|
3805
3807
|
return results
|
|
3806
3808
|
}
|
|
@@ -4334,6 +4336,14 @@ export interface ArchiveReadOptions {
|
|
|
4334
4336
|
* card would pay it every time (SHI-13's one request per tick).
|
|
4335
4337
|
*/
|
|
4336
4338
|
archivedWith?: boolean
|
|
4339
|
+
/**
|
|
4340
|
+
* With `openRead`, open each file by the list read (SPEC §6.13) without its
|
|
4341
|
+
* text: its first record and each field's current change, for a list that
|
|
4342
|
+
* draws a file's title, summary and conversation but never what it says.
|
|
4343
|
+
* Each opened file's `prevs.description` reads as unread (`''`), as a list
|
|
4344
|
+
* read's does. The Screener's rows (APP-11: 3.5 MB of text on Miky's Desk).
|
|
4345
|
+
*/
|
|
4346
|
+
withoutText?: boolean
|
|
4337
4347
|
/**
|
|
4338
4348
|
* For a Folder's card: also list the files in it this reader can open, as
|
|
4339
4349
|
* `children` — SPEC §3.2. What its relay-signed `30890` lists, read as
|
|
@@ -4756,7 +4766,7 @@ function planObject(
|
|
|
4756
4766
|
* reader's — has its root and every change read as before, so a deleted file
|
|
4757
4767
|
* still says who deleted it and an unreadable one is still told apart from it.
|
|
4758
4768
|
*/
|
|
4759
|
-
async function openedEvents(plans: readonly ObjectPlan[], query: QueryFn): Promise<SignedEvent[]> {
|
|
4769
|
+
async function openedEvents(plans: readonly ObjectPlan[], query: QueryFn, text = true): Promise<SignedEvent[]> {
|
|
4760
4770
|
const opened = new Map<string, ObjectPlan>()
|
|
4761
4771
|
for (const plan of plans) if (plan.opened) opened.set(plan.address, plan)
|
|
4762
4772
|
if (opened.size === 0) return []
|
|
@@ -4771,7 +4781,7 @@ async function openedEvents(plans: readonly ObjectPlan[], query: QueryFn): Promi
|
|
|
4771
4781
|
for (const { kind, pubkey, identifiers } of groups.values()) {
|
|
4772
4782
|
for (let start = 0; start < identifiers.length; start += RELAY_PAGE_CEILING) {
|
|
4773
4783
|
const chunk = identifiers.slice(start, start + RELAY_PAGE_CEILING)
|
|
4774
|
-
filters.push({ fields: 'newest', kinds: [kind], authors: [pubkey], '#d': chunk, limit: chunk.length, text: true })
|
|
4784
|
+
filters.push({ fields: 'newest', kinds: [kind], authors: [pubkey], '#d': chunk, limit: chunk.length, ...(text ? { text: true } : {}) })
|
|
4775
4785
|
}
|
|
4776
4786
|
}
|
|
4777
4787
|
const answered = await queryChunked(filters, query)
|
package/src/yourTopics.ts
CHANGED
|
@@ -9,13 +9,16 @@
|
|
|
9
9
|
*
|
|
10
10
|
* 1. every topic's root, and the viewer's mute list, in one request;
|
|
11
11
|
* 2. the changes naming the viewer on any topic and the team lists naming
|
|
12
|
-
* them
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* them, in one request: whether the viewer is in a topic does not depend on
|
|
13
|
+
* its fields, so this says which topics could be theirs;
|
|
14
|
+
* 3. only those topics' current fields, by the list read (alone: a relay
|
|
15
|
+
* refuses a list read mixed with other filters) — each topic's title,
|
|
16
|
+
* archive and parent come from that answer, and only the topics the viewer
|
|
17
|
+
* is in are read further. Every topic's fields were 0.13 MB of Ship's
|
|
18
|
+
* sidebar on Miky's workspace, 64 topics for the 25 he is in (ALO-22);
|
|
19
|
+
* 4. their listed ids, what the list read skipped and the manifests of their
|
|
17
20
|
* parents, in one request;
|
|
18
|
-
*
|
|
21
|
+
* 5. their parents, a level a request by the list read, to see whether one is
|
|
19
22
|
* archived, while their activity is read.
|
|
20
23
|
*
|
|
21
24
|
* Without the list read (the relay does not advertise it), round 2 reads each
|
|
@@ -113,7 +116,7 @@ export async function readYourTopics(
|
|
|
113
116
|
const addresses = [...roots.keys()]
|
|
114
117
|
if (addresses.length === 0) return { me, topics: [], at: new Map(), muted: await mutedOpened }
|
|
115
118
|
|
|
116
|
-
// 2. How the viewer is in each, which are spaces, and each topic's fields.
|
|
119
|
+
// 2. How the viewer is in each, which are spaces, and (without the list read) each topic's fields.
|
|
117
120
|
const second = gathered(query)
|
|
118
121
|
const partRead = readAll(second.query, [changesNamingFilter(me, addresses)])
|
|
119
122
|
const statesRead = readAll(second.query, teamListFilters(roots))
|
|
@@ -121,30 +124,32 @@ export async function readYourTopics(
|
|
|
121
124
|
const objectChangesRead = listRead ? Promise.resolve([]) : second.query(addresses.map(plainChangesFilter))
|
|
122
125
|
const listChangesRead = listRead ? Promise.resolve([]) : readAll(second.query, addresses.map(topicListFilter))
|
|
123
126
|
second.send()
|
|
124
|
-
const [part, states,
|
|
125
|
-
partRead,
|
|
126
|
-
statesRead,
|
|
127
|
-
listRead ? newestChanges(query, addresses) : Promise.resolve([]),
|
|
128
|
-
objectChangesRead,
|
|
129
|
-
listChangesRead,
|
|
130
|
-
mutedOpened,
|
|
131
|
-
])
|
|
127
|
+
const [part, states, objectChanges, listChanges] = await Promise.all([partRead, statesRead, objectChangesRead, listChangesRead])
|
|
132
128
|
const spaces = spacesOf(states, addresses)
|
|
133
129
|
const byTopic = eventsByTopic(part)
|
|
134
130
|
const facts = { roots, byTopic, states, spaces }
|
|
135
|
-
const
|
|
131
|
+
const inIt = (object: ForeignObject) => {
|
|
136
132
|
const topic = readTopicOf(object, me, facts)
|
|
137
|
-
return topic && topic.yours && (options.spaces || !topic.space)
|
|
133
|
+
return topic && topic.yours && (options.spaces || !topic.space) ? topic : undefined
|
|
138
134
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const byList = listRead ? addresses.filter((address) => answered.has(address)) : addresses
|
|
142
|
-
const objects = projectTopics([...byList.map((address) => roots.get(address)!), ...(listRead ? listed : objectChanges)], listRead)
|
|
135
|
+
let objects: ForeignObject[]
|
|
136
|
+
let listed: SignedEvent[] = []
|
|
143
137
|
if (listRead) {
|
|
144
|
-
|
|
145
|
-
//
|
|
146
|
-
|
|
147
|
-
|
|
138
|
+
// 3. Whether the viewer is in a topic does not depend on its fields, so its root alone says which could be theirs:
|
|
139
|
+
// only those are read as their current fields, not every topic in the workspace (ALO-22: 25 of Miky's 64). The
|
|
140
|
+
// mute list is not waited for: muting leaves out a topic below, and decides nothing here.
|
|
141
|
+
const maybe = projectTopics([...roots.values()], false).flatMap((object) => (inIt(object) ? [object.address!] : []))
|
|
142
|
+
listed = maybe.length > 0 ? await newestChanges(query, maybe) : []
|
|
143
|
+
const answered = new Set(topicRoots(listed).keys())
|
|
144
|
+
objects = projectTopics([...maybe.filter((address) => answered.has(address)).map((address) => roots.get(address)!), ...listed], true)
|
|
145
|
+
// A topic the list read did not answer (deleted) is read plain, as a parent is.
|
|
146
|
+
const unanswered = maybe.filter((address) => !answered.has(address))
|
|
147
|
+
if (unanswered.length > 0) objects.push(...projectTopics([...unanswered.map((address) => roots.get(address)!), ...(await query(unanswered.map(plainChangesFilter)))], false))
|
|
148
|
+
} else objects = projectTopics([...roots.values(), ...objectChanges], false)
|
|
149
|
+
const muted = await mutedOpened
|
|
150
|
+
const mine = (object: ForeignObject) => {
|
|
151
|
+
const topic = inIt(object)
|
|
152
|
+
return topic && !muted?.has(topic.address) ? topic : undefined
|
|
148
153
|
}
|
|
149
154
|
const candidates: Omit<ReadTopic, 'listed'>[] = []
|
|
150
155
|
for (const object of objects) {
|
|
@@ -153,7 +158,7 @@ export async function readYourTopics(
|
|
|
153
158
|
}
|
|
154
159
|
if (candidates.length === 0) return { me, topics: [], at: new Map(), muted }
|
|
155
160
|
|
|
156
|
-
//
|
|
161
|
+
// 4. Their listed ids, what the list read skipped, and their parents' manifests.
|
|
157
162
|
const asked = candidates.map((topic) => topic.address)
|
|
158
163
|
const listEvents = listRead ? listed : listChanges
|
|
159
164
|
const plan = listReadPlan(asked, roots, listEvents, listRead)
|
|
@@ -170,7 +175,7 @@ export async function readYourTopics(
|
|
|
170
175
|
const lists = listsFrom(asked, roots, [...listEvents, ...again], resolved)
|
|
171
176
|
const topics: ReadTopic[] = candidates.map((topic) => ({ ...topic, listed: lists.get(topic.address) ?? [] }))
|
|
172
177
|
|
|
173
|
-
//
|
|
178
|
+
// 5. Their parents, while their activity is read: one archived with a parent is left out after.
|
|
174
179
|
const [activity] = await Promise.all([
|
|
175
180
|
readTopicActivity(query, activityTopics(topics), { nowSeconds: options.nowSeconds, times: options.times }),
|
|
176
181
|
markTopicsArchivedWith(
|