Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: basic publish #13

Merged
merged 1 commit into from
Nov 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions components/account/AccountMe.client.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
<script setup lang="ts">
const { currentUser } = useAppStore()
const { currentUser } = $(useAppStore())

const account = $computed(() => currentUser?.account)
</script>

<template>
<div flex flex-col gap-4 p4>
<!-- 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 -->
<a v-else href="/api/mas.to/login" px2 py1 bg-teal6 text-white m2 rounded>Login</a>
<PublishWidget />
</div>
</template>
20 changes: 17 additions & 3 deletions components/publish/PublishWidget.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,26 @@
<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>

<template>
<div flex flex-col gap-4>
<textarea p2 border-rounded w-full h-40 color-black placeholder="What's on your mind?" />
<div flex flex-col gap-4 :class="isSending ? ' pointer-events-none' : ''">
<textarea v-model="draftPost" p2 border-rounded w-full h-40 color-black placeholder="What's on your mind?" />
<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!
</button>
</div>
Expand Down