Compare commits
No commits in common. "26ab74c3addc49124153cf38aed659b3741ca283" and "ef6c1a0e1810fed04523ff0f2dd1d28e311fca10" have entirely different histories.
26ab74c3ad
...
ef6c1a0e18
7 changed files with 46 additions and 49 deletions
|
|
@ -1,18 +1,17 @@
|
||||||
# wip sveltekit site for anylists
|
# wip sveltekit site for anylists
|
||||||
|
|
||||||
## Setup
|
|
||||||
|
|
||||||
|
## Setup
|
||||||
```bash
|
```bash
|
||||||
bun install # install dependencies
|
bun install # install dependencies
|
||||||
|
|
||||||
bun run types # generate types from: https://winry.woach.me/Spoor/lexicons
|
bun run types # generate types from: https://winry.woach.me/Julia/anylists
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## Developing
|
## Developing
|
||||||
|
|
||||||
start the development server
|
start the development server
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun run dev
|
bun run dev
|
||||||
```
|
```
|
||||||
|
|
@ -26,7 +25,6 @@ bun run build
|
||||||
```
|
```
|
||||||
|
|
||||||
preview the static site with:
|
preview the static site with:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
bun run preview
|
bun run preview
|
||||||
```
|
```
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"client_id": "spoor",
|
"client_id": "woach",
|
||||||
"client_name": "Spoor",
|
"client_name": "Woach",
|
||||||
"client_uri": "https://spoor.my",
|
"client_uri": "https://woach.me",
|
||||||
"redirect_uris": ["https://spoor.my/callback"],
|
"redirect_uris": ["https://woach.me/callback"],
|
||||||
"application_type": "web",
|
"application_type": "web",
|
||||||
"dpop_bound_access_tokens": true,
|
"dpop_bound_access_tokens": true,
|
||||||
"grant_types": [
|
"grant_types": [
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import type {
|
import type {
|
||||||
MySpoorContentExternal,
|
MeWoachContentAnilist,
|
||||||
MySpoorLogActivity,
|
MeWoachFeedActivity,
|
||||||
MySpoorLogSession
|
MeWoachFeedSession
|
||||||
} from '@atcute/client/lexicons';
|
} from '@atcute/client/lexicons';
|
||||||
export let activity: {
|
export let activity: {
|
||||||
session: MySpoorLogSession.Record;
|
session: MeWoachFeedSession.Record;
|
||||||
activity: MySpoorLogActivity.Record;
|
activity: MeWoachFeedActivity.Record;
|
||||||
content: MySpoorContentExternal.Record;
|
content: MeWoachContentAnilist.Main;
|
||||||
}[];
|
}[];
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
@ -17,14 +17,16 @@
|
||||||
{#each activity as activityItem}
|
{#each activity as activityItem}
|
||||||
<li class="mx-auto mb-2 rounded-sm bg-gray-500 p-4">
|
<li class="mx-auto mb-2 rounded-sm bg-gray-500 p-4">
|
||||||
<div>
|
<div>
|
||||||
<p>{activityItem.content.titles}</p>
|
<p>{activityItem.content.id}</p>
|
||||||
<p>
|
<p>
|
||||||
Watched episode {activityItem.activity.progress} at {activityItem.activity.performedAt}
|
Watched episode {activityItem.activity.progress} at {activityItem.activity.performedAt}
|
||||||
</p>
|
</p>
|
||||||
{#if activityItem.session.otherParticipants?.length}
|
{#if activityItem.session.participants?.length}
|
||||||
<p>With:</p>
|
<p>With:</p>
|
||||||
{#each activityItem.session.otherParticipants ?? [] as participant}
|
{#each activityItem.session.participants ?? [] as participant}
|
||||||
<a href={'/user/' + participant.split('at://')[1]}>{participant.split('at://')[1]}</a>
|
<a href={'/user/' + participant.uri.split('at://')[1]}
|
||||||
|
>{participant.uri.split('at://')[1]}</a
|
||||||
|
>
|
||||||
{/each}
|
{/each}
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { addActivity } from '$lib/util';
|
import { addActivity } from '$lib/util';
|
||||||
import type { XRPC } from '@atcute/client';
|
import type { XRPC } from '@atcute/client';
|
||||||
import type { At, MySpoorLogSession } from '@atcute/client/lexicons';
|
import type { At, MeWoachFeedSession } from '@atcute/client/lexicons';
|
||||||
export let sessions: {
|
export let sessions: {
|
||||||
record: MySpoorLogSession.Record;
|
record: MeWoachFeedSession.Record;
|
||||||
uri: string;
|
uri: string;
|
||||||
cid: string;
|
cid: string;
|
||||||
progress: number;
|
progress: number;
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ import {
|
||||||
|
|
||||||
import { configureOAuth } from '@atcute/oauth-browser-client';
|
import { configureOAuth } from '@atcute/oauth-browser-client';
|
||||||
|
|
||||||
import type { At, MySpoorLogActivity } from '@atcute/client/lexicons';
|
import type { At, MeWoachFeedActivity } from '@atcute/client/lexicons';
|
||||||
|
|
||||||
const didDocumentResolver = new CompositeDidDocumentResolver({
|
const didDocumentResolver = new CompositeDidDocumentResolver({
|
||||||
methods: {
|
methods: {
|
||||||
|
|
@ -62,7 +62,7 @@ export async function getSessions(rpc: XRPC, did: string) {
|
||||||
} = await rpc.get('com.atproto.repo.listRecords', {
|
} = await rpc.get('com.atproto.repo.listRecords', {
|
||||||
params: {
|
params: {
|
||||||
repo: did,
|
repo: did,
|
||||||
collection: 'my.spoor.log.session'
|
collection: 'me.woach.feed.session'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return records;
|
return records;
|
||||||
|
|
@ -74,7 +74,7 @@ export async function getActivity(rpc: XRPC, did: string) {
|
||||||
} = await rpc.get('com.atproto.repo.listRecords', {
|
} = await rpc.get('com.atproto.repo.listRecords', {
|
||||||
params: {
|
params: {
|
||||||
repo: did,
|
repo: did,
|
||||||
collection: 'my.spoor.log.activity'
|
collection: 'me.woach.feed.activity'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return records;
|
return records;
|
||||||
|
|
@ -89,7 +89,7 @@ export async function resolveSession(rpc: XRPC, uri: At.Uri) {
|
||||||
params: {
|
params: {
|
||||||
repo,
|
repo,
|
||||||
rkey,
|
rkey,
|
||||||
collection: 'my.spoor.log.session'
|
collection: 'me.woach.feed.session'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return value;
|
return value;
|
||||||
|
|
@ -104,7 +104,7 @@ export async function resolveMedia(rpc: XRPC, uri: At.Uri) {
|
||||||
params: {
|
params: {
|
||||||
repo,
|
repo,
|
||||||
rkey,
|
rkey,
|
||||||
collection: 'my.spoor.content.external'
|
collection: 'me.woach.content.anilist'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return value;
|
return value;
|
||||||
|
|
@ -118,10 +118,10 @@ export async function addActivity(
|
||||||
count: number = 1,
|
count: number = 1,
|
||||||
performedAt: string = new Date().toISOString()
|
performedAt: string = new Date().toISOString()
|
||||||
) {
|
) {
|
||||||
const activityRecord: MySpoorLogActivity.Record = {
|
const activityRecord: MeWoachFeedActivity.Record = {
|
||||||
$type: 'my.spoor.log.activity',
|
$type: 'me.woach.feed.activity',
|
||||||
createdAt: new Date().toISOString(),
|
createdAt: new Date().toISOString(),
|
||||||
progress: { $type: 'my.spoor.log.activity#progressIndex', index: count },
|
progress: count,
|
||||||
session: { cid, uri },
|
session: { cid, uri },
|
||||||
performedAt
|
performedAt
|
||||||
};
|
};
|
||||||
|
|
@ -129,7 +129,7 @@ export async function addActivity(
|
||||||
const result = await rpc.call('com.atproto.repo.createRecord', {
|
const result = await rpc.call('com.atproto.repo.createRecord', {
|
||||||
data: {
|
data: {
|
||||||
repo: did,
|
repo: did,
|
||||||
collection: 'my.spoor.log.activity',
|
collection: 'me.woach.feed.activity',
|
||||||
record: activityRecord
|
record: activityRecord
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -141,18 +141,18 @@ export async function getProgress(rpc: XRPC, did: string, uri: At.Uri) {
|
||||||
const currentProgress = await rpc.get('com.atproto.repo.listRecords', {
|
const currentProgress = await rpc.get('com.atproto.repo.listRecords', {
|
||||||
params: {
|
params: {
|
||||||
repo: did,
|
repo: did,
|
||||||
collection: 'my.spoor.log.activity'
|
collection: 'me.woach.feed.activity'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const filteredRecords = currentProgress.data.records.filter((a) => {
|
const filteredRecords = currentProgress.data.records.filter((a) => {
|
||||||
const record = a.value as MySpoorLogActivity.Record;
|
const record = a.value as MeWoachFeedActivity.Record;
|
||||||
return record.session.uri === uri;
|
return record.session.uri === uri;
|
||||||
});
|
});
|
||||||
|
|
||||||
let lastProgress = 0;
|
let lastProgress = 0;
|
||||||
if (filteredRecords.length > 0) {
|
if (filteredRecords.length > 0) {
|
||||||
const lastUpdate = filteredRecords[0]?.value as MySpoorLogActivity.Record;
|
const lastUpdate = filteredRecords[0]?.value as MeWoachFeedActivity.Record;
|
||||||
lastProgress = Number(lastUpdate.progress);
|
lastProgress = Number(lastUpdate.progress);
|
||||||
|
|
||||||
return lastProgress;
|
return lastProgress;
|
||||||
|
|
|
||||||
|
|
@ -39,12 +39,12 @@
|
||||||
console.log('logout');
|
console.log('logout');
|
||||||
config();
|
config();
|
||||||
try {
|
try {
|
||||||
const session = await getSession(`did:${userState.did}:default`, { allowStale: true });
|
const session = await getSession(`did:${userState.did}`, { allowStale: true });
|
||||||
const agent = new OAuthUserAgent(session);
|
const agent = new OAuthUserAgent(session);
|
||||||
|
|
||||||
await agent.signOut();
|
await agent.signOut();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
deleteStoredSession(`did:${userState.did}:default`);
|
deleteStoredSession(`did:${userState.did}`);
|
||||||
}
|
}
|
||||||
userState.rpc = undefined;
|
userState.rpc = undefined;
|
||||||
userState.agent = undefined;
|
userState.agent = undefined;
|
||||||
|
|
|
||||||
|
|
@ -9,9 +9,9 @@ import {
|
||||||
} from '$lib/util';
|
} from '$lib/util';
|
||||||
import type {
|
import type {
|
||||||
ComAtprotoRepoListRecords,
|
ComAtprotoRepoListRecords,
|
||||||
MySpoorContentExternal,
|
MeWoachContentAnilist,
|
||||||
MySpoorLogActivity,
|
MeWoachFeedActivity,
|
||||||
MySpoorLogSession
|
MeWoachFeedSession
|
||||||
} from '@atcute/client/lexicons';
|
} from '@atcute/client/lexicons';
|
||||||
import type { PageLoad } from './$types';
|
import type { PageLoad } from './$types';
|
||||||
|
|
||||||
|
|
@ -20,13 +20,13 @@ export const load: PageLoad = async ({ params }) => {
|
||||||
const rpc = await createRPC(did);
|
const rpc = await createRPC(did);
|
||||||
|
|
||||||
const sessions: {
|
const sessions: {
|
||||||
record: MySpoorLogSession.Record;
|
record: MeWoachFeedSession.Record;
|
||||||
uri: string;
|
uri: string;
|
||||||
cid: string;
|
cid: string;
|
||||||
progress: number;
|
progress: number;
|
||||||
}[] = await Promise.all(
|
}[] = await Promise.all(
|
||||||
(await getSessions(rpc, did)).map(async (record: ComAtprotoRepoListRecords.Record) => ({
|
(await getSessions(rpc, did)).map(async (record: ComAtprotoRepoListRecords.Record) => ({
|
||||||
record: record.value as MySpoorLogSession.Record,
|
record: record.value as MeWoachFeedSession.Record,
|
||||||
uri: record.uri,
|
uri: record.uri,
|
||||||
cid: record.cid,
|
cid: record.cid,
|
||||||
progress: await getProgress(rpc, did, record.uri)
|
progress: await getProgress(rpc, did, record.uri)
|
||||||
|
|
@ -34,24 +34,21 @@ export const load: PageLoad = async ({ params }) => {
|
||||||
);
|
);
|
||||||
|
|
||||||
const activity: {
|
const activity: {
|
||||||
session: MySpoorLogSession.Record;
|
session: MeWoachFeedSession.Record;
|
||||||
activity: MySpoorLogActivity.Record;
|
activity: MeWoachFeedActivity.Record;
|
||||||
content: MySpoorContentExternal.Record;
|
content: MeWoachContentAnilist.Main;
|
||||||
}[] = await Promise.all(
|
}[] = await Promise.all(
|
||||||
(await getActivity(rpc, did)).map(async (activityRecord: ComAtprotoRepoListRecords.Record) => {
|
(await getActivity(rpc, did)).map(async (activityRecord: ComAtprotoRepoListRecords.Record) => {
|
||||||
const session = (await resolveSession(
|
const session = (await resolveSession(
|
||||||
rpc,
|
rpc,
|
||||||
(activityRecord.value as MySpoorLogActivity.Record).session.uri
|
(activityRecord.value as MeWoachFeedActivity.Record).session.uri
|
||||||
)) as MySpoorLogSession.Record;
|
)) as MeWoachFeedSession.Record;
|
||||||
|
|
||||||
const content = (await resolveMedia(
|
const content = (await resolveMedia(rpc, session.content.uri)) as MeWoachContentAnilist.Main;
|
||||||
rpc,
|
|
||||||
session.content.uri
|
|
||||||
)) as MySpoorContentExternal.Record;
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
session,
|
session,
|
||||||
activity: activityRecord.value as MySpoorLogActivity.Record,
|
activity: activityRecord.value as MeWoachFeedActivity.Record,
|
||||||
content
|
content
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue