feat: disable SSR

This commit is contained in:
Anthony Fu 2022-11-23 07:08:36 +08:00
parent e59b3e5db2
commit a6578155ae
29 changed files with 109 additions and 175 deletions

View file

@ -1,5 +1,5 @@
<script setup lang="ts">
import type { Account, MastoClient } from 'masto'
import type { Account } from 'masto'
const { account } = defineProps<{
account: Account
@ -7,11 +7,8 @@ const { account } = defineProps<{
const relationship = $(useRelationship(account))
let masto: MastoClient
async function toggleFollow() {
relationship!.following = !relationship!.following
masto ??= await useMasto()
await masto.accounts[relationship!.following ? 'follow' : 'unfollow'](account.id)
}
</script>

View file

@ -1,7 +1,5 @@
<script setup lang="ts">
const { currentUser } = $(useClientState())
const account = $computed(() => currentUser?.account)
const account = $computed(() => currentUser.value?.account)
</script>
<template>

View file

@ -1,5 +1,3 @@
import type { Emoji } from 'masto'
export default defineComponent({
props: {
content: {
@ -8,15 +6,11 @@ export default defineComponent({
},
},
setup(props) {
const emojis = shallowRef<Record<string, Emoji>>({})
onMounted(() => {
const { server } = useAppCookies()
const { serverInfos } = useClientState()
if (server.value)
emojis.value = serverInfos.value[server.value].customEmojis || {}
})
return () => h('div', { class: 'rich-content' }, contentToVNode(props.content, undefined, emojis.value))
const serverInfos = useServerInfo(currentServer.value)
return () => h(
'div',
{ class: 'rich-content' },
contentToVNode(props.content, undefined, serverInfos.value?.customEmojis),
)
},
})

View file

@ -1,10 +1,9 @@
<script setup lang="ts">
const isLogin = useLoginState()
</script>
<template>
<div px6 py2 flex="~ col gap6" text-lg>
<template v-if="isLogin">
<template v-if="currentUser">
<NuxtLink flex gap2 items-center to="/home" active-class="text-primary">
<div i-ri:home-5-line />
<span>Home</span>
@ -26,7 +25,7 @@ const isLogin = useLoginState()
<div i-ri:earth-line />
<span>Federated</span>
</NuxtLink>
<template v-if="isLogin">
<template v-if="currentUser">
<NuxtLink flex gap2 items-center to="/conversations" active-class="text-primary">
<div i-ri:at-line />
<span>Conversations</span>

View file

@ -11,8 +11,6 @@ const {
inReplyToId?: string
}>()
const masto = await useMasto()
let isSending = $ref(false)
const storageKey = `nuxtodon-draft-${draftKey}`
function getDefaultStatus(): CreateStatusParamsWithStatus {

View file

@ -5,8 +5,6 @@ const { status } = defineProps<{
status: Status
}>()
const masto = await useMasto()
// Use different states to let the user press different actions right after the other
const isLoading = $ref({ reblogged: false, favourited: false, bookmarked: false })
async function toggleStatusAction(action: 'reblogged' | 'favourited' | 'bookmarked', newStatus: Promise<Status>) {