tangled
alpha
login
or
join now
veryroundbird.house
/
pds-dash
4
fork
atom
pds dash for shimaenaga.veryroundbird.house (based off of pds.witchcraft.systems)
4
fork
atom
overview
issues
pulls
pipelines
add favicons, start adding in guestbook
veryroundbird.house
6 months ago
00cfb58a
d01e878f
+43
-3
2 changed files
expand all
collapse all
unified
split
src
App.svelte
lib
pdsfetch.ts
+10
-2
src/App.svelte
reviewed
···
2
2
import PostComponent from "./lib/PostComponent.svelte";
3
3
import AccountComponent from "./lib/AccountComponent.svelte";
4
4
import InfiniteLoading from "svelte-infinite-loading";
5
5
-
import { getNextPosts, Post, getAllMetadataFromPds } from "./lib/pdsfetch";
5
5
+
import { getNextPosts, Post, getAllMetadataFromPds, fetchGuestbookPosts } from "./lib/pdsfetch";
6
6
import { Config } from "../config";
7
7
const accountsPromise = getAllMetadataFromPds();
8
8
import { onMount } from "svelte";
9
9
10
10
let posts: Post[] = [];
11
11
+
let guestbookPosts: Post[] = [];
11
12
12
13
let hue: number = 1;
13
14
const cycleColors = async () => {
···
34
35
getNextPosts().then((initialPosts) => {
35
36
posts = initialPosts;
36
37
});
38
38
+
fetchGuestbookPosts().then((gbPosts) => {
39
39
+
guestbookPosts = gbPosts;
40
40
+
console.log(gbPosts);
41
41
+
});
37
42
});
38
43
// Infinite loading function
39
44
const onInfinite = ({
···
88
93
<div id="guestbookContents" popover>
89
94
<div id="signInfo">You can sign the guestbook <a href="{Config.GUESTBOOK_POST}" target="_blank">here</a>!</div>
90
95
<div id="guestbookPosts">
91
91
-
96
96
+
{#each guestbookPosts as postObject}
97
97
+
<div class="guestbookPost">
98
98
+
</div>
99
99
+
{/each}
92
100
</div>
93
101
</div>
94
102
</div>
+33
-1
src/lib/pdsfetch.ts
reviewed
···
359
359
}
360
360
};
361
361
362
362
-
export { getAllMetadataFromPds, getNextPosts, Post };
362
362
+
const convertUri = (uri: string) => {
363
363
+
if (uri.startsWith("at://")) {
364
364
+
return uri;
365
365
+
}
366
366
+
367
367
+
if (uri.includes("bsky.app/profile/")) {
368
368
+
const match = uri.match(/profile\/([\w.]+)\/post\/([\w]+)/);
369
369
+
if (match) {
370
370
+
const [, did, postId] = match;
371
371
+
return `at://${did}/app.bsky.feed.post/${postId}` as At.Did;
372
372
+
}
373
373
+
}
374
374
+
375
375
+
this.error = "Invalid Bluesky post URL format";
376
376
+
return null;
377
377
+
}
378
378
+
379
379
+
const fetchGuestbookPosts = async () => {
380
380
+
try {
381
381
+
const { data } = await rpc.get("app.bsky.feed.getPostThread", {
382
382
+
params: {
383
383
+
uri: convertUri(Config.GUESTBOOK_POST)
384
384
+
}
385
385
+
});
386
386
+
387
387
+
return data.records as ComAtprotoRepoListRecords.Record[];
388
388
+
} catch (e) {
389
389
+
console.error(`Error fetching replies for ${did}. Are you sure this is a Bluesky post?`, e);
390
390
+
return null;
391
391
+
}
392
392
+
}
393
393
+
394
394
+
export { getAllMetadataFromPds, getNextPosts, Post, fetchGuestbookPosts };
363
395
export type { AccountMetadata };