From 3b11860d3445271c9495b08f8c68330e48c5f33e Mon Sep 17 00:00:00 2001 From: rinpatch Date: Sun, 8 Dec 2019 02:05:50 +0300 Subject: Remove whitespace hack on empty post content It's no longer necessary since the backend handles posts with empty content fine and also fixes an odd whitespace when attachment links are disabled. --- src/components/post_status_form/post_status_form.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/components/post_status_form') diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index af6299e4..74067fef 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -169,9 +169,7 @@ const PostStatusForm = { if (this.submitDisabled) { return } if (this.newStatus.status === '') { - if (this.newStatus.files.length > 0) { - this.newStatus.status = '\u200b' // hack - } else { + if (this.newStatus.files.length === 0) { this.error = 'Cannot post an empty status with no files' return } -- cgit v1.2.3-70-g09d2 From 8e399710988dd874bd921a9ced76daf90034c29f Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Wed, 13 May 2020 17:48:31 +0300 Subject: add with_relationships where necessary --- src/components/post_status_form/post_status_form.js | 2 +- src/components/user_settings/user_settings.js | 4 ++-- src/modules/users.js | 4 ++-- src/services/api/api.service.js | 13 +++++++++---- 4 files changed, 14 insertions(+), 9 deletions(-) (limited to 'src/components/post_status_form') diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index 74067fef..a98e1e31 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -102,7 +102,7 @@ const PostStatusForm = { ...this.$store.state.instance.customEmoji ], users: this.$store.state.users.users, - updateUsersList: (input) => this.$store.dispatch('searchUsers', input) + updateUsersList: (query) => this.$store.dispatch('searchUsers', { query }) }) }, emojiSuggestor () { diff --git a/src/components/user_settings/user_settings.js b/src/components/user_settings/user_settings.js index 5338c974..a1ec2997 100644 --- a/src/components/user_settings/user_settings.js +++ b/src/components/user_settings/user_settings.js @@ -112,7 +112,7 @@ const UserSettings = { ...this.$store.state.instance.customEmoji ], users: this.$store.state.users.users, - updateUsersList: (input) => this.$store.dispatch('searchUsers', input) + updateUsersList: (query) => this.$store.dispatch('searchUsers', { query }) }) }, emojiSuggestor () { @@ -362,7 +362,7 @@ const UserSettings = { }) }, queryUserIds (query) { - return this.$store.dispatch('searchUsers', query) + return this.$store.dispatch('searchUsers', { query }) .then((users) => map(users, 'id')) }, blockUsers (ids) { diff --git a/src/modules/users.js b/src/modules/users.js index 1d1b415c..f377da75 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -428,8 +428,8 @@ const users = { store.commit('setUserForNotification', notification) }) }, - searchUsers (store, query) { - return store.rootState.api.backendInteractor.searchUsers({ query }) + searchUsers (store, { query, withRelationships }) { + return store.rootState.api.backendInteractor.searchUsers({ query, withRelationships }) .then((users) => { store.commit('addNewUsers', users) return users diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 72c8874f..94ff4623 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -324,7 +324,8 @@ const fetchFriends = ({ id, maxId, sinceId, limit = 20, credentials }) => { const args = [ maxId && `max_id=${maxId}`, sinceId && `since_id=${sinceId}`, - limit && `limit=${limit}` + limit && `limit=${limit}`, + `with_relationships=true` ].filter(_ => _).join('&') url = url + (args ? '?' + args : '') @@ -358,7 +359,8 @@ const fetchFollowers = ({ id, maxId, sinceId, limit = 20, credentials }) => { const args = [ maxId && `max_id=${maxId}`, sinceId && `since_id=${sinceId}`, - limit && `limit=${limit}` + limit && `limit=${limit}`, + `with_relationships=true` ].filter(_ => _).join('&') url += args ? '?' + args : '' @@ -935,12 +937,13 @@ const reportUser = ({ credentials, userId, statusIds, comment, forward }) => { }) } -const searchUsers = ({ credentials, query }) => { +const searchUsers = ({ credentials, query, withRelationships }) => { return promisedRequest({ url: MASTODON_USER_SEARCH_URL, params: { q: query, - resolve: true + resolve: true, + with_relationships: withRelationships }, credentials }) @@ -971,6 +974,8 @@ const search2 = ({ credentials, q, resolve, limit, offset, following }) => { params.push(['following', true]) } + params.push(['with_relationships', true]) + let queryString = map(params, (param) => `${param[0]}=${param[1]}`).join('&') url += `?${queryString}` -- cgit v1.2.3-70-g09d2 From e45f7fe8772f538c6824718ec26067849bde34c6 Mon Sep 17 00:00:00 2001 From: lain Date: Mon, 8 Jun 2020 18:22:17 +0200 Subject: MediaUpload: Correctly handle multiple uploads. --- src/components/media_upload/media_upload.js | 33 ++++++++++++++-------- .../post_status_form/post_status_form.js | 2 -- .../post_status_form/post_status_form.vue | 1 + 3 files changed, 23 insertions(+), 13 deletions(-) (limited to 'src/components/post_status_form') diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js index 4568224b..16e47ef7 100644 --- a/src/components/media_upload/media_upload.js +++ b/src/components/media_upload/media_upload.js @@ -5,10 +5,15 @@ import fileSizeFormatService from '../../services/file_size_format/file_size_for const mediaUpload = { data () { return { - uploading: false, + uploadCount: 0, uploadReady: true } }, + computed: { + uploading () { + return this.uploadCount > 0 + } + }, methods: { uploadFile (file) { const self = this @@ -23,23 +28,27 @@ const mediaUpload = { formData.append('file', file) self.$emit('uploading') - self.uploading = true + self.uploadCount++ statusPosterService.uploadMedia({ store, formData }) .then((fileData) => { self.$emit('uploaded', fileData) - self.uploading = false + self.decreaseUploadCount() }, (error) => { // eslint-disable-line handle-callback-err self.$emit('upload-failed', 'default') - self.uploading = false + self.decreaseUploadCount() }) }, + decreaseUploadCount() { + this.uploadCount-- + if (this.uploadCount === 0) { + this.$emit('all-uploaded') + } + }, fileDrop (e) { if (e.dataTransfer.files.length > 0) { e.preventDefault() // allow dropping text like before - for (const file of e.dataTransfer.files) { - this.uploadFile(file) - } + this.multiUpload(e.dataTransfer.files) } }, fileDrag (e) { @@ -56,11 +65,13 @@ const mediaUpload = { this.uploadReady = true }) }, - change ({ target }) { - for (var i = 0; i < target.files.length; i++) { - let file = target.files[i] + multiUpload (files) { + for (const file of files) { this.uploadFile(file) } + }, + change ({ target }) { + this.multiUpload(target.files) } }, props: [ @@ -69,7 +80,7 @@ const mediaUpload = { watch: { 'dropFiles': function (fileInfos) { if (!this.uploading) { - this.uploadFile(fileInfos[0]) + this.multiUpload(fileInfos) } } } diff --git a/src/components/post_status_form/post_status_form.js b/src/components/post_status_form/post_status_form.js index a98e1e31..6164caa0 100644 --- a/src/components/post_status_form/post_status_form.js +++ b/src/components/post_status_form/post_status_form.js @@ -218,7 +218,6 @@ const PostStatusForm = { }, addMediaFile (fileInfo) { this.newStatus.files.push(fileInfo) - this.enableSubmit() }, removeMediaFile (fileInfo) { let index = this.newStatus.files.indexOf(fileInfo) @@ -227,7 +226,6 @@ const PostStatusForm = { uploadFailed (errString, templateArgs) { templateArgs = templateArgs || {} this.error = this.$t('upload.error.base') + ' ' + this.$t('upload.error.' + errString, templateArgs) - this.enableSubmit() }, disableSubmit () { this.submitDisabled = true diff --git a/src/components/post_status_form/post_status_form.vue b/src/components/post_status_form/post_status_form.vue index 9789a481..5629ceac 100644 --- a/src/components/post_status_form/post_status_form.vue +++ b/src/components/post_status_form/post_status_form.vue @@ -172,6 +172,7 @@ @uploading="disableSubmit" @uploaded="addMediaFile" @upload-failed="uploadFailed" + @all-uploaded="enableSubmit" />
Date: Wed, 10 Jun 2020 11:01:38 +0300 Subject: add better visual indication for dropping files, make dropzone bigger --- src/components/media_upload/media_upload.js | 14 ---------- src/components/media_upload/media_upload.vue | 7 +---- .../post_status_form/post_status_form.js | 19 +++++++++++-- .../post_status_form/post_status_form.vue | 32 ++++++++++++++++++++-- 4 files changed, 47 insertions(+), 25 deletions(-) (limited to 'src/components/post_status_form') diff --git a/src/components/media_upload/media_upload.js b/src/components/media_upload/media_upload.js index 5849b065..fbb2d03d 100644 --- a/src/components/media_upload/media_upload.js +++ b/src/components/media_upload/media_upload.js @@ -45,20 +45,6 @@ const mediaUpload = { this.$emit('all-uploaded') } }, - fileDrop (e) { - if (e.dataTransfer.files.length > 0) { - e.preventDefault() // allow dropping text like before - this.multiUpload(e.dataTransfer.files) - } - }, - fileDrag (e) { - let types = e.dataTransfer.types - if (types.contains('Files')) { - e.dataTransfer.dropEffect = 'copy' - } else { - e.dataTransfer.dropEffect = 'none' - } - }, clearFile () { this.uploadReady = false this.$nextTick(() => { diff --git a/src/components/media_upload/media_upload.vue b/src/components/media_upload/media_upload.vue index 0fc305ac..5e31730b 100644 --- a/src/components/media_upload/media_upload.vue +++ b/src/components/media_upload/media_upload.vue @@ -1,10 +1,5 @@