forked from pdsls.dev/pdsls
this repo has no description

add reverse to listRecords

Changed files
+25 -13
src
+25 -13
src/views/collection.tsx
··· 1 1 import { createEffect, createResource, createSignal, For, Show, untrack } from "solid-js"; 2 2 import { CredentialManager, Client } from "@atcute/client"; 3 - import { A, query, useParams } from "@solidjs/router"; 3 + import { A, useParams } from "@solidjs/router"; 4 4 import { resolvePDS } from "../utils/api.js"; 5 5 import * as TID from "@atcute/tid"; 6 6 import { JSONType, JSONValue } from "../components/json.jsx"; ··· 70 70 const [filter, setFilter] = createSignal<string>(); 71 71 const [batchDelete, setBatchDelete] = createSignal(false); 72 72 const [lastSelected, setLastSelected] = createSignal<number>(); 73 + const [reverse, setReverse] = createSignal(false); 73 74 const did = params.repo; 74 75 let pds: string; 75 76 let rpc: Client; 76 77 77 - const listRecords = query( 78 - (did: string, collection: string, cursor: string | undefined) => 79 - rpc.get("com.atproto.repo.listRecords", { 80 - params: { 81 - repo: did as ActorIdentifier, 82 - collection: collection as `${string}.${string}.${string}`, 83 - limit: LIMIT, 84 - cursor: cursor, 85 - }, 86 - }), 87 - "listRecords", 88 - ); 78 + const listRecords = (did: string, collection: string, cursor: string | undefined) => 79 + rpc.get("com.atproto.repo.listRecords", { 80 + params: { 81 + repo: did as ActorIdentifier, 82 + collection: collection as `${string}.${string}.${string}`, 83 + limit: LIMIT, 84 + cursor: cursor, 85 + reverse: reverse(), 86 + }, 87 + }); 89 88 90 89 const fetchRecords = async () => { 91 90 if (!pds) pds = await resolvePDS(did); ··· 233 232 /> 234 233 </div> 235 234 <div class="flex items-center gap-x-2"> 235 + <label class="flex select-none items-center gap-x-1"> 236 + <input 237 + type="checkbox" 238 + checked={reverse()} 239 + onchange={async (e) => { 240 + setReverse(e.currentTarget.checked); 241 + setRecords([]); 242 + setCursor(undefined); 243 + await fetchRecords(); 244 + }} 245 + /> 246 + Reverse 247 + </label> 236 248 <div> 237 249 <Show when={batchDelete()}> 238 250 <span>{records.filter((rec) => rec.toDelete).length}</span>