feat: basic publish (#13)

This commit is contained in:
patak 2022-11-17 14:09:54 +01:00 committed by GitHub
parent 0dda5c9b15
commit 787a55bea7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 6 deletions

View file

@ -1,13 +1,17 @@
<script setup lang="ts"> <script setup lang="ts">
const { currentUser } = useAppStore() const { currentUser } = $(useAppStore())
const account = $computed(() => currentUser?.account)
</script> </script>
<template> <template>
<div flex flex-col gap-4 p4> <div flex flex-col gap-4 p4>
<!-- TODO: multiple account switcher --> <!-- TODO: multiple account switcher -->
<AccountInfo v-if="currentUser?.account" :account="currentUser.account" /> <template v-if="account">
<AccountInfo :account="account" />
<PublishWidget />
</template>
<!-- TODO: dialog for select server --> <!-- TODO: dialog for select server -->
<a v-else href="/api/mas.to/login" px2 py1 bg-teal6 text-white m2 rounded>Login</a> <a v-else href="/api/mas.to/login" px2 py1 bg-teal6 text-white m2 rounded>Login</a>
<PublishWidget />
</div> </div>
</template> </template>

View file

@ -1,12 +1,26 @@
<script setup lang="ts"> <script setup lang="ts">
const masto = await useMasto()
let draftPost = $ref('')
let isSending = $ref(false)
async function publish() {
try {
isSending = true
await masto.statuses.create({ status: draftPost })
draftPost = ''
}
finally {
isSending = false
}
}
</script> </script>
<template> <template>
<div flex flex-col gap-4> <div flex flex-col gap-4 :class="isSending ? ' pointer-events-none' : ''">
<textarea p2 border-rounded w-full h-40 color-black placeholder="What's on your mind?" /> <textarea v-model="draftPost" p2 border-rounded w-full h-40 color-black placeholder="What's on your mind?" />
<div flex justify-end> <div flex justify-end>
<button h-9 w-22 bg-primary border-rounded> <button h-9 w-22 bg-primary border-rounded :disabled="draftPost === ''" @click="publish">
Publish! Publish!
</button> </button>
</div> </div>