missing { data } extraction

This commit is contained in:
Henry Jameson 2026-06-22 19:44:44 +03:00
commit a39d3b1b56
23 changed files with 44 additions and 48 deletions

View file

@ -27,7 +27,7 @@ const BookmarkFolderEdit = {
fetchBookmarkFolders({ fetchBookmarkFolders({
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((folders) => { }).then(({ data: folders }) => {
const folder = folders.find((folder) => folder.id === this.id) const folder = folders.find((folder) => folder.id === this.id)
if (!folder) return if (!folder) return

View file

@ -278,7 +278,7 @@ const Chat = {
maxId, maxId,
sinceId, sinceId,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((messages) => { }).then(({ data: messages }) => {
// Clear the current chat in case we're recovering from a ws connection loss. // Clear the current chat in case we're recovering from a ws connection loss.
if (isFirstFetch) { if (isFirstFetch) {
chatService.clear(chatMessageService) chatService.clear(chatMessageService)
@ -310,10 +310,11 @@ const Chat = {
let chat = this.findOpenedChatByRecipientId(this.recipientId) let chat = this.findOpenedChatByRecipientId(this.recipientId)
if (!chat) { if (!chat) {
try { try {
chat = await getOrCreateChat({ const { data } = await getOrCreateChat({
accountId: this.recipientId, accountId: this.recipientId,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}) })
chat = data
} catch (e) { } catch (e) {
console.error('Error creating or getting a chat', e) console.error('Error creating or getting a chat', e)
this.errorLoadingChat = true this.errorLoadingChat = true
@ -383,7 +384,7 @@ const Chat = {
params, params,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}) })
.then((data) => { .then(({ data }) => {
this.$store.dispatch('addChatMessages', { this.$store.dispatch('addChatMessages', {
chatId: this.currentChat.id, chatId: this.currentChat.id,
updateMaxId: false, updateMaxId: false,

View file

@ -16,7 +16,7 @@ const RemoteUserResolver = {
id, id,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}) })
.then((externalUser) => { .then(({ data: externalUser }) => {
if (externalUser.error) { if (externalUser.error) {
this.error = true this.error = true
} else { } else {

View file

@ -490,7 +490,7 @@ const AppearanceTab = {
background, background,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}) })
.then((data) => { .then(({ data }) => {
this.$store.commit('addNewUsers', [data]) this.$store.commit('addNewUsers', [data])
this.$store.commit('setCurrentUser', data) this.$store.commit('setCurrentUser', data)
this.backgroundPreview = null this.backgroundPreview = null

View file

@ -169,7 +169,7 @@ const ComposingTab = {
updateProfile({ updateProfile({
params, params,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((user) => { }).then(({ data: user }) => {
this.$store.commit('addNewUsers', [user]) this.$store.commit('addNewUsers', [user])
this.$store.commit('setCurrentUser', user) this.$store.commit('setCurrentUser', user)
}) })

View file

@ -64,7 +64,7 @@ const DataImportExportTab = {
return importFollows({ return importFollows({
file, file,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((status) => { }).then(({ data: status }) => {
if (!status) { if (!status) {
throw new Error('failed') throw new Error('failed')
} }
@ -74,7 +74,7 @@ const DataImportExportTab = {
return importBlocks({ return importBlocks({
file, file,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((status) => { }).then(({ data: status }) => {
if (!status) { if (!status) {
throw new Error('failed') throw new Error('failed')
} }
@ -84,13 +84,13 @@ const DataImportExportTab = {
return importMutes({ return importMutes({
file, file,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((status) => { }).then(({ data: status }) => {
if (!status) { if (!status) {
throw new Error('failed') throw new Error('failed')
} }
}) })
}, },
generateExportableUsersContent(users) { generateExportableUsersContent({ data: users }) {
// Get addresses // Get addresses
return users return users
.map((user) => { .map((user) => {
@ -121,7 +121,7 @@ const DataImportExportTab = {
listBackups({ listBackups({
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}) })
.then((res) => { .then(({ data: res }) => {
this.backups = res this.backups = res
this.listBackupsError = false this.listBackupsError = false
}) })

View file

@ -63,7 +63,7 @@ const GeneralTab = {
updateProfile({ updateProfile({
params, params,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((user) => { }).then(({ data: user }) => {
this.$store.commit('addNewUsers', [user]) this.$store.commit('addNewUsers', [user])
this.$store.commit('setCurrentUser', user) this.$store.commit('setCurrentUser', user)
}) })

View file

@ -60,7 +60,7 @@ const MutesAndBlocks = {
return importFollows({ return importFollows({
file, file,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((status) => { }).then(({ data: status }) => {
if (!status) { if (!status) {
throw new Error('failed') throw new Error('failed')
} }
@ -70,7 +70,7 @@ const MutesAndBlocks = {
return importBlocks({ return importBlocks({
file, file,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((status) => { }).then(({ data: status }) => {
if (!status) { if (!status) {
throw new Error('failed') throw new Error('failed')
} }

View file

@ -43,7 +43,7 @@ const ProfileTab = {
params, params,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}) })
.then((user) => { .then(({ data: user }) => {
this.$store.commit('addNewUsers', [user]) this.$store.commit('addNewUsers', [user])
this.$store.commit('setCurrentUser', user) this.$store.commit('setCurrentUser', user)
}) })

View file

@ -40,7 +40,7 @@ export default {
mfaDisableOTP({ mfaDisableOTP({
password: this.currentPassword, password: this.currentPassword,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((res) => { }).then(({ data: res }) => {
this.inProgress = false this.inProgress = false
if (res.error) { if (res.error) {
this.error = res.error this.error = res.error

View file

@ -78,7 +78,7 @@ const SecurityTab = {
deleteAccount({ deleteAccount({
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
password: this.deleteAccountConfirmPasswordInput, password: this.deleteAccountConfirmPasswordInput,
}).then((res) => { }).then(({ data: res }) => {
if (res.status === 'success') { if (res.status === 'success') {
this.$store.dispatch('logout') this.$store.dispatch('logout')
this.$router.push({ name: 'root' }) this.$router.push({ name: 'root' })
@ -94,7 +94,7 @@ const SecurityTab = {
newPasswordConfirmation: this.changePasswordInputs[2], newPasswordConfirmation: this.changePasswordInputs[2],
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
} }
changePassword(params).then((res) => { changePassword(params).then(({ data: res }) => {
if (res.status === 'success') { if (res.status === 'success') {
this.changedPassword = true this.changedPassword = true
this.changePasswordError = false this.changePasswordError = false
@ -111,7 +111,7 @@ const SecurityTab = {
password: this.changeEmailPassword, password: this.changeEmailPassword,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
} }
changeEmail(params).then((res) => { changeEmail(params).then(({ data: res }) => {
if (res.status === 'success') { if (res.status === 'success') {
this.changedEmail = true this.changedEmail = true
this.changeEmailError = false this.changeEmailError = false
@ -127,7 +127,7 @@ const SecurityTab = {
password: this.moveAccountPassword, password: this.moveAccountPassword,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
} }
moveAccount(params).then((res) => { moveAccount(params).then(({ data: res }) => {
if (res.status === 'success') { if (res.status === 'success') {
this.movedAccount = true this.movedAccount = true
this.moveAccountError = false this.moveAccountError = false
@ -163,7 +163,7 @@ const SecurityTab = {
listAliases({ listAliases({
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}) })
.then((res) => { .then(({ data: res }) => {
this.aliases = res.aliases this.aliases = res.aliases
this.listAliasesError = false this.listAliasesError = false
}) })

View file

@ -600,7 +600,7 @@ export default {
} }
updateProfile({ params }) updateProfile({ params })
.then((user) => { .then(({ data: user }) => {
this.newFields.splice(this.newFields.length) this.newFields.splice(this.newFields.length)
merge(this.newFields, user.fields) merge(this.newFields, user.fields)
this.$store.commit('addNewUsers', [user]) this.$store.commit('addNewUsers', [user])

View file

@ -23,7 +23,7 @@ const WhoToFollow = {
fetchUser({ fetchUser({
id, id,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((externalUser) => { }).then(({ data: externalUser }) => {
if (!externalUser.error) { if (!externalUser.error) {
this.$store.commit('addNewUsers', [externalUser]) this.$store.commit('addNewUsers', [externalUser])
this.users.push(externalUser) this.users.push(externalUser)
@ -34,7 +34,7 @@ const WhoToFollow = {
getWhoToFollow() { getWhoToFollow() {
const credentials = useOAuthStore().token const credentials = useOAuthStore().token
if (credentials) { if (credentials) {
suggestions({ credentials }).then((reply) => { suggestions({ credentials }).then(({ data: reply }) => {
this.showWhoToFollow(reply) this.showWhoToFollow(reply)
}) })
} }

View file

@ -21,7 +21,7 @@ function showWhoToFollow(panel, reply) {
fetchUser({ fetchUser({
id: name, id: name,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((externalUser) => { }).then(({ data: externalUser }) => {
if (!externalUser.error) { if (!externalUser.error) {
panel.$store.commit('addNewUsers', [externalUser]) panel.$store.commit('addNewUsers', [externalUser])
toFollow.id = externalUser.id toFollow.id = externalUser.id
@ -36,7 +36,7 @@ function getWhoToFollow(panel) {
panel.usersToFollow.forEach((toFollow) => { panel.usersToFollow.forEach((toFollow) => {
toFollow.name = 'Loading...' toFollow.name = 'Loading...'
}) })
suggestions({ credentials }).then((reply) => { suggestions({ credentials }).then(({ data: reply }) => {
showWhoToFollow(panel, reply) showWhoToFollow(panel, reply)
}) })
} }

View file

@ -10,7 +10,7 @@ const defaultApi = ({ rootState, commit }, { path, value }) => {
return updateProfile({ return updateProfile({
params, params,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((result) => { }).then(({ data: result }) => {
commit('addNewUsers', [result]) commit('addNewUsers', [result])
commit('setCurrentUser', result) commit('setCurrentUser', result)
}) })
@ -22,7 +22,7 @@ const notificationsApi = ({ rootState, commit }, { path, value, oldValue }) => {
return updateNotificationSettings({ return updateNotificationSettings({
settings, settings,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((result) => { }).then(({ data: result }) => {
if (result.status === 'success') { if (result.status === 'success') {
commit('confirmProfileOption', { name, value }) commit('confirmProfileOption', { name, value })
} else { } else {

View file

@ -4,7 +4,7 @@ import { promiseInterval } from 'src/services/promise_interval/promise_interval.
const fetchAndUpdate = ({ store, credentials }) => { const fetchAndUpdate = ({ store, credentials }) => {
return fetchFollowRequests({ credentials }) return fetchFollowRequests({ credentials })
.then( .then(
(requests) => { ({ data: requests }) => {
store.commit('setFollowRequests', requests) store.commit('setFollowRequests', requests)
store.commit('addNewUsers', requests) store.commit('addNewUsers', requests)
}, },

View file

@ -601,7 +601,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
}).then(({ data }) => data) }).then(({ data }) => data)
}, },
deleteEmojiPack({ name }) { deleteEmojiPack({ name }) {
return createEmojiPack({ return deleteEmojiPack({
name, name,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then(({ data }) => data) }).then(({ data }) => data)

View file

@ -192,7 +192,7 @@ export const useEmojiStore = defineStore('emoji', {
listEmojiPacks({ listEmojiPacks({
...params, ...params,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}), }).then(({ data }) => data),
) )
this.adminPacksLocalLoading = false this.adminPacksLocalLoading = false
}, },
@ -210,10 +210,6 @@ export const useEmojiStore = defineStore('emoji', {
pageSize: 0, pageSize: 0,
}) })
.then((data) => { .then((data) => {
if (data.error !== undefined) {
return Promise.reject(data.error)
}
const promises = [] const promises = []
for (let i = 0; i < Math.ceil(data.count / pageSize); i++) { for (let i = 0; i < Math.ceil(data.count / pageSize); i++) {
@ -223,10 +219,6 @@ export const useEmojiStore = defineStore('emoji', {
page: i, page: i,
pageSize, pageSize,
}).then((pageData) => { }).then((pageData) => {
if (pageData.error !== undefined) {
return Promise.reject(pageData.error)
}
return pageData.packs return pageData.packs
}), }),
) )

View file

@ -211,9 +211,10 @@ export const useInstanceStore = defineStore('instance', {
}, },
async getKnownDomains() { async getKnownDomains() {
try { try {
this.knownDomains = await fetchKnownDomains({ const { data } = await fetchKnownDomains({
credentials: window.vuex.state.users.currentUser.credentials, credentials: window.vuex.state.users.currentUser.credentials,
}) })
this.knownDomains = data
} catch (e) { } catch (e) {
console.warn("Can't load known domains\n", e) console.warn("Can't load known domains\n", e)
} }

View file

@ -54,7 +54,7 @@ export const useListsStore = defineStore('lists', {
return await createList({ return await createList({
title, title,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((list) => { }).then(({ data: list }) => {
this.setList({ listId: list.id, title }) this.setList({ listId: list.id, title })
return list return list
}) })
@ -63,13 +63,15 @@ export const useListsStore = defineStore('lists', {
return await getList({ return await getList({
listId, listId,
credentials: useOAuthStore().token, 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 }) { async fetchListAccounts({ listId }) {
return await getListAccounts({ return await getListAccounts({
listId, listId,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((accountIds) => { }).then(({ data: accountIds }) => {
if (!this.allListsObject[listId]) { if (!this.allListsObject[listId]) {
this.allListsObject[listId] = { accountIds: [] } this.allListsObject[listId] = { accountIds: [] }
} }

View file

@ -20,8 +20,8 @@ export const useOAuthTokensStore = defineStore('oauthTokens', {
revokeOAuthToken({ revokeOAuthToken({
id, id,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((response) => { }).then(({ status }) => {
if (response.status === 201) { if (status === 201) {
this.swapTokens(this.tokens.filter((token) => token.id !== id)) this.swapTokens(this.tokens.filter((token) => token.id !== id))
} }
}) })

View file

@ -27,7 +27,7 @@ export const usePollsStore = defineStore('polls', {
fetchPoll({ fetchPoll({
pollId, pollId,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((poll) => { }).then(({ data: poll }) => {
setTimeout(() => { setTimeout(() => {
if (this.trackedPolls[pollId]) { if (this.trackedPolls[pollId]) {
this.updateTrackedPoll(pollId) this.updateTrackedPoll(pollId)

View file

@ -350,7 +350,7 @@ export const useUserHighlightStore = defineStore('user_highlight', {
updateProfileJSON({ updateProfileJSON({
params, params,
credentials: useOAuthStore().token, credentials: useOAuthStore().token,
}).then((user) => { }).then(({ data: user }) => {
this.initUserHighlight(user) this.initUserHighlight(user)
this.dirty = false this.dirty = false
}) })