forked from coracle/flotilla
Bump welshman
This commit is contained in:
+6
-6
@@ -1,11 +1,11 @@
|
||||
import type {Unsubscriber} from "svelte/store"
|
||||
import {sleep, partition, assoc, now, sortBy} from "@welshman/lib"
|
||||
import {sleep, partition, assoc, now} from "@welshman/lib"
|
||||
import {MESSAGE, DELETE, THREAD, COMMENT} from "@welshman/util"
|
||||
import type {SubscribeRequestWithHandlers, Subscription} from "@welshman/net"
|
||||
import {SubscriptionEvent} from "@welshman/net"
|
||||
import type {AppSyncOpts} from "@welshman/app"
|
||||
import {subscribe, load, pull, repository, hasNegentropy} from "@welshman/app"
|
||||
import {userRoomsByUrl, LEGACY_MESSAGE, GENERAL} from "@app/state"
|
||||
import {subscribe, load, pull, hasNegentropy} from "@welshman/app"
|
||||
import {userRoomsByUrl, LEGACY_MESSAGE, GENERAL, getEventsForUrl} from "@app/state"
|
||||
|
||||
// Utils
|
||||
|
||||
@@ -15,14 +15,14 @@ export const pullConservatively = ({relays, filters}: AppSyncOpts) => {
|
||||
|
||||
// Since pulling from relays without negentropy is expensive, limit how many
|
||||
// duplicates we repeatedly download
|
||||
if (dumb.length > 0) {
|
||||
const events = sortBy(e => -e.created_at, repository.query(filters))
|
||||
for (const url of dumb) {
|
||||
const events = getEventsForUrl(url, filters)
|
||||
|
||||
if (events.length > 100) {
|
||||
filters = filters.map(assoc("since", events[10]!.created_at))
|
||||
}
|
||||
|
||||
promises.push(pull({relays: dumb, filters}))
|
||||
promises.push(pull({relays: [url], filters}))
|
||||
}
|
||||
|
||||
return Promise.all(promises)
|
||||
|
||||
@@ -251,6 +251,16 @@ export const getUrlsForEvent = derived([trackerStore, thunks], ([$tracker, $thun
|
||||
}
|
||||
})
|
||||
|
||||
export const getEventsForUrl = (url: string, filters: Filter[]) => {
|
||||
const $getUrlsForEvent = get(getUrlsForEvent)
|
||||
const $events = repository.query(filters)
|
||||
|
||||
return sortBy(
|
||||
e => -e.created_at,
|
||||
$events.filter(e => $getUrlsForEvent(e.id).includes(url)),
|
||||
)
|
||||
}
|
||||
|
||||
export const deriveEventsForUrl = (url: string, filters: Filter[]) =>
|
||||
derived([deriveEvents(repository, {filters}), getUrlsForEvent], ([$events, $getUrlsForEvent]) =>
|
||||
sortBy(
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<script lang="ts">
|
||||
import {throttle} from "throttle-debounce"
|
||||
import {type Instance} from "tippy.js"
|
||||
import type {NativeEmoji} from "emoji-picker-element/shared"
|
||||
import {between} from "@welshman/lib"
|
||||
import {between, throttle} from "@welshman/lib"
|
||||
import Button from "@lib/components/Button.svelte"
|
||||
import Tippy from "@lib/components/Tippy.svelte"
|
||||
import EmojiPicker from "@lib/components/EmojiPicker.svelte"
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<svelte:options accessors />
|
||||
|
||||
<script lang="ts">
|
||||
import {throttle} from "throttle-debounce"
|
||||
import {fly, slide} from "svelte/transition"
|
||||
import {clamp} from "@welshman/lib"
|
||||
import {clamp, throttle} from "@welshman/lib"
|
||||
import Icon from "@lib/components/Icon.svelte"
|
||||
import {theme} from "@app/theme"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user