setup types, more intelligent list component implementation example

This commit is contained in:
Badtz 2025-03-28 00:48:42 -07:00
parent b9db27d084
commit 299b29adcd
9 changed files with 65 additions and 14 deletions

View file

@ -7,6 +7,7 @@ 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
};

View file

@ -9,6 +9,6 @@
<h1>{data.userData.handle}</h1>
<h2>{data.userData.did}</h2>
<List did={data.userData.did} rpc={data.rpc}/>
<List sessions={data.userData.sessions}/>

View file

@ -1,3 +1,4 @@
import type { ComAtprotoRepoListRecords, MeWoachFeedSession } from '@atcute/client/lexicons'; // Import the type
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ parent, params }) => {
@ -9,11 +10,24 @@ export const load: PageLoad = async ({ parent, params }) => {
}
});
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(
(record: ComAtprotoRepoListRecords.Record) => record.value as MeWoachFeedSession.Record
);
return {
userData: {
handle: params.handle,
did: userData.did
},
rpc
did: userData.did,
sessions: sessionsValues
}
};
};