|
1 | 1 | <template> |
2 | | - <div class="flex w-full h-full px-8 max-w-screen-lg"> |
3 | | - <Sidebar /> |
4 | | - <router-view></router-view> |
5 | | - </div> |
| 2 | + <ul v-infinite-scroll="load" class="infinite-list flex-1" style="overflow: auto"> |
| 3 | + <li class="flex text-4xl font-bold my-5 py-4">Home</li> |
| 4 | + <li v-for="(_, index) in Array(5)" :key="index" v-show="loading"> |
| 5 | + <el-skeleton animated> |
| 6 | + <template #template> |
| 7 | + <el-card class="relative border-0" shadow="never"> |
| 8 | + <div class="flex flex-row"> |
| 9 | + <el-skeleton-item variant="circle" class="w-10 h-10 mr-3"></el-skeleton-item> |
| 10 | + <div class="flex-1"> |
| 11 | + <el-skeleton-item variant="p" class="w-64"></el-skeleton-item> |
| 12 | + <el-skeleton-item variant="p" class="h-9 w-96"></el-skeleton-item> |
| 13 | + </div> |
| 14 | + </div> |
| 15 | + </el-card> |
| 16 | + </template> |
| 17 | + </el-skeleton> |
| 18 | + </li> |
| 19 | + <li v-for="note in notes" :key="note.id"> |
| 20 | + <Note :note="note" :character="character" /> |
| 21 | + </li> |
| 22 | + <li v-if="!loading && notes.length === 0"> |
| 23 | + <p class="text-center text-gray-500"> |
| 24 | + <span class="align-middle">No notes yet... Try to </span> |
| 25 | + <el-button class="align-middle" text bg type="primary" @click="tweet">sync a tweet</el-button> |
| 26 | + </p> |
| 27 | + </li> |
| 28 | + </ul> |
6 | 29 | </template> |
7 | 30 |
|
8 | 31 | <script setup lang="ts"> |
9 | | -import Sidebar from '@/components/Sidebar.vue'; |
| 32 | +import { ref } from 'vue'; |
| 33 | +import { useRouter } from 'vue-router'; |
| 34 | +import { useStore } from '@/common/store'; |
| 35 | +import Note from '@/components/Notes.vue'; |
| 36 | +import type { Note as TypeNote } from 'unidata.js'; |
| 37 | +
|
| 38 | +const router = useRouter(); |
| 39 | +const store = useStore(); |
| 40 | +
|
| 41 | +const notes = ref<TypeNote[]>([]); |
| 42 | +const loading = ref(true); |
| 43 | +
|
| 44 | +if (store.state.settings.address) { |
| 45 | + if (!store.state.characters?.list.length) { |
| 46 | + router.push('/mint'); |
| 47 | + } else if (!store.state.settings.handle) { |
| 48 | + router.push('/characters'); |
| 49 | + } |
| 50 | +} else { |
| 51 | + router.push('/'); |
| 52 | +} |
| 53 | +
|
| 54 | +let cursor: any; |
| 55 | +let first = true; |
| 56 | +const load = async () => { |
| 57 | + if (cursor || first) { |
| 58 | + first = false; |
| 59 | + const result = await window.unidata.notes.get({ |
| 60 | + identity: store.state.settings.handle!, |
| 61 | + platform: 'Crossbell', |
| 62 | + source: 'Crossbell Note', |
| 63 | + ...(store.state.settings.notesShowCSSCOnly && { |
| 64 | + filter: { |
| 65 | + applications: ['CrossSync'], |
| 66 | + }, |
| 67 | + }), |
| 68 | + cursor, |
| 69 | + }); |
| 70 | + notes.value = notes.value.concat(result?.list || []); |
| 71 | + cursor = result?.cursor; |
| 72 | + loading.value = false; |
| 73 | + } |
| 74 | +}; |
| 75 | +
|
| 76 | +load(); |
| 77 | +
|
| 78 | +const character = |
| 79 | + store.state.characters!.list.find((character) => character.username === store.state.settings.handle) || |
| 80 | + store.state.characters!.list[0]; // As a fallback, use the first character |
| 81 | +
|
| 82 | +const tweet = () => { |
| 83 | + const text = encodeURIComponent( |
| 84 | + `#OwnMyTweets I'm proudly syncing my Tweet to blockchain and truly owning my tweet!`, |
| 85 | + ); |
| 86 | + window.open(`https://twitter.com/compose/tweet`); |
| 87 | +}; |
10 | 88 | </script> |
11 | 89 |
|
12 | 90 | <style></style> |
0 commit comments