tangled
alpha
login
or
join now
retr0.id
/
pdsls
forked from
pds.ls/pdsls
1
fork
atom
atproto explorer
1
fork
atom
overview
issues
pulls
pipelines
backlinks API types
juli.ee
5 months ago
a96fd57b
13dd9973
verified
This commit was signed with the committer's
known signature
.
juli.ee
SSH Key Fingerprint:
SHA256:mBrT4x0JdzLpbVR95g1hjI1aaErfC02kmLRkPXwsYCk=
+30
-8
2 changed files
expand all
collapse all
unified
split
src
components
backlinks.tsx
utils
api.ts
+12
-6
src/components/backlinks.tsx
···
1
1
import * as TID from "@atcute/tid";
2
2
import { createResource, createSignal, For, onMount, Show } from "solid-js";
3
3
-
import { getAllBacklinks, getDidBacklinks, getRecordBacklinks } from "../utils/api.js";
3
3
+
import {
4
4
+
getAllBacklinks,
5
5
+
getDidBacklinks,
6
6
+
getRecordBacklinks,
7
7
+
LinksWithDids,
8
8
+
LinksWithRecords,
9
9
+
} from "../utils/api.js";
4
10
import { localDateFromTimestamp } from "../utils/date.js";
5
11
import { Button } from "./button.jsx";
6
12
···
128
134
dids: boolean;
129
135
cursor?: string;
130
136
}) => {
131
131
-
const [links, setLinks] = createSignal<any>();
137
137
+
const [links, setLinks] = createSignal<LinksWithDids | LinksWithRecords>();
132
138
const [more, setMore] = createSignal<boolean>(false);
133
139
134
140
onMount(async () => {
···
147
153
return (
148
154
<Show when={links()} fallback={<p>Loading…</p>}>
149
155
<Show when={dids}>
150
150
-
<For each={links().linking_dids}>
156
156
+
<For each={(links() as LinksWithDids).linking_dids}>
151
157
{(did) => (
152
158
<a
153
159
href={`/at://${did}`}
···
159
165
</For>
160
166
</Show>
161
167
<Show when={!dids}>
162
162
-
<For each={links().linking_records}>
168
168
+
<For each={(links() as LinksWithRecords).linking_records}>
163
169
{({ did, collection, rkey }) => (
164
170
<p class="relative flex w-full items-center gap-1 font-mono">
165
171
<a
···
177
183
)}
178
184
</For>
179
185
</Show>
180
180
-
<Show when={links().cursor}>
186
186
+
<Show when={links()?.cursor}>
181
187
<Show when={more()} fallback={<Button onClick={() => setMore(true)}>Load More</Button>}>
182
188
<BacklinkItems
183
189
target={target}
184
190
collection={collection}
185
191
path={path}
186
192
dids={dids}
187
187
-
cursor={links().cursor}
193
193
+
cursor={links()!.cursor}
188
194
/>
189
195
</Show>
190
196
</Show>
+18
-2
src/utils/api.ts
···
119
119
};
120
120
}
121
121
122
122
+
type LinksWithRecords = {
123
123
+
cursor: string;
124
124
+
total: number;
125
125
+
linking_records: Array<{ did: string; collection: string; rkey: string }>;
126
126
+
};
127
127
+
128
128
+
type LinksWithDids = {
129
129
+
cursor: string;
130
130
+
total: number;
131
131
+
linking_dids: Array<string>;
132
132
+
};
133
133
+
122
134
const getConstellation = async (
123
135
endpoint: string,
124
136
target: string,
···
152
164
path: string,
153
165
cursor?: string,
154
166
limit?: number,
155
155
-
) => getConstellation("/links", target, collection, path, cursor, limit || 100);
167
167
+
): Promise<LinksWithRecords> =>
168
168
+
getConstellation("/links", target, collection, path, cursor, limit || 100);
156
169
157
170
const getDidBacklinks = (
158
171
target: string,
···
160
173
path: string,
161
174
cursor?: string,
162
175
limit?: number,
163
163
-
) => getConstellation("/links/distinct-dids", target, collection, path, cursor, limit || 100);
176
176
+
): Promise<LinksWithDids> =>
177
177
+
getConstellation("/links/distinct-dids", target, collection, path, cursor, limit || 100);
164
178
165
179
export {
166
180
didDocCache,
···
175
189
resolvePDS,
176
190
validateHandle,
177
191
type LinkData,
192
192
+
type LinksWithDids,
193
193
+
type LinksWithRecords,
178
194
};