implement utility functions, reactive list updates
This commit is contained in:
parent
299b29adcd
commit
9a3819293c
7 changed files with 74 additions and 45 deletions
|
|
@ -1,14 +1,2 @@
|
|||
import { CredentialManager, XRPC } from '@atcute/client';
|
||||
import type { LayoutLoad } from './$types';
|
||||
|
||||
export const prerender = true;
|
||||
export const trailingSlash = 'always';
|
||||
|
||||
export const load: LayoutLoad = async () => {
|
||||
const manager = new CredentialManager({ service: 'https://bsky.social' });
|
||||
const rpc = new XRPC({ handler: manager });
|
||||
await manager.login({ identifier: 'm.woach.me', password: 'c5sj-oyqa-uxhx-ju45' });
|
||||
return {
|
||||
rpc
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,7 +1,4 @@
|
|||
<script>
|
||||
import List from "$lib/components/list.svelte";
|
||||
</script>
|
||||
|
||||
<h1>Home Page</h1>
|
||||
<List did="test" />
|
||||
|
||||
|
|
|
|||
|
|
@ -3,12 +3,8 @@
|
|||
import type { PageProps } from './$types';
|
||||
|
||||
let { data }: PageProps = $props();
|
||||
|
||||
|
||||
</script>
|
||||
<h1>{data.userData.handle}</h1>
|
||||
<h2>{data.userData.did}</h2>
|
||||
|
||||
<List sessions={data.userData.sessions}/>
|
||||
|
||||
<h1>{data.handle}</h1>
|
||||
|
||||
<List sessions={data.sessions} />
|
||||
|
|
|
|||
|
|
@ -1,33 +1,17 @@
|
|||
import type { ComAtprotoRepoListRecords, MeWoachFeedSession } from '@atcute/client/lexicons'; // Import the type
|
||||
import { createRPC, getSessions, resolveHandle } from '$lib/util';
|
||||
import type { ComAtprotoRepoListRecords, MeWoachFeedSession } from '@atcute/client/lexicons';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ parent, params }) => {
|
||||
const { rpc } = await parent();
|
||||
export const load: PageLoad = async ({ params }) => {
|
||||
const did = await resolveHandle(params.handle);
|
||||
const rpc = await createRPC(did);
|
||||
|
||||
const { data: userData } = await rpc.get('com.atproto.identity.resolveHandle', {
|
||||
params: {
|
||||
handle: params.handle
|
||||
}
|
||||
});
|
||||
|
||||
const {
|
||||
data: { records }
|
||||
} = await rpc.get('com.atproto.repo.listRecords', {
|
||||
params: {
|
||||
repo: userData.did,
|
||||
collection: 'me.woach.feed.session'
|
||||
}
|
||||
});
|
||||
|
||||
const sessionsValues: MeWoachFeedSession.Record[] = records.map(
|
||||
const sessions: MeWoachFeedSession.Record[] = (await getSessions(rpc, did)).map(
|
||||
(record: ComAtprotoRepoListRecords.Record) => record.value as MeWoachFeedSession.Record
|
||||
);
|
||||
|
||||
return {
|
||||
userData: {
|
||||
handle: params.handle,
|
||||
did: userData.did,
|
||||
sessions: sessionsValues
|
||||
}
|
||||
handle: params.handle,
|
||||
sessions: sessions
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue