diff --git a/src/components/bookmark_folder_edit/bookmark_folder_edit.js b/src/components/bookmark_folder_edit/bookmark_folder_edit.js index 748070495..ae5aebedd 100644 --- a/src/components/bookmark_folder_edit/bookmark_folder_edit.js +++ b/src/components/bookmark_folder_edit/bookmark_folder_edit.js @@ -27,7 +27,7 @@ const BookmarkFolderEdit = { fetchBookmarkFolders({ credentials: useOAuthStore().token, - }).then((folders) => { + }).then(({ data: folders }) => { const folder = folders.find((folder) => folder.id === this.id) if (!folder) return diff --git a/src/components/chat/chat.js b/src/components/chat/chat.js index b03bc0256..68306acbe 100644 --- a/src/components/chat/chat.js +++ b/src/components/chat/chat.js @@ -278,7 +278,7 @@ const Chat = { maxId, sinceId, credentials: useOAuthStore().token, - }).then((messages) => { + }).then(({ data: messages }) => { // Clear the current chat in case we're recovering from a ws connection loss. if (isFirstFetch) { chatService.clear(chatMessageService) @@ -310,10 +310,11 @@ const Chat = { let chat = this.findOpenedChatByRecipientId(this.recipientId) if (!chat) { try { - chat = await getOrCreateChat({ + const { data } = await getOrCreateChat({ accountId: this.recipientId, credentials: useOAuthStore().token, }) + chat = data } catch (e) { console.error('Error creating or getting a chat', e) this.errorLoadingChat = true @@ -383,7 +384,7 @@ const Chat = { params, credentials: useOAuthStore().token, }) - .then((data) => { + .then(({ data }) => { this.$store.dispatch('addChatMessages', { chatId: this.currentChat.id, updateMaxId: false, diff --git a/src/components/remote_user_resolver/remote_user_resolver.js b/src/components/remote_user_resolver/remote_user_resolver.js index b44629fcf..75304fe52 100644 --- a/src/components/remote_user_resolver/remote_user_resolver.js +++ b/src/components/remote_user_resolver/remote_user_resolver.js @@ -16,7 +16,7 @@ const RemoteUserResolver = { id, credentials: useOAuthStore().token, }) - .then((externalUser) => { + .then(({ data: externalUser }) => { if (externalUser.error) { this.error = true } else { diff --git a/src/components/settings_modal/tabs/appearance_tab.js b/src/components/settings_modal/tabs/appearance_tab.js index 5dbd79de4..c11579e53 100644 --- a/src/components/settings_modal/tabs/appearance_tab.js +++ b/src/components/settings_modal/tabs/appearance_tab.js @@ -490,7 +490,7 @@ const AppearanceTab = { background, credentials: useOAuthStore().token, }) - .then((data) => { + .then(({ data }) => { this.$store.commit('addNewUsers', [data]) this.$store.commit('setCurrentUser', data) this.backgroundPreview = null diff --git a/src/components/settings_modal/tabs/composing_tab.js b/src/components/settings_modal/tabs/composing_tab.js index 3a2384832..1586c87bf 100644 --- a/src/components/settings_modal/tabs/composing_tab.js +++ b/src/components/settings_modal/tabs/composing_tab.js @@ -169,7 +169,7 @@ const ComposingTab = { updateProfile({ params, credentials: useOAuthStore().token, - }).then((user) => { + }).then(({ data: user }) => { this.$store.commit('addNewUsers', [user]) this.$store.commit('setCurrentUser', user) }) diff --git a/src/components/settings_modal/tabs/data_import_export_tab.js b/src/components/settings_modal/tabs/data_import_export_tab.js index a89657658..4554f4a1f 100644 --- a/src/components/settings_modal/tabs/data_import_export_tab.js +++ b/src/components/settings_modal/tabs/data_import_export_tab.js @@ -64,7 +64,7 @@ const DataImportExportTab = { return importFollows({ file, credentials: useOAuthStore().token, - }).then((status) => { + }).then(({ data: status }) => { if (!status) { throw new Error('failed') } @@ -74,7 +74,7 @@ const DataImportExportTab = { return importBlocks({ file, credentials: useOAuthStore().token, - }).then((status) => { + }).then(({ data: status }) => { if (!status) { throw new Error('failed') } @@ -84,13 +84,13 @@ const DataImportExportTab = { return importMutes({ file, credentials: useOAuthStore().token, - }).then((status) => { + }).then(({ data: status }) => { if (!status) { throw new Error('failed') } }) }, - generateExportableUsersContent(users) { + generateExportableUsersContent({ data: users }) { // Get addresses return users .map((user) => { @@ -121,7 +121,7 @@ const DataImportExportTab = { listBackups({ credentials: useOAuthStore().token, }) - .then((res) => { + .then(({ data: res }) => { this.backups = res this.listBackupsError = false }) diff --git a/src/components/settings_modal/tabs/general_tab.js b/src/components/settings_modal/tabs/general_tab.js index e40bb993e..bed6f6500 100644 --- a/src/components/settings_modal/tabs/general_tab.js +++ b/src/components/settings_modal/tabs/general_tab.js @@ -63,7 +63,7 @@ const GeneralTab = { updateProfile({ params, credentials: useOAuthStore().token, - }).then((user) => { + }).then(({ data: user }) => { this.$store.commit('addNewUsers', [user]) this.$store.commit('setCurrentUser', user) }) diff --git a/src/components/settings_modal/tabs/mutes_and_blocks_tab.js b/src/components/settings_modal/tabs/mutes_and_blocks_tab.js index cb945012f..781412249 100644 --- a/src/components/settings_modal/tabs/mutes_and_blocks_tab.js +++ b/src/components/settings_modal/tabs/mutes_and_blocks_tab.js @@ -60,7 +60,7 @@ const MutesAndBlocks = { return importFollows({ file, credentials: useOAuthStore().token, - }).then((status) => { + }).then(({ data: status }) => { if (!status) { throw new Error('failed') } @@ -70,7 +70,7 @@ const MutesAndBlocks = { return importBlocks({ file, credentials: useOAuthStore().token, - }).then((status) => { + }).then(({ data: status }) => { if (!status) { throw new Error('failed') } diff --git a/src/components/settings_modal/tabs/profile_tab.js b/src/components/settings_modal/tabs/profile_tab.js index d30a82bf9..844e223c9 100644 --- a/src/components/settings_modal/tabs/profile_tab.js +++ b/src/components/settings_modal/tabs/profile_tab.js @@ -43,7 +43,7 @@ const ProfileTab = { params, credentials: useOAuthStore().token, }) - .then((user) => { + .then(({ data: user }) => { this.$store.commit('addNewUsers', [user]) this.$store.commit('setCurrentUser', user) }) diff --git a/src/components/settings_modal/tabs/security_tab/mfa_totp.js b/src/components/settings_modal/tabs/security_tab/mfa_totp.js index a22e88070..bbe06c217 100644 --- a/src/components/settings_modal/tabs/security_tab/mfa_totp.js +++ b/src/components/settings_modal/tabs/security_tab/mfa_totp.js @@ -40,7 +40,7 @@ export default { mfaDisableOTP({ password: this.currentPassword, credentials: useOAuthStore().token, - }).then((res) => { + }).then(({ data: res }) => { this.inProgress = false if (res.error) { this.error = res.error diff --git a/src/components/settings_modal/tabs/security_tab/security_tab.js b/src/components/settings_modal/tabs/security_tab/security_tab.js index 30a8b580e..45876f848 100644 --- a/src/components/settings_modal/tabs/security_tab/security_tab.js +++ b/src/components/settings_modal/tabs/security_tab/security_tab.js @@ -78,7 +78,7 @@ const SecurityTab = { deleteAccount({ credentials: useOAuthStore().token, password: this.deleteAccountConfirmPasswordInput, - }).then((res) => { + }).then(({ data: res }) => { if (res.status === 'success') { this.$store.dispatch('logout') this.$router.push({ name: 'root' }) @@ -94,7 +94,7 @@ const SecurityTab = { newPasswordConfirmation: this.changePasswordInputs[2], credentials: useOAuthStore().token, } - changePassword(params).then((res) => { + changePassword(params).then(({ data: res }) => { if (res.status === 'success') { this.changedPassword = true this.changePasswordError = false @@ -111,7 +111,7 @@ const SecurityTab = { password: this.changeEmailPassword, credentials: useOAuthStore().token, } - changeEmail(params).then((res) => { + changeEmail(params).then(({ data: res }) => { if (res.status === 'success') { this.changedEmail = true this.changeEmailError = false @@ -127,7 +127,7 @@ const SecurityTab = { password: this.moveAccountPassword, credentials: useOAuthStore().token, } - moveAccount(params).then((res) => { + moveAccount(params).then(({ data: res }) => { if (res.status === 'success') { this.movedAccount = true this.moveAccountError = false @@ -163,7 +163,7 @@ const SecurityTab = { listAliases({ credentials: useOAuthStore().token, }) - .then((res) => { + .then(({ data: res }) => { this.aliases = res.aliases this.listAliasesError = false }) diff --git a/src/components/user_card/user_card.js b/src/components/user_card/user_card.js index 2f10c5ebc..70fb057af 100644 --- a/src/components/user_card/user_card.js +++ b/src/components/user_card/user_card.js @@ -600,7 +600,7 @@ export default { } updateProfile({ params }) - .then((user) => { + .then(({ data: user }) => { this.newFields.splice(this.newFields.length) merge(this.newFields, user.fields) this.$store.commit('addNewUsers', [user]) diff --git a/src/components/who_to_follow/who_to_follow.js b/src/components/who_to_follow/who_to_follow.js index 3c0b53b0d..6f00b3e5e 100644 --- a/src/components/who_to_follow/who_to_follow.js +++ b/src/components/who_to_follow/who_to_follow.js @@ -23,7 +23,7 @@ const WhoToFollow = { fetchUser({ id, credentials: useOAuthStore().token, - }).then((externalUser) => { + }).then(({ data: externalUser }) => { if (!externalUser.error) { this.$store.commit('addNewUsers', [externalUser]) this.users.push(externalUser) @@ -34,7 +34,7 @@ const WhoToFollow = { getWhoToFollow() { const credentials = useOAuthStore().token if (credentials) { - suggestions({ credentials }).then((reply) => { + suggestions({ credentials }).then(({ data: reply }) => { this.showWhoToFollow(reply) }) } diff --git a/src/components/who_to_follow_panel/who_to_follow_panel.js b/src/components/who_to_follow_panel/who_to_follow_panel.js index 32f9dc918..7a65ba39d 100644 --- a/src/components/who_to_follow_panel/who_to_follow_panel.js +++ b/src/components/who_to_follow_panel/who_to_follow_panel.js @@ -21,7 +21,7 @@ function showWhoToFollow(panel, reply) { fetchUser({ id: name, credentials: useOAuthStore().token, - }).then((externalUser) => { + }).then(({ data: externalUser }) => { if (!externalUser.error) { panel.$store.commit('addNewUsers', [externalUser]) toFollow.id = externalUser.id @@ -36,7 +36,7 @@ function getWhoToFollow(panel) { panel.usersToFollow.forEach((toFollow) => { toFollow.name = 'Loading...' }) - suggestions({ credentials }).then((reply) => { + suggestions({ credentials }).then(({ data: reply }) => { showWhoToFollow(panel, reply) }) } diff --git a/src/modules/profileConfig.js b/src/modules/profileConfig.js index 80f881a25..3fca7d6a8 100644 --- a/src/modules/profileConfig.js +++ b/src/modules/profileConfig.js @@ -10,7 +10,7 @@ const defaultApi = ({ rootState, commit }, { path, value }) => { return updateProfile({ params, credentials: useOAuthStore().token, - }).then((result) => { + }).then(({ data: result }) => { commit('addNewUsers', [result]) commit('setCurrentUser', result) }) @@ -22,7 +22,7 @@ const notificationsApi = ({ rootState, commit }, { path, value, oldValue }) => { return updateNotificationSettings({ settings, credentials: useOAuthStore().token, - }).then((result) => { + }).then(({ data: result }) => { if (result.status === 'success') { commit('confirmProfileOption', { name, value }) } else { diff --git a/src/services/follow_request_fetcher/follow_request_fetcher.service.js b/src/services/follow_request_fetcher/follow_request_fetcher.service.js index ecb6cb7dd..e49206fcd 100644 --- a/src/services/follow_request_fetcher/follow_request_fetcher.service.js +++ b/src/services/follow_request_fetcher/follow_request_fetcher.service.js @@ -4,7 +4,7 @@ import { promiseInterval } from 'src/services/promise_interval/promise_interval. const fetchAndUpdate = ({ store, credentials }) => { return fetchFollowRequests({ credentials }) .then( - (requests) => { + ({ data: requests }) => { store.commit('setFollowRequests', requests) store.commit('addNewUsers', requests) }, diff --git a/src/stores/admin_settings.js b/src/stores/admin_settings.js index 9c9e69d8b..06bcab9ae 100644 --- a/src/stores/admin_settings.js +++ b/src/stores/admin_settings.js @@ -601,7 +601,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', { }).then(({ data }) => data) }, deleteEmojiPack({ name }) { - return createEmojiPack({ + return deleteEmojiPack({ name, credentials: useOAuthStore().token, }).then(({ data }) => data) diff --git a/src/stores/emoji.js b/src/stores/emoji.js index 6ea8d1032..3316f8328 100644 --- a/src/stores/emoji.js +++ b/src/stores/emoji.js @@ -192,7 +192,7 @@ export const useEmojiStore = defineStore('emoji', { listEmojiPacks({ ...params, credentials: useOAuthStore().token, - }), + }).then(({ data }) => data), ) this.adminPacksLocalLoading = false }, @@ -210,10 +210,6 @@ export const useEmojiStore = defineStore('emoji', { pageSize: 0, }) .then((data) => { - if (data.error !== undefined) { - return Promise.reject(data.error) - } - const promises = [] for (let i = 0; i < Math.ceil(data.count / pageSize); i++) { @@ -223,10 +219,6 @@ export const useEmojiStore = defineStore('emoji', { page: i, pageSize, }).then((pageData) => { - if (pageData.error !== undefined) { - return Promise.reject(pageData.error) - } - return pageData.packs }), ) diff --git a/src/stores/instance.js b/src/stores/instance.js index 08bcde1ae..ea3419e80 100644 --- a/src/stores/instance.js +++ b/src/stores/instance.js @@ -211,9 +211,10 @@ export const useInstanceStore = defineStore('instance', { }, async getKnownDomains() { try { - this.knownDomains = await fetchKnownDomains({ + const { data } = await fetchKnownDomains({ credentials: window.vuex.state.users.currentUser.credentials, }) + this.knownDomains = data } catch (e) { console.warn("Can't load known domains\n", e) } diff --git a/src/stores/lists.js b/src/stores/lists.js index 6bafbde7a..7634f1061 100644 --- a/src/stores/lists.js +++ b/src/stores/lists.js @@ -54,7 +54,7 @@ export const useListsStore = defineStore('lists', { return await createList({ title, credentials: useOAuthStore().token, - }).then((list) => { + }).then(({ data: list }) => { this.setList({ listId: list.id, title }) return list }) @@ -63,13 +63,15 @@ export const useListsStore = defineStore('lists', { return await getList({ listId, credentials: useOAuthStore().token, - }).then((list) => this.setList({ listId: list.id, title: list.title })) + }).then(({ data: list }) => + this.setList({ listId: list.id, title: list.title }), + ) }, async fetchListAccounts({ listId }) { return await getListAccounts({ listId, credentials: useOAuthStore().token, - }).then((accountIds) => { + }).then(({ data: accountIds }) => { if (!this.allListsObject[listId]) { this.allListsObject[listId] = { accountIds: [] } } diff --git a/src/stores/oauth_tokens.js b/src/stores/oauth_tokens.js index afbbb5f46..10aa371f9 100644 --- a/src/stores/oauth_tokens.js +++ b/src/stores/oauth_tokens.js @@ -20,8 +20,8 @@ export const useOAuthTokensStore = defineStore('oauthTokens', { revokeOAuthToken({ id, credentials: useOAuthStore().token, - }).then((response) => { - if (response.status === 201) { + }).then(({ status }) => { + if (status === 201) { this.swapTokens(this.tokens.filter((token) => token.id !== id)) } }) diff --git a/src/stores/polls.js b/src/stores/polls.js index 1a1e8e332..e2f4b0ab2 100644 --- a/src/stores/polls.js +++ b/src/stores/polls.js @@ -27,7 +27,7 @@ export const usePollsStore = defineStore('polls', { fetchPoll({ pollId, credentials: useOAuthStore().token, - }).then((poll) => { + }).then(({ data: poll }) => { setTimeout(() => { if (this.trackedPolls[pollId]) { this.updateTrackedPoll(pollId) diff --git a/src/stores/user_highlight.js b/src/stores/user_highlight.js index ca334f579..b056ca808 100644 --- a/src/stores/user_highlight.js +++ b/src/stores/user_highlight.js @@ -350,7 +350,7 @@ export const useUserHighlightStore = defineStore('user_highlight', { updateProfileJSON({ params, credentials: useOAuthStore().token, - }).then((user) => { + }).then(({ data: user }) => { this.initUserHighlight(user) this.dirty = false })