-
-
-
-
+
+
+
+
+
+
+
+
-
-
+
-
-
+
-
-
diff --git a/components/status/StatusActions.vue b/components/status/StatusActions.vue
index 9dd4074a..ca8bc2f2 100644
--- a/components/status/StatusActions.vue
+++ b/components/status/StatusActions.vue
@@ -54,6 +54,11 @@ const toggleBookmark = () => toggleStatusAction(
'bookmarked',
masto.statuses[status.bookmarked ? 'unbookmark' : 'bookmark'](status.id),
)
+const togglePin = async () => toggleStatusAction(
+ 'pinned',
+ masto.statuses[status.pinned ? 'unpin' : 'pin'](status.id),
+)
+
const copyLink = async () => {
await clipboard.copy(location.href)
}
@@ -69,10 +74,34 @@ const deleteStatus = async () => {
// TODO when timeline, remove this item
}
-const togglePin = async () => toggleStatusAction(
- 'pinned',
- masto.statuses[status.pinned ? 'unpin' : 'pin'](status.id),
-)
+
+const deleteAndRedraft = async () => {
+ // TODO confirm to delete
+
+ const { text } = await masto.statuses.remove(status.id)
+
+ if (!dialogDraft.isEmpty) {
+ // TODO confirm to overwrite
+ }
+
+ dialogDraft.draft.value = {
+ params: { ...getParamsFromStatus(status), status: text! },
+ attachments: [],
+ }
+ openPublishDialog()
+}
+
+function editStatus() {
+ if (!dialogDraft.isEmpty) {
+ // TODO confirm to overwrite
+ }
+ dialogDraft.draft.value = {
+ editingStatus: status,
+ params: getParamsFromStatus(status),
+ attachments: [],
+ }
+ openPublishDialog()
+}
@@ -151,8 +180,7 @@ const togglePin = async () => toggleStatusAction(
{{ status.pinned ? 'Unpin on profile' : 'Pin on profile' }}
-
-
+
Edit
@@ -165,6 +193,7 @@ const togglePin = async () => toggleStatusAction(
Delete & re-draft
diff --git a/components/status/StatusCard.vue b/components/status/StatusCard.vue
index 4414280d..f5690454 100644
--- a/components/status/StatusCard.vue
+++ b/components/status/StatusCard.vue
@@ -5,9 +5,11 @@ const props = withDefaults(
defineProps<{
status: Status
actions?: boolean
+ hover?: boolean
}>(),
{
actions: true,
+ hover: true,
},
)
@@ -68,7 +70,7 @@ const timeago = useTimeAgo(() => status.createdAt, {
-
+
diff --git a/composables/statusDrafts.ts b/composables/statusDrafts.ts
index a8624220..efe9f7c3 100644
--- a/composables/statusDrafts.ts
+++ b/composables/statusDrafts.ts
@@ -1,9 +1,10 @@
-import type { Attachment, CreateStatusParamsWithStatus } from 'masto'
+import type { Attachment, CreateStatusParams, CreateStatusParamsWithStatus, Status } from 'masto'
import { STORAGE_KEY_DRAFTS } from '~/constants'
import type { Mutable } from '~/types/utils'
export type DraftMap = Record
+ editingStatus?: Status
+ params: Omit, 'status'> & { status?: Exclude }
attachments: Attachment[]
}>
@@ -17,3 +18,45 @@ export const currentUserDrafts = computed(() => {
allDrafts.value[id] = {}
return allDrafts.value[id]
})
+
+export function getDefaultStatus(inReplyToId?: string): CreateStatusParamsWithStatus {
+ return {
+ status: '',
+ inReplyToId,
+ visibility: 'public',
+ }
+}
+
+export function getParamsFromStatus(status: Status) {
+ return {
+ status: status.content,
+ mediaIds: status.mediaAttachments.map(att => att.id),
+ visibility: status.visibility,
+ }
+}
+
+export function useDraft(draftKey: string, inReplyToId?: string) {
+ const draft = computed({
+ get() {
+ if (!currentUserDrafts.value[draftKey]) {
+ currentUserDrafts.value[draftKey] = {
+ params: getDefaultStatus(inReplyToId),
+ attachments: [],
+ }
+ }
+ return currentUserDrafts.value[draftKey]
+ },
+ set(val) {
+ currentUserDrafts.value[draftKey] = val
+ },
+ })
+
+ const isEmpty = computed(() => {
+ return (draft.value.params.status ?? '').trim().length === 0
+ && draft.value.attachments.length === 0
+ })
+
+ return { draft, isEmpty }
+}
+
+export const dialogDraft = useDraft('dialog')