Remove Fluent, Tags

This commit is contained in:
Jon Staab
2024-12-13 15:18:33 -08:00
parent 6235c3f6bb
commit 760d6d07cd
7 changed files with 14 additions and 258 deletions
+4 -4
View File
@@ -1,6 +1,6 @@
import {uniq, identity, flatten, pushToMapKey, intersection, tryCatch, now} from '@welshman/lib'
import type {TrustedEvent, Filter} from '@welshman/util'
import {Tags, intersectFilters, matchFilter, getAddress, getIdFilters, unionFilters} from '@welshman/util'
import {intersectFilters, matchFilter, getAddress, getIdFilters, unionFilters} from '@welshman/util'
import type {CreatedAtItem, RequestItem, ListItem, LabelItem, WOTItem, DVMItem, Scope, Feed, FeedOptions} from './core'
import {getFeedArgs, feedsFromTags} from './utils'
import {FeedType} from './core'
@@ -110,7 +110,7 @@ export class FeedCompiler {
this.options.requestDVM({
...request,
onEvent: async (e: TrustedEvent) => {
const tags = Tags.wrap(await tryCatch(() => JSON.parse(e.content)) || [])
const tags = await tryCatch(() => JSON.parse(e.content)) || []
for (const feed of feedsFromTags(tags, mappings)) {
feeds.push(feed)
@@ -231,7 +231,7 @@ export class FeedCompiler {
const event = eventsByAddress.get(address)
if (event) {
for (const feed of feedsFromTags(Tags.fromEvent(event), mappings)) {
for (const feed of feedsFromTags(event.tags, mappings)) {
feeds.push(feed)
}
}
@@ -271,7 +271,7 @@ export class FeedCompiler {
}
}
return feedsFromTags(Tags.wrap(tags), mappings)
return feedsFromTags(tags, mappings)
})
)
)
+5 -7
View File
@@ -1,6 +1,6 @@
import {ensureNumber} from '@welshman/lib'
import type {Filter} from '@welshman/util'
import {Tags} from '@welshman/util'
import {getTagValues} from '@welshman/util'
import {
FeedType,
Feed,
@@ -110,15 +110,13 @@ export const defaultTagFeedMappings: TagFeedMapping[] = [
['t', [FeedType.Tag, '#t']],
]
export const feedsFromTags = (tags: Tags, mappings?: TagFeedMapping[]) => {
export const feedsFromTags = (tags: string[][], mappings?: TagFeedMapping[]) => {
const feeds = []
for (const [tagName, templateFeed] of mappings || defaultTagFeedMappings) {
const filterTags = tags.whereKey(tagName)
if (filterTags.exists()) {
let values: string[] | number[] = filterTags.values().valueOf()
let values: any[] = getTagValues(tagName, tags)
if (values.length > 0) {
if (isKindFeed(templateFeed)) {
values = values.map(ensureNumber) as number[]
}
@@ -130,7 +128,7 @@ export const feedsFromTags = (tags: Tags, mappings?: TagFeedMapping[]) => {
return feeds
}
export const feedFromTags = (tags: Tags, mappings?: TagFeedMapping[]) =>
export const feedFromTags = (tags: string[][], mappings?: TagFeedMapping[]) =>
makeIntersectionFeed(...feedsFromTags(tags, mappings))
export const feedsFromFilter = ({since, until, ...filter}: Filter) => {