fast insert

This commit is contained in:
Shusui MOYATANI
2023-06-18 12:22:17 +09:00
parent 7f0343fcfa
commit eb276cc0a6

View File

@@ -1,6 +1,7 @@
import { createSignal, createEffect, onMount, onCleanup, on } from 'solid-js';
import uniqBy from 'lodash/uniqBy';
import { utils } from 'nostr-tools';
import useConfig from '@/core/useConfig';
import usePool from '@/nostr/usePool';
@@ -64,7 +65,7 @@ const useSubscription = (propsProvider: () => UseSubscriptionProps | null) => {
const limit = propsProvider()?.limit ?? 50;
setEvents((current) => {
const sorted = sortEvents([event, ...current].slice(0, limit));
const sorted = utils.insertEventIntoDescendingList(current, event).slice(0, limit);
// FIXME なぜか重複して取得される問題があるが一旦uniqByで対処
// https://github.com/syusui-s/rabbit/issues/5
const deduped = uniqBy(sorted, (e) => e.id);