From ddb6fb9217789e90490a4ec1ce7a2dd9ced67631 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Sun, 24 Nov 2019 13:57:46 +0200 Subject: Backend Interactor service overhaul, removed the need for copypasting --- src/components/moderation_tools/moderation_tools.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/components/moderation_tools/moderation_tools.js') diff --git a/src/components/moderation_tools/moderation_tools.js b/src/components/moderation_tools/moderation_tools.js index 8aadc8c5..5bb76497 100644 --- a/src/components/moderation_tools/moderation_tools.js +++ b/src/components/moderation_tools/moderation_tools.js @@ -45,12 +45,12 @@ const ModerationTools = { toggleTag (tag) { const store = this.$store if (this.tagsSet.has(tag)) { - store.state.api.backendInteractor.untagUser(this.user, tag).then(response => { + store.state.api.backendInteractor.untagUser({ user: this.user, tag }).then(response => { if (!response.ok) { return } store.commit('untagUser', { user: this.user, tag }) }) } else { - store.state.api.backendInteractor.tagUser(this.user, tag).then(response => { + store.state.api.backendInteractor.tagUser({ user: this.user, tag }).then(response => { if (!response.ok) { return } store.commit('tagUser', { user: this.user, tag }) }) @@ -59,21 +59,21 @@ const ModerationTools = { toggleRight (right) { const store = this.$store if (this.user.rights[right]) { - store.state.api.backendInteractor.deleteRight(this.user, right).then(response => { + store.state.api.backendInteractor.deleteRight({ user: this.user, right }).then(response => { if (!response.ok) { return } - store.commit('updateRight', { user: this.user, right: right, value: false }) + store.commit('updateRight', { user: this.user, right, value: false }) }) } else { - store.state.api.backendInteractor.addRight(this.user, right).then(response => { + store.state.api.backendInteractor.addRight({ user: this.user, right }).then(response => { if (!response.ok) { return } - store.commit('updateRight', { user: this.user, right: right, value: true }) + store.commit('updateRight', { user: this.user, right, value: true }) }) } }, toggleActivationStatus () { const store = this.$store const status = !!this.user.deactivated - store.state.api.backendInteractor.setActivationStatus(this.user, status).then(response => { + store.state.api.backendInteractor.setActivationStatus({ user: this.user, status }).then(response => { if (!response.ok) { return } store.commit('updateActivationStatus', { user: this.user, status: status }) }) @@ -85,7 +85,7 @@ const ModerationTools = { const store = this.$store const user = this.user const { id, name } = user - store.state.api.backendInteractor.deleteUser(user) + store.state.api.backendInteractor.deleteUser({ user }) .then(e => { this.$store.dispatch('markStatusesAsDeleted', status => user.id === status.user.id) const isProfile = this.$route.name === 'external-user-profile' || this.$route.name === 'user-profile' -- cgit v1.2.3-70-g09d2 From 506822bed01deb2d2fb98f511902d6801819cbd8 Mon Sep 17 00:00:00 2001 From: taehoon Date: Mon, 18 Nov 2019 20:29:12 -0500 Subject: replace setActivationStatus api with new one --- src/components/moderation_tools/moderation_tools.js | 2 +- src/services/api/api.service.js | 19 +++++++------------ .../backend_interactor_service.js | 6 +++--- 3 files changed, 11 insertions(+), 16 deletions(-) (limited to 'src/components/moderation_tools/moderation_tools.js') diff --git a/src/components/moderation_tools/moderation_tools.js b/src/components/moderation_tools/moderation_tools.js index 8aadc8c5..10a20709 100644 --- a/src/components/moderation_tools/moderation_tools.js +++ b/src/components/moderation_tools/moderation_tools.js @@ -73,7 +73,7 @@ const ModerationTools = { toggleActivationStatus () { const store = this.$store const status = !!this.user.deactivated - store.state.api.backendInteractor.setActivationStatus(this.user, status).then(response => { + store.state.api.backendInteractor.toggleActivationStatus(this.user).then(response => { if (!response.ok) { return } store.commit('updateActivationStatus', { user: this.user, status: status }) }) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 7eb0547e..dbc8320e 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -12,7 +12,7 @@ const CHANGE_EMAIL_URL = '/api/pleroma/change_email' const CHANGE_PASSWORD_URL = '/api/pleroma/change_password' const TAG_USER_URL = '/api/pleroma/admin/users/tag' const PERMISSION_GROUP_URL = (screenName, right) => `/api/pleroma/admin/users/${screenName}/permission_group/${right}` -const ACTIVATION_STATUS_URL = screenName => `/api/pleroma/admin/users/${screenName}/activation_status` +const TOGGLE_ACTIVATION_URL = screenName => `/api/pleroma/admin/users/${screenName}/toggle_activation` const ADMIN_USERS_URL = '/api/pleroma/admin/users' const SUGGESTIONS_URL = '/api/v1/suggestions' const NOTIFICATION_SETTINGS_URL = '/api/pleroma/notification_settings' @@ -450,19 +450,14 @@ const deleteRight = ({ right, credentials, ...user }) => { }) } -const setActivationStatus = ({ status, credentials, ...user }) => { - const screenName = user.screen_name - const body = { - status: status - } - +// eslint-disable-next-line camelcase +const toggleActivationStatus = ({ credentials, screen_name }) => { const headers = authHeaders(credentials) headers['Content-Type'] = 'application/json' - return fetch(ACTIVATION_STATUS_URL(screenName), { - method: 'PUT', - headers: headers, - body: JSON.stringify(body) + return fetch(TOGGLE_ACTIVATION_URL(screen_name), { + method: 'PATCH', + headers: headers }) } @@ -979,7 +974,7 @@ const apiService = { deleteUser, addRight, deleteRight, - setActivationStatus, + toggleActivationStatus, register, getCaptcha, updateAvatar, diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index c16bd1f1..e0a15d3b 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -89,8 +89,8 @@ const backendInteractorService = credentials => { } // eslint-disable-next-line camelcase - const setActivationStatus = ({ screen_name }, status) => { - return apiService.setActivationStatus({ screen_name, status, credentials }) + const toggleActivationStatus = ({ screen_name }) => { + return apiService.toggleActivationStatus({ screen_name, credentials }) } // eslint-disable-next-line camelcase @@ -191,7 +191,7 @@ const backendInteractorService = credentials => { addRight, deleteRight, deleteUser, - setActivationStatus, + toggleActivationStatus, register, getCaptcha, updateAvatar, -- cgit v1.2.3-70-g09d2 From 36376ce57c93c81317b6a8b0b50699d6b8488f57 Mon Sep 17 00:00:00 2001 From: taehoon Date: Mon, 18 Nov 2019 20:42:10 -0500 Subject: use vuex action --- src/components/moderation_tools/moderation_tools.js | 7 +------ src/modules/users.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 8 deletions(-) (limited to 'src/components/moderation_tools/moderation_tools.js') diff --git a/src/components/moderation_tools/moderation_tools.js b/src/components/moderation_tools/moderation_tools.js index 10a20709..02b92fef 100644 --- a/src/components/moderation_tools/moderation_tools.js +++ b/src/components/moderation_tools/moderation_tools.js @@ -71,12 +71,7 @@ const ModerationTools = { } }, toggleActivationStatus () { - const store = this.$store - const status = !!this.user.deactivated - store.state.api.backendInteractor.toggleActivationStatus(this.user).then(response => { - if (!response.ok) { return } - store.commit('updateActivationStatus', { user: this.user, status: status }) - }) + this.$store.dispatch('toggleActivationStatus', this.user) }, deleteUserDialog (show) { this.showDeleteUserDialog = show diff --git a/src/modules/users.js b/src/modules/users.js index 14b2d8b5..ec2ef608 100644 --- a/src/modules/users.js +++ b/src/modules/users.js @@ -95,9 +95,9 @@ export const mutations = { newRights[right] = value set(user, 'rights', newRights) }, - updateActivationStatus (state, { user: { id }, status }) { + updateActivationStatus (state, { user: { id }, deactivated }) { const user = state.usersObject[id] - set(user, 'deactivated', !status) + set(user, 'deactivated', deactivated) }, setCurrentUser (state, user) { state.lastLoginName = user.screen_name @@ -331,6 +331,12 @@ const users = { return rootState.api.backendInteractor.unsubscribeUser(id) .then((relationship) => commit('updateUserRelationship', [relationship])) }, + toggleActivationStatus ({ rootState, commit }, user) { + rootState.api.backendInteractor.toggleActivationStatus(user) + .then(response => { + commit('updateActivationStatus', { user, deactivated: response.deactivated }) + }) + }, registerPushNotifications (store) { const token = store.state.currentUser.credentials const vapidPublicKey = store.rootState.instance.vapidPublicKey -- cgit v1.2.3-70-g09d2 From 31225f5d142b51d52bed305f25a37288c9188062 Mon Sep 17 00:00:00 2001 From: Shpuld Shpludson Date: Fri, 28 Feb 2020 16:39:47 +0000 Subject: Fix/popover performance --- CHANGELOG.md | 1 + package.json | 1 - src/components/account_actions/account_actions.js | 4 +- src/components/account_actions/account_actions.vue | 21 +-- src/components/emoji_reactions/emoji_reactions.js | 11 +- src/components/emoji_reactions/emoji_reactions.vue | 33 +++-- src/components/extra_buttons/extra_buttons.js | 3 + src/components/extra_buttons/extra_buttons.vue | 14 +- .../moderation_tools/moderation_tools.js | 11 +- .../moderation_tools/moderation_tools.vue | 17 ++- src/components/popover/popover.js | 156 ++++++++++++++++++++ src/components/popover/popover.vue | 118 +++++++++++++++ src/components/popper/popper.scss | 164 --------------------- src/components/react_button/react_button.js | 23 +-- src/components/react_button/react_button.vue | 32 ++-- src/components/status/status.vue | 11 +- src/components/status_popover/status_popover.js | 12 +- src/components/status_popover/status_popover.vue | 64 +++----- src/main.js | 8 - yarn.lock | 19 --- 20 files changed, 393 insertions(+), 330 deletions(-) create mode 100644 src/components/popover/popover.js create mode 100644 src/components/popover/popover.vue delete mode 100644 src/components/popper/popper.scss (limited to 'src/components/moderation_tools/moderation_tools.js') diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cdd604b..e77334b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Registration fixed - Deactivation of remote accounts from frontend - Fixed NSFW unhiding not working with videos when using one-click unhiding/displaying +- Improved performance of anything that uses popovers (most notably statuses) ## [1.1.7 and earlier] - 2019-12-14 ### Added diff --git a/package.json b/package.json index 5c7fa31e..542086b4 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,6 @@ "portal-vue": "^2.1.4", "sanitize-html": "^1.13.0", "v-click-outside": "^2.1.1", - "v-tooltip": "^2.0.2", "vue": "^2.5.13", "vue-chat-scroll": "^1.2.1", "vue-i18n": "^7.3.2", diff --git a/src/components/account_actions/account_actions.js b/src/components/account_actions/account_actions.js index d2153680..5d7ecf7e 100644 --- a/src/components/account_actions/account_actions.js +++ b/src/components/account_actions/account_actions.js @@ -1,4 +1,5 @@ import ProgressButton from '../progress_button/progress_button.vue' +import Popover from '../popover/popover.vue' const AccountActions = { props: [ @@ -8,7 +9,8 @@ const AccountActions = { return { } }, components: { - ProgressButton + ProgressButton, + Popover }, methods: { showRepeats () { diff --git a/src/components/account_actions/account_actions.vue b/src/components/account_actions/account_actions.vue index d3235be1..483783cf 100644 --- a/src/components/account_actions/account_actions.vue +++ b/src/components/account_actions/account_actions.vue @@ -1,13 +1,13 @@