Add default feed loader to app

This commit is contained in:
Jon Staab
2024-10-09 09:48:08 -07:00
parent cabeba4533
commit 6e24f49384
9 changed files with 112 additions and 7 deletions
+19 -1
View File
@@ -1,6 +1,6 @@
import {throttle} from 'throttle-debounce'
import {derived, writable} from 'svelte/store'
import {addToMapKey, inc, dec} from '@welshman/lib'
import {max, addToMapKey, inc, dec} from '@welshman/lib'
import {getListTags, getPubkeyTagValues} from '@welshman/util'
import {throttled, withGetter} from '@welshman/store'
import {pubkey} from './session'
@@ -13,6 +13,22 @@ export const getFollows = (pubkey: string) =>
export const getMutes = (pubkey: string) =>
getPubkeyTagValues(getListTags(mutesByPubkey.get().get(pubkey)))
export const getNetwork = (pubkey: string) => {
const pubkeys = new Set(getFollows(pubkey))
const network = new Set<string>()
for (const follow of pubkeys) {
for (const tpk of getFollows(follow)) {
if (!pubkeys.has(tpk)) {
network.add(tpk)
}
}
}
return Array.from(network)
}
export const followersByPubkey = withGetter(
derived(
throttled(1000, follows),
@@ -61,6 +77,8 @@ export const getFollowsWhoMute = (pubkey: string, target: string) =>
export const wotGraph = withGetter(writable(new Map<string, number>()))
export const maxWot = withGetter(derived(wotGraph, $g => max(Array.from($g.values()))))
const buildGraph = throttle(1000, () => {
const $pubkey = pubkey.get()
const $graph = new Map<string, number>()