mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-07 09:29:59 +00:00
feat: separate metions lines on replying
This commit is contained in:
parent
9476d14d6c
commit
9571d7338a
4 changed files with 17 additions and 6 deletions
|
@ -120,6 +120,12 @@ defineExpose({
|
||||||
border="2 dashed transparent"
|
border="2 dashed transparent"
|
||||||
:class="[isSending ? 'pointer-events-none' : '', isOverDropZone ? '!border-primary' : '']"
|
:class="[isSending ? 'pointer-events-none' : '', isOverDropZone ? '!border-primary' : '']"
|
||||||
>
|
>
|
||||||
|
<ContentMentionGroup v-if="draft.mentions?.length && shouldExpanded">
|
||||||
|
<div v-for="m of draft.mentions" :key="m" text-primary>
|
||||||
|
@{{ m }}
|
||||||
|
</div>
|
||||||
|
</ContentMentionGroup>
|
||||||
|
|
||||||
<div v-if="draft.params.sensitive">
|
<div v-if="draft.params.sensitive">
|
||||||
<input
|
<input
|
||||||
v-model="draft.params.spoilerText"
|
v-model="draft.params.spoilerText"
|
||||||
|
|
|
@ -23,9 +23,13 @@ export const usePublish = (options: {
|
||||||
})
|
})
|
||||||
|
|
||||||
async function publishDraft() {
|
async function publishDraft() {
|
||||||
|
let content = htmlToText(draft.params.status || '')
|
||||||
|
if (draft.mentions?.length)
|
||||||
|
content = `${draft.mentions.map(i => `@${i}`).join(' ')} ${content}`
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
...draft.params,
|
...draft.params,
|
||||||
status: htmlToText(draft.params.status || ''),
|
status: content,
|
||||||
mediaIds: draft.attachments.map(a => a.id),
|
mediaIds: draft.attachments.map(a => a.id),
|
||||||
...(isGlitchEdition.value ? { 'content-type': 'text/markdown' } : {}),
|
...(isGlitchEdition.value ? { 'content-type': 'text/markdown' } : {}),
|
||||||
} as mastodon.v1.CreateStatusParams
|
} as mastodon.v1.CreateStatusParams
|
||||||
|
|
|
@ -21,6 +21,7 @@ export function getDefaultDraft(options: Partial<Mutable<mastodon.v1.CreateStatu
|
||||||
sensitive,
|
sensitive,
|
||||||
spoilerText,
|
spoilerText,
|
||||||
language,
|
language,
|
||||||
|
mentions,
|
||||||
} = options
|
} = options
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
@ -34,6 +35,7 @@ export function getDefaultDraft(options: Partial<Mutable<mastodon.v1.CreateStatu
|
||||||
spoilerText: spoilerText || '',
|
spoilerText: spoilerText || '',
|
||||||
language: language || 'en',
|
language: language || 'en',
|
||||||
},
|
},
|
||||||
|
mentions,
|
||||||
lastUpdated: Date.now(),
|
lastUpdated: Date.now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,10 +52,6 @@ export async function getDraftFromStatus(status: mastodon.v1.Status): Promise<Dr
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function toMentionsHTML(accounts: string[]) {
|
|
||||||
return accounts.map(acct => `<span data-type="mention" data-id="${acct}" contenteditable="false">@${acct}</span>`).join(' ')
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAccountsToMention(status: mastodon.v1.Status) {
|
function getAccountsToMention(status: mastodon.v1.Status) {
|
||||||
const userId = currentUser.value?.account.id
|
const userId = currentUser.value?.account.id
|
||||||
const accountsToMention = new Set<string>()
|
const accountsToMention = new Set<string>()
|
||||||
|
@ -72,9 +70,10 @@ export function getReplyDraft(status: mastodon.v1.Status) {
|
||||||
key: `reply-${status.id}`,
|
key: `reply-${status.id}`,
|
||||||
draft: () => {
|
draft: () => {
|
||||||
return getDefaultDraft({
|
return getDefaultDraft({
|
||||||
initialText: toMentionsHTML(accountsToMention),
|
initialText: '',
|
||||||
inReplyToId: status!.id,
|
inReplyToId: status!.id,
|
||||||
visibility: status.visibility,
|
visibility: status.visibility,
|
||||||
|
mentions: accountsToMention,
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,9 @@ export interface Draft {
|
||||||
params: MarkNonNullable<Mutable<mastodon.v1.CreateStatusParams>, 'status' | 'language' | 'sensitive' | 'spoilerText' | 'visibility'>
|
params: MarkNonNullable<Mutable<mastodon.v1.CreateStatusParams>, 'status' | 'language' | 'sensitive' | 'spoilerText' | 'visibility'>
|
||||||
attachments: mastodon.v1.MediaAttachment[]
|
attachments: mastodon.v1.MediaAttachment[]
|
||||||
lastUpdated: number
|
lastUpdated: number
|
||||||
|
mentions?: string[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DraftMap = Record<string, Draft>
|
export type DraftMap = Record<string, Draft>
|
||||||
|
|
||||||
export interface ConfirmDialogLabel {
|
export interface ConfirmDialogLabel {
|
||||||
|
|
Loading…
Reference in a new issue