This commit is contained in:
Henry Jameson 2026-07-22 13:52:00 +03:00
commit d1bf0e607a
4 changed files with 45 additions and 29 deletions

View file

@ -1,4 +1,3 @@
import { find } from 'lodash'
import { mapState as mapPiniaState } from 'pinia' import { mapState as mapPiniaState } from 'pinia'
import { mapState } from 'vuex' import { mapState } from 'vuex'

View file

@ -30,7 +30,10 @@ export default {
return pollFallback(this.modelValue, 'pollType') return pollFallback(this.modelValue, 'pollType')
}, },
set(newVal) { set(newVal) {
this.$emit('update:modelValue', { ...this.modelValue, pollType: newVal }) this.$emit('update:modelValue', {
...this.modelValue,
pollType: newVal,
})
}, },
}, },
options: { options: {
@ -39,14 +42,17 @@ export default {
}, },
set(newVal) { set(newVal) {
this.$emit('update:modelValue', { ...this.modelValue, options: newVal }) this.$emit('update:modelValue', { ...this.modelValue, options: newVal })
} },
}, },
expiryAmount: { expiryAmount: {
get() { get() {
return pollFallback(this.modelValue, 'expiryAmount') return pollFallback(this.modelValue, 'expiryAmount')
}, },
set(newVal) { set(newVal) {
this.$emit('update:modelValue', { ...this.modelValue, expiryAmount: newVal }) this.$emit('update:modelValue', {
...this.modelValue,
expiryAmount: newVal,
})
}, },
}, },
expiryUnit: { expiryUnit: {
@ -54,7 +60,10 @@ export default {
return pollFallback(this.modelValue, 'expiryUnit') return pollFallback(this.modelValue, 'expiryUnit')
}, },
set(newVal) { set(newVal) {
this.$emit('update:modelValue', { ...this.modelValue, expiryUnit: newVal }) this.$emit('update:modelValue', {
...this.modelValue,
expiryUnit: newVal,
})
}, },
}, },
pollLimits() { pollLimits() {

View file

@ -1,4 +1,10 @@
import { debounce, reject, uniqBy, isEqual, unescape as ldUnescape } from 'lodash' import {
debounce,
isEqual,
unescape as ldUnescape,
reject,
uniqBy,
} from 'lodash'
import { mapActions, mapState } from 'pinia' import { mapActions, mapState } from 'pinia'
import { defineAsyncComponent } from 'vue' import { defineAsyncComponent } from 'vue'
@ -60,9 +66,6 @@ const pxStringToNumber = (str) => {
return Number(str.substring(0, str.length - 2)) return Number(str.substring(0, str.length - 2))
} }
const DEFAULT_NEWSTATUS = {
}
const PostStatusForm = { const PostStatusForm = {
props: { props: {
// Status editing stuff // Status editing stuff
@ -195,7 +198,8 @@ const PostStatusForm = {
this.updateIdempotencyKey() this.updateIdempotencyKey()
// If we are starting a new post, do not associate it with old drafts // If we are starting a new post, do not associate it with old drafts
const draft = !this.disableDraft && (this.draftId || this.statusType !== 'new') const draft =
!this.disableDraft && (this.draftId || this.statusType !== 'new')
? this.getDraft(this.statusType, this.refId) ? this.getDraft(this.statusType, this.refId)
: null : null
@ -251,16 +255,17 @@ const PostStatusForm = {
refId() { refId() {
if (this.replyTo) { if (this.replyTo) {
return this.replyTo return this.replyTo
} else if (profileMention) { } else if (this.profileMention && this.repliedUser?.id) {
return this.profileMention && this.repliedUser?.id return this.profileMention && this.repliedUser?.id
} else if (statusId) { } else if (this.statusId) {
return this.statusId return this.statusId
} else { } else {
return null return null
} }
}, },
mentionsString() { mentionsString() {
if (this.statusType !== 'reply' && this.statusType !== 'mention') return '' if (this.statusType !== 'reply' && this.statusType !== 'mention')
return ''
let allAttentions = [...(this.attentions || [])] let allAttentions = [...(this.attentions || [])]
allAttentions.unshift(this.repliedUser) allAttentions.unshift(this.repliedUser)
@ -268,7 +273,9 @@ const PostStatusForm = {
allAttentions = uniqBy(allAttentions, 'id') allAttentions = uniqBy(allAttentions, 'id')
allAttentions = reject(allAttentions, { id: this.currentUser.id }) allAttentions = reject(allAttentions, { id: this.currentUser.id })
const mentions = allAttentions.map((attention) => `@${attention.screen_name}`) const mentions = allAttentions.map(
(attention) => `@${attention.screen_name}`,
)
return mentions.length > 0 ? mentions.join(' ') + ' ' : '' return mentions.length > 0 ? mentions.join(' ') + ' ' : ''
}, },
@ -286,7 +293,7 @@ const PostStatusForm = {
} }
const scope = const scope =
(this.repliedScope && this.userDefaultScopeCopy) || (this.repliedScope && this.userDefaultScopeCopy) ||
this.repliedScope === 'direct' this.repliedScope === 'direct'
? this.repliedScope ? this.repliedScope
: this.userDefaultScope : this.userDefaultScope
@ -450,11 +457,13 @@ const PostStatusForm = {
// Drafts // Drafts
isDirty() { isDirty() {
return Object.entries(this.defaultNewStatus).some(([key, defaultValue]) => { return Object.entries(this.defaultNewStatus).some(
const actualValue = this.newStatus[key] ([key, defaultValue]) => {
if (actualValue === null) return false const actualValue = this.newStatus[key]
return !isEqual(actualValue, defaultValue) if (actualValue === null) return false
}) return !isEqual(actualValue, defaultValue)
},
)
}, },
shouldAutoSaveDraft() { shouldAutoSaveDraft() {
return useMergedConfigStore().mergedConfig.autoSaveDraft return useMergedConfigStore().mergedConfig.autoSaveDraft
@ -590,14 +599,13 @@ const PostStatusForm = {
clearStatus() { clearStatus() {
this.saveInhibited = true this.saveInhibited = true
this.newStatus.status = '' this.newStatus.status = ''
this.newStatus.mentionsLine = '', ;(this.newStatus.mentionsLine = ''),
this.newStatus.spoilerText = '', (this.newStatus.spoilerText = ''),
this.newStatus.files = [], (this.newStatus.files = []),
this.newStatus.poll = null, (this.newStatus.poll = null),
this.newStatus.quote = null, (this.newStatus.quote = null),
this.newStatus.mediaDescriptions = {}, (this.newStatus.mediaDescriptions = {}),
this.$refs.mediaUpload && this.$refs.mediaUpload.clearFile()
this.$refs.mediaUpload && this.$refs.mediaUpload.clearFile()
this.clearQuoteForm() this.clearQuoteForm()
if (this.preserveFocus) { if (this.preserveFocus) {
this.$nextTick(() => { this.$nextTick(() => {

View file

@ -45,10 +45,10 @@ import {
} from 'src/api/public.js' } from 'src/api/public.js'
import { import {
blockUser as apiBlockUser, blockUser as apiBlockUser,
editUserNote as apiEditUserNote,
muteUser as apiMuteUser, muteUser as apiMuteUser,
unblockUser as apiUnblockUser, unblockUser as apiUnblockUser,
unmuteUser as apiUnmuteUser, unmuteUser as apiUnmuteUser,
editUserNote as apiEditUserNote,
fetchBlocks, fetchBlocks,
fetchDomainMutes, fetchDomainMutes,
fetchMutes, fetchMutes,