✨ Quick reply
This commit is contained in:
@@ -1,23 +1,78 @@
|
|||||||
<template>
|
<template>
|
||||||
<n-card title="Post your reply" size="small" embedded>
|
<n-card title="Quick Reply" size="small" embedded>
|
||||||
|
<div class="flex flex-col gap-2 mb-1">
|
||||||
|
<pub-select v-model:value="publisher" />
|
||||||
<n-input
|
<n-input
|
||||||
|
v-model:value="content"
|
||||||
type="textarea"
|
type="textarea"
|
||||||
placeholder="Talk about this post for a bit."
|
placeholder="Talk about this post for a bit."
|
||||||
size="large"
|
size="large"
|
||||||
:rows="5"
|
:rows="3"
|
||||||
auto-grow
|
auto-grow
|
||||||
></n-input>
|
@keydown.meta.enter.exact="submit"
|
||||||
<div class="flex justify-end mt-3">
|
@keydown.ctrl.enter.exact="submit"
|
||||||
<n-button type="primary">
|
>
|
||||||
|
<template #suffix>
|
||||||
|
<div class="flex items-end h-full py-3">
|
||||||
|
<n-button text :loading="submitting" @click="submit">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<n-icon :component="SendIcon" />
|
<n-icon :component="SendIcon" />
|
||||||
</template>
|
</template>
|
||||||
Send
|
|
||||||
</n-button>
|
</n-button>
|
||||||
</div>
|
</div>
|
||||||
|
</template>
|
||||||
|
</n-input>
|
||||||
|
</div>
|
||||||
</n-card>
|
</n-card>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { SendIcon } from "lucide-vue-next"
|
import { SendIcon } from "lucide-vue-next"
|
||||||
|
import { ref } from "vue"
|
||||||
|
import { useSolarNetwork } from "~/composables/useSolarNetwork"
|
||||||
|
|
||||||
|
// Interface for uploaded files in the editor
|
||||||
|
interface UploadedFile {
|
||||||
|
name: string
|
||||||
|
url: string
|
||||||
|
type: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const props = defineProps<{
|
||||||
|
repliedPostId: string
|
||||||
|
}>()
|
||||||
|
|
||||||
|
const emits = defineEmits(["posted"])
|
||||||
|
|
||||||
|
const publisher = ref<string | undefined>()
|
||||||
|
const content = ref("")
|
||||||
|
|
||||||
|
const fileList = ref<UploadedFile[]>([])
|
||||||
|
|
||||||
|
const submitting = ref(false)
|
||||||
|
|
||||||
|
async function submit() {
|
||||||
|
if (!content.value.trim()) return
|
||||||
|
|
||||||
|
submitting.value = true
|
||||||
|
const api = useSolarNetwork()
|
||||||
|
await api(`/sphere/posts?pub=${publisher.value}`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"content-type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
content: content.value,
|
||||||
|
replied_post_id: props.repliedPostId,
|
||||||
|
attachments: fileList.value
|
||||||
|
.filter((e) => e.url != null)
|
||||||
|
.map((e) => e.url!.split("/").reverse()[0])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
submitting.value = false
|
||||||
|
content.value = ""
|
||||||
|
fileList.value = []
|
||||||
|
emits("posted")
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="replies-list">
|
<div class="replies-list">
|
||||||
<post-quick-reply v-if="!props.hideQuickReply" class="mb-4" />
|
<post-quick-reply
|
||||||
|
v-if="!props.hideQuickReply"
|
||||||
|
:replied-post-id="props.params.postId"
|
||||||
|
@posted="refresh"
|
||||||
|
class="mb-4"
|
||||||
|
/>
|
||||||
|
|
||||||
<!-- Error State -->
|
<!-- Error State -->
|
||||||
<n-alert
|
<n-alert
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<n-config-provider :theme-overrides="{ common: { borderRadius: '8px' } }">
|
||||||
<n-select
|
<n-select
|
||||||
:options="pubStore.publishers"
|
:options="pubStore.publishers"
|
||||||
label-field="nick"
|
label-field="nick"
|
||||||
@@ -8,13 +9,13 @@
|
|||||||
:render-label="renderLabel"
|
:render-label="renderLabel"
|
||||||
:render-tag="renderTag"
|
:render-tag="renderTag"
|
||||||
/>
|
/>
|
||||||
|
</n-config-provider>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { usePubStore } from "~/stores/pub"
|
import { usePubStore } from "~/stores/pub"
|
||||||
import { watch, h } from "vue"
|
import { watch, h } from "vue"
|
||||||
import type { SelectRenderLabel, SelectRenderTag } from "naive-ui"
|
import type { SelectRenderLabel, SelectRenderTag } from "naive-ui"
|
||||||
import type { SnPublisher } from "~/types/api"
|
|
||||||
|
|
||||||
const pubStore = usePubStore()
|
const pubStore = usePubStore()
|
||||||
const apiBase = useSolarNetworkUrl()
|
const apiBase = useSolarNetworkUrl()
|
||||||
@@ -23,22 +24,25 @@ const props = defineProps<{ value: string | undefined }>()
|
|||||||
const emits = defineEmits(["update:value"])
|
const emits = defineEmits(["update:value"])
|
||||||
|
|
||||||
const renderLabel: SelectRenderLabel = (option) => {
|
const renderLabel: SelectRenderLabel = (option) => {
|
||||||
|
const pubData = pubStore.publishers.filter((p) => p.id == option.id)[0]
|
||||||
return h("div", { class: "flex items-center" }, [
|
return h("div", { class: "flex items-center" }, [
|
||||||
h(NAvatar, {
|
h(NAvatar, {
|
||||||
src: (option.value as SnPublisher)!.picture?.id
|
round: true,
|
||||||
? `${apiBase}/drive/files/${(option.value as SnPublisher)!.picture!.id}`
|
src: pubData?.picture?.id
|
||||||
|
? `${apiBase}/drive/files/${pubData.picture!.id}`
|
||||||
: undefined,
|
: undefined,
|
||||||
size: "small",
|
size: "small",
|
||||||
class: "mr-2"
|
class: "mr-2"
|
||||||
}),
|
}),
|
||||||
h("div", null, [
|
h("div", null, [
|
||||||
h("div", null, option.nick as string),
|
h("div", null, pubData!.nick),
|
||||||
h("div", { class: "text-xs opacity-80" }, `@${option.name as string}`)
|
h("div", { class: "text-xs opacity-80" }, `@${pubData!.name as string}`)
|
||||||
])
|
])
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderTag: SelectRenderTag = ({ option }) => {
|
const renderTag: SelectRenderTag = ({ option }) => {
|
||||||
|
const pubData = pubStore.publishers.filter((p) => p.id == option.id)[0]
|
||||||
return h(
|
return h(
|
||||||
"div",
|
"div",
|
||||||
{
|
{
|
||||||
@@ -46,10 +50,9 @@ const renderTag: SelectRenderTag = ({ option }) => {
|
|||||||
},
|
},
|
||||||
[
|
[
|
||||||
h(NAvatar, {
|
h(NAvatar, {
|
||||||
src: (option.value as SnPublisher)!.picture?.id
|
round: true,
|
||||||
? `${apiBase}/drive/files/${
|
src: pubData?.picture?.id
|
||||||
(option.value as SnPublisher)!.picture!.id
|
? `${apiBase}/drive/files/${pubData.picture!.id}`
|
||||||
}`
|
|
||||||
: undefined,
|
: undefined,
|
||||||
size: "small",
|
size: "small",
|
||||||
class: "mr-2"
|
class: "mr-2"
|
||||||
|
|||||||
Reference in New Issue
Block a user