mirror of
https://github.com/elk-zone/elk.git
synced 2024-11-24 18:26:17 +03: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"
|
||||
: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">
|
||||
<input
|
||||
v-model="draft.params.spoilerText"
|
||||
|
|
|
@ -23,9 +23,13 @@ export const usePublish = (options: {
|
|||
})
|
||||
|
||||
async function publishDraft() {
|
||||
let content = htmlToText(draft.params.status || '')
|
||||
if (draft.mentions?.length)
|
||||
content = `${draft.mentions.map(i => `@${i}`).join(' ')} ${content}`
|
||||
|
||||
const payload = {
|
||||
...draft.params,
|
||||
status: htmlToText(draft.params.status || ''),
|
||||
status: content,
|
||||
mediaIds: draft.attachments.map(a => a.id),
|
||||
...(isGlitchEdition.value ? { 'content-type': 'text/markdown' } : {}),
|
||||
} as mastodon.v1.CreateStatusParams
|
||||
|
|
|
@ -21,6 +21,7 @@ export function getDefaultDraft(options: Partial<Mutable<mastodon.v1.CreateStatu
|
|||
sensitive,
|
||||
spoilerText,
|
||||
language,
|
||||
mentions,
|
||||
} = options
|
||||
|
||||
return {
|
||||
|
@ -34,6 +35,7 @@ export function getDefaultDraft(options: Partial<Mutable<mastodon.v1.CreateStatu
|
|||
spoilerText: spoilerText || '',
|
||||
language: language || 'en',
|
||||
},
|
||||
mentions,
|
||||
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) {
|
||||
const userId = currentUser.value?.account.id
|
||||
const accountsToMention = new Set<string>()
|
||||
|
@ -72,9 +70,10 @@ export function getReplyDraft(status: mastodon.v1.Status) {
|
|||
key: `reply-${status.id}`,
|
||||
draft: () => {
|
||||
return getDefaultDraft({
|
||||
initialText: toMentionsHTML(accountsToMention),
|
||||
initialText: '',
|
||||
inReplyToId: status!.id,
|
||||
visibility: status.visibility,
|
||||
mentions: accountsToMention,
|
||||
})
|
||||
},
|
||||
}
|
||||
|
|
|
@ -56,7 +56,9 @@ export interface Draft {
|
|||
params: MarkNonNullable<Mutable<mastodon.v1.CreateStatusParams>, 'status' | 'language' | 'sensitive' | 'spoilerText' | 'visibility'>
|
||||
attachments: mastodon.v1.MediaAttachment[]
|
||||
lastUpdated: number
|
||||
mentions?: string[]
|
||||
}
|
||||
|
||||
export type DraftMap = Record<string, Draft>
|
||||
|
||||
export interface ConfirmDialogLabel {
|
||||
|
|
Loading…
Reference in a new issue