feat: init public notes
This commit is contained in:
13
src/modules/atproto/getAka.ts
Normal file
13
src/modules/atproto/getAka.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export const getAka = async (dids: Set<string>) => {
|
||||
const correspondance = await Promise.all(
|
||||
[...dids].map(async (did) => {
|
||||
const response = await fetch(`https://plc.directory/${did}`)
|
||||
const {
|
||||
alsoKnownAs: [aka],
|
||||
} = await response.json()
|
||||
return [did, aka] as [string, string]
|
||||
}),
|
||||
)
|
||||
|
||||
return new Map(correspondance)
|
||||
}
|
||||
@@ -1,7 +1,19 @@
|
||||
import { DataType } from '@/data/DataType.enum'
|
||||
import { Model } from '@/data/models/Model'
|
||||
import { DataType } from "@/data/DataType.enum"
|
||||
import { Model } from "@/data/models/Model"
|
||||
|
||||
export interface Note extends Model<DataType.Note> {
|
||||
content: string
|
||||
editedSha?: string
|
||||
}
|
||||
|
||||
export interface PublicNoteListItem {
|
||||
did: string
|
||||
rkey: string
|
||||
title: string
|
||||
publishedAt: string
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export interface PublicNote extends PublicNoteListItem {
|
||||
content: string
|
||||
}
|
||||
|
||||
@@ -14,6 +14,11 @@ const routes: Array<RouteRecordRaw> = [
|
||||
props: true,
|
||||
component: () => import("@/views/FluxNoteView.vue"),
|
||||
},
|
||||
{
|
||||
path: "/notes",
|
||||
name: "PublicNoteView",
|
||||
component: () => import("@/views/PublicNoteView.vue"),
|
||||
},
|
||||
{
|
||||
path: "/:user/:repo/share/:note",
|
||||
name: "ShareNotes",
|
||||
|
||||
30
src/views/PublicNoteView.vue
Normal file
30
src/views/PublicNoteView.vue
Normal file
@@ -0,0 +1,30 @@
|
||||
<script setup lang="ts">
|
||||
import { PublicNoteListItem } from "@/modules/note/models/Note"
|
||||
import { useAsyncState } from "@vueuse/core"
|
||||
|
||||
const { state, isLoading } = useAsyncState<{
|
||||
notes: PublicNoteListItem[]
|
||||
}>(
|
||||
async () => {
|
||||
const response = await fetch("https://api.litenote.li212.fr/notes")
|
||||
return response.json()
|
||||
},
|
||||
{ notes: [] },
|
||||
)
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div v-if="isLoading"></div>
|
||||
<div class="public-note-view" v-else>
|
||||
<ul>
|
||||
<li v-for="note in state.notes">
|
||||
{{ note.did }}/{{ note.rkey }}: {{ note.title }}
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.public-note-view {
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user