import { useI18n } from '@solid-primitives/i18n' import { IconReload } from '@tabler/icons-solidjs' import InfiniteScroll from 'solid-infinite-scroll' import { For, Show, createMemo, createSignal, onMount } from 'solid-js' import { twMerge } from 'tailwind-merge' import { Button } from '~/components' import { formatTimeFromNow, useStringBooleanMap } from '~/helpers' import { useRules } from '~/signals' export default () => { const [t] = useI18n() const { rules, rulesProviders, updateRules, updateAllRuleProvider, updateRuleProviderByName, } = useRules() const [maxRuleRender, setMaxRuleRender] = createSignal(100) const renderRules = createMemo(() => rules().slice(0, maxRuleRender())) onMount(updateRules) const { map: updatingMap, setWithCallback: setUpdatingMap } = useStringBooleanMap() const [allProviderIsUpdating, setAllProviderIsUpdating] = createSignal(false) const onUpdateProviderClick = (e: MouseEvent, name: string) => { e.stopPropagation() void setUpdatingMap(name, () => updateRuleProviderByName(name)) } const onUpdateAllProviderClick = async (e: MouseEvent) => { e.stopPropagation() setAllProviderIsUpdating(true) try { await updateAllRuleProvider() } catch {} setAllProviderIsUpdating(false) } return (