mirror of
https://github.com/h3poteto/whalebird-desktop
synced 2025-02-04 11:17:32 +01:00
Merge pull request #2069 from h3poteto/iss-2033
closes #2033 Reject adding 5+ images before upload images in new toot
This commit is contained in:
commit
9a8b32cd80
@ -30,6 +30,7 @@ import Mousetrap from 'mousetrap'
|
|||||||
import ReceiveDrop from './TimelineSpace/ReceiveDrop'
|
import ReceiveDrop from './TimelineSpace/ReceiveDrop'
|
||||||
import { AccountLoadError } from '@/errors/load'
|
import { AccountLoadError } from '@/errors/load'
|
||||||
import { TimelineFetchError } from '@/errors/fetch'
|
import { TimelineFetchError } from '@/errors/fetch'
|
||||||
|
import { NewTootAttachLength } from '@/errors/validations'
|
||||||
import { Event } from '~/src/renderer/components/event'
|
import { Event } from '~/src/renderer/components/event'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@ -126,11 +127,18 @@ export default {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
Event.$emit('image-uploaded')
|
Event.$emit('image-uploaded')
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(err => {
|
||||||
|
if (err instanceof NewTootAttachLength) {
|
||||||
|
this.$message({
|
||||||
|
message: this.$t('validation.new_toot.attach_length', { max: 4 }),
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.attach_error'),
|
message: this.$t('message.attach_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
return false
|
return false
|
||||||
},
|
},
|
||||||
|
@ -354,11 +354,18 @@ export default {
|
|||||||
.then(() => {
|
.then(() => {
|
||||||
this.statusHeight = this.statusHeight - this.$refs.preview.offsetHeight
|
this.statusHeight = this.statusHeight - this.$refs.preview.offsetHeight
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(err => {
|
||||||
|
if (err instanceof NewTootAttachLength) {
|
||||||
|
this.$message({
|
||||||
|
message: this.$t('validation.new_toot.attach_length', { max: 4 }),
|
||||||
|
type: 'error'
|
||||||
|
})
|
||||||
|
} else {
|
||||||
this.$message({
|
this.$message({
|
||||||
message: this.$t('message.attach_error'),
|
message: this.$t('message.attach_error'),
|
||||||
type: 'error'
|
type: 'error'
|
||||||
})
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
removeAttachment(media) {
|
removeAttachment(media) {
|
||||||
|
@ -328,7 +328,10 @@ const actions: ActionTree<NewTootState, RootState> = {
|
|||||||
commit(MUTATION_TYPES.CHANGE_SENSITIVE, false)
|
commit(MUTATION_TYPES.CHANGE_SENSITIVE, false)
|
||||||
commit(MUTATION_TYPES.CHANGE_VISIBILITY_VALUE, Visibility.Public.value)
|
commit(MUTATION_TYPES.CHANGE_VISIBILITY_VALUE, Visibility.Public.value)
|
||||||
},
|
},
|
||||||
uploadImage: async ({ commit, rootState }, image: any) => {
|
uploadImage: async ({ commit, state, rootState }, image: any) => {
|
||||||
|
if (state.attachedMedias.length > 3) {
|
||||||
|
throw new NewTootAttachLength()
|
||||||
|
}
|
||||||
commit(MUTATION_TYPES.CHANGE_BLOCK_SUBMIT, true)
|
commit(MUTATION_TYPES.CHANGE_BLOCK_SUBMIT, true)
|
||||||
if (rootState.TimelineSpace.account.accessToken === undefined || rootState.TimelineSpace.account.accessToken === null) {
|
if (rootState.TimelineSpace.account.accessToken === undefined || rootState.TimelineSpace.account.accessToken === null) {
|
||||||
throw new AuthenticationError()
|
throw new AuthenticationError()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user