mirror of
https://github.com/coracle-social/flotilla.git
synced 2025-12-10 02:47:06 +00:00
Debounce search
This commit is contained in:
@@ -643,7 +643,7 @@ export const getBlossomServer = async (options: GetBlossomServerOptions = {}) =>
|
||||
}
|
||||
}
|
||||
|
||||
const userUrls = getTagValues("server", getListTags(userBlossomServerList.get()))
|
||||
const userUrls = getTagValues("server", getListTags(get(userBlossomServerList)))
|
||||
|
||||
for (const url of userUrls) {
|
||||
return normalizeBlossomUrl(url)
|
||||
|
||||
@@ -14,7 +14,6 @@ import {
|
||||
sortBy,
|
||||
append,
|
||||
sort,
|
||||
prop,
|
||||
uniq,
|
||||
indexBy,
|
||||
partition,
|
||||
@@ -308,10 +307,7 @@ export const loadSettings = makeLoadItem(
|
||||
getSettings,
|
||||
)
|
||||
|
||||
export const userSettings = makeUserData({
|
||||
mapStore: settingsByPubkey,
|
||||
loadItem: loadSettings,
|
||||
})
|
||||
export const userSettings = makeUserData(settingsByPubkey, loadSettings)
|
||||
|
||||
export const loadUserSettings = makeUserLoader(loadSettings)
|
||||
|
||||
@@ -610,10 +606,7 @@ export const getSpaceRoomsFromGroupList = (url: string, groupList: List | undefi
|
||||
return sortBy(roomComparator(url), rooms)
|
||||
}
|
||||
|
||||
export const userGroupList = makeUserData({
|
||||
mapStore: groupListsByPubkey,
|
||||
loadItem: loadGroupList,
|
||||
})
|
||||
export const userGroupList = makeUserData(groupListsByPubkey, loadGroupList)
|
||||
|
||||
export const loadUserGroupList = makeUserLoader(loadGroupList)
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@ import {
|
||||
profiles,
|
||||
searchProfiles,
|
||||
handlesByNip05,
|
||||
maxWot,
|
||||
wotGraph,
|
||||
getMaxWot,
|
||||
getWotGraph,
|
||||
} from "@welshman/app"
|
||||
import type {FileAttributes} from "@welshman/editor"
|
||||
import {Editor, MentionSuggestion, WelshmanExtension} from "@welshman/editor"
|
||||
@@ -62,10 +62,10 @@ export const makeEditor = async ({
|
||||
onSearch: searchProfiles,
|
||||
getValue: (profile: PublishedProfile) => profile.event.pubkey,
|
||||
sortFn: ({score = 1, item}) => {
|
||||
const wotScore = wotGraph.get().get(item.event.pubkey) || 0
|
||||
const wotScore = getWotGraph().get(item.event.pubkey) || 0
|
||||
const membershipScale = $spaceMembers.includes(item.event.pubkey) ? 2 : 1
|
||||
|
||||
return dec(score) * inc(wotScore / maxWot.get()) * membershipScale
|
||||
return dec(score) * inc(wotScore / getMaxWot()) * membershipScale
|
||||
},
|
||||
fuseOptions: {
|
||||
keys: [
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import {onMount} from "svelte"
|
||||
import {debounce} from "throttle-debounce"
|
||||
import {createScroller, isMobile} from "@lib/html"
|
||||
import {profileSearch} from "@welshman/app"
|
||||
import Magnifier from "@assets/icons/magnifier.svg?dataurl"
|
||||
@@ -11,9 +12,18 @@
|
||||
|
||||
let term = $state("")
|
||||
let limit = $state(10)
|
||||
let pubkeys = $state($bootstrapPubkeys)
|
||||
let element: Element | undefined = $state()
|
||||
|
||||
const pubkeys = $derived(term ? $profileSearch.searchValues(term) : $bootstrapPubkeys)
|
||||
const search = debounce(200, (term: string) => {
|
||||
if (term) {
|
||||
pubkeys = $profileSearch.searchValues(term)
|
||||
} else {
|
||||
pubkeys = $bootstrapPubkeys
|
||||
}
|
||||
})
|
||||
|
||||
$effect(() => search(term))
|
||||
|
||||
onMount(() => {
|
||||
const scroller = createScroller({
|
||||
|
||||
Reference in New Issue
Block a user