refactor promisedRequest to always return whole response
This commit is contained in:
parent
c81813064b
commit
1ca0ffb1f0
25 changed files with 352 additions and 327 deletions
|
|
@ -87,7 +87,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
loadAdminStuff() {
|
||||
getInstanceDBConfig({
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((backendDbConfig) => {
|
||||
}).then(({ data: backendDbConfig }) => {
|
||||
if (backendDbConfig.error) {
|
||||
if (backendDbConfig.error.status === 400) {
|
||||
backendDbConfig.error.json().then((errorJson) => {
|
||||
|
|
@ -106,7 +106,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
if (this.descriptions === null) {
|
||||
getInstanceConfigDescriptions({
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((backendDescriptions) =>
|
||||
}).then(({ data: backendDescriptions }) =>
|
||||
this.setInstanceAdminDescriptions({
|
||||
credentials: useOAuthStore().token,
|
||||
backendDescriptions,
|
||||
|
|
@ -251,7 +251,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
.then(() =>
|
||||
getInstanceDBConfig({
|
||||
credentials: useOAuthStore().token,
|
||||
}),
|
||||
}).then(({ data }) => data),
|
||||
)
|
||||
.then((backendDbConfig) =>
|
||||
this.setInstanceAdminSettings({
|
||||
|
|
@ -294,7 +294,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
.then(() =>
|
||||
getInstanceDBConfig({
|
||||
credentials: useOAuthStore().token,
|
||||
}),
|
||||
}).then(({ data }) => data),
|
||||
)
|
||||
.then((backendDbConfig) =>
|
||||
this.setInstanceAdminSettings({
|
||||
|
|
@ -326,7 +326,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
.then(() =>
|
||||
getInstanceDBConfig({
|
||||
credentials: useOAuthStore().token,
|
||||
}),
|
||||
}).then(({ data }) => data),
|
||||
)
|
||||
.then((backendDbConfig) =>
|
||||
this.setInstanceAdminSettings({ backendDbConfig }),
|
||||
|
|
@ -337,7 +337,9 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
loadFrontendsStuff() {
|
||||
getAvailableFrontends({
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((frontends) => this.setAvailableFrontends({ frontends }))
|
||||
}).then(({ data: frontends }) =>
|
||||
this.setAvailableFrontends({ frontends }),
|
||||
)
|
||||
},
|
||||
|
||||
setAvailableFrontends({ frontends }) {
|
||||
|
|
@ -355,12 +357,14 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
installFrontend() {
|
||||
return installFrontend({
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
|
||||
// Statuses stuff
|
||||
async fetchStatuses(opts) {
|
||||
const { total, activities } = await listStatuses({
|
||||
const {
|
||||
data: { total, activities },
|
||||
} = await listStatuses({
|
||||
credentials: useOAuthStore().token,
|
||||
opts,
|
||||
})
|
||||
|
|
@ -375,20 +379,21 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
}
|
||||
},
|
||||
async changeStatusScope(opts) {
|
||||
const raw = await changeStatusScope({
|
||||
const { data } = await changeStatusScope({
|
||||
credentials: useOAuthStore().token,
|
||||
opts,
|
||||
})
|
||||
const status = parseStatus(raw)
|
||||
const status = parseStatus(data)
|
||||
|
||||
await window.vuex.dispatch('addNewStatuses', { statuses: [status] })
|
||||
},
|
||||
|
||||
// Users stuff
|
||||
async fetchUsers(opts) {
|
||||
const { users, count } = await listUsers({
|
||||
const {
|
||||
data: { users, count },
|
||||
} = await listUsers({
|
||||
credentials: useOAuthStore().token,
|
||||
|
||||
opts,
|
||||
})
|
||||
|
||||
|
|
@ -412,7 +417,8 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
credentials: useOAuthStore().token,
|
||||
screen_name,
|
||||
})
|
||||
window.vuex.commit('updateUserAdminData', { user: result })
|
||||
|
||||
window.vuex.commit('updateUserAdminData', { user: result.data })
|
||||
},
|
||||
async deleteUsers({ users }) {
|
||||
const screen_names = users.map((u) => u.screen_name)
|
||||
|
|
@ -423,7 +429,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
screen_names,
|
||||
})
|
||||
|
||||
resultUserIds.forEach((userId) => {
|
||||
resultUserIds.data.forEach((userId) => {
|
||||
window.vuex.dispatch(
|
||||
'markStatusesAsDeleted',
|
||||
(status) => userId === status.user.id,
|
||||
|
|
@ -439,7 +445,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
return resendConfirmationEmail({
|
||||
credentials: useOAuthStore().token,
|
||||
screen_names,
|
||||
})
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
requirePasswordChange({ users }) {
|
||||
const screen_names = users.map((u) => u.screen_name)
|
||||
|
|
@ -447,7 +453,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
return requirePasswordChange({
|
||||
credentials: useOAuthStore().token,
|
||||
screen_names,
|
||||
})
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
// Singular only!
|
||||
disableMFA({ user }) {
|
||||
|
|
@ -456,7 +462,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
return disableMFA({
|
||||
credentials: useOAuthStore().token,
|
||||
screen_name,
|
||||
})
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
async setUsersTags({ users, tags, value }) {
|
||||
const screen_names = users.map((u) => u.screen_name)
|
||||
|
|
@ -498,7 +504,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
value,
|
||||
})
|
||||
|
||||
resultUsers.forEach((user) => {
|
||||
resultUsers.data.forEach((user) => {
|
||||
window.vuex.commit('updateUserAdminData', { user })
|
||||
})
|
||||
},
|
||||
|
|
@ -512,7 +518,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
value,
|
||||
})
|
||||
|
||||
resultUsers.forEach((user) => {
|
||||
resultUsers.data.forEach((user) => {
|
||||
window.vuex.commit('updateUserAdminData', { user })
|
||||
})
|
||||
},
|
||||
|
|
@ -538,27 +544,31 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
screen_names,
|
||||
})
|
||||
|
||||
resultUsers.forEach((user) => {
|
||||
resultUsers.data.forEach((user) => {
|
||||
window.vuex.commit('updateUserAdminData', { user })
|
||||
})
|
||||
},
|
||||
reloadEmoji() {
|
||||
return reloadEmoji({ credentials: useOAuthStore().token })
|
||||
return reloadEmoji({ credentials: useOAuthStore().token }).then(
|
||||
({ data }) => data,
|
||||
)
|
||||
},
|
||||
importEmojiFromFS() {
|
||||
return importEmojiFromFS({ credentials: useOAuthStore().token })
|
||||
return importEmojiFromFS({ credentials: useOAuthStore().token }).then(
|
||||
({ data }) => data,
|
||||
)
|
||||
},
|
||||
listEmojiPacks(params) {
|
||||
return listEmojiPacks({
|
||||
...params,
|
||||
credentials: useOAuthStore().token
|
||||
})
|
||||
credentials: useOAuthStore().token,
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
listRemoteEmojiPacks(params) {
|
||||
return listRemoteEmojiPacks({
|
||||
...params,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
addNewEmojiFile({ packName, file, shortcode, filename }) {
|
||||
return addNewEmojiFile({
|
||||
|
|
@ -567,7 +577,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
shortcode,
|
||||
filename,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
downloadRemoteEmojiPack({ instance, packName, as }) {
|
||||
return downloadRemoteEmojiPack({
|
||||
|
|
@ -575,33 +585,33 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
packName,
|
||||
as,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
downloadRemoteEmojiPackZIP({ url, packName }) {
|
||||
return downloadRemoteEmojiPackZIP({
|
||||
url,
|
||||
packName,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
createEmojiPack({ name }) {
|
||||
return createEmojiPack({
|
||||
name,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
deleteEmojiPack({ name }) {
|
||||
return createEmojiPack({
|
||||
name,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
saveEmojiPackMetadata({ name, newData }) {
|
||||
return createEmojiPack({
|
||||
name,
|
||||
newData,
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
}).then(({ data }) => data)
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
|||
|
|
@ -44,15 +44,16 @@ export const useAnnouncementsStore = defineStore('announcements', {
|
|||
|
||||
const fetchAnnouncements = async () => {
|
||||
if (!isAdmin) {
|
||||
return getAnnouncements({
|
||||
const result = await getAnnouncements({
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
return result.data
|
||||
}
|
||||
|
||||
const all = await adminGetAnnouncements({
|
||||
const { data: all } = await adminGetAnnouncements({
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
const visible = await getAnnouncements({
|
||||
const { data: visible } = await getAnnouncements({
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
const visibleObject = visible.reduce((a, c) => {
|
||||
|
|
|
|||
|
|
@ -31,10 +31,7 @@ export const useBookmarkFoldersStore = defineStore('bookmarkFolders', {
|
|||
this.fetcher = fetchBookmarkFolders({
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
.then(
|
||||
(folders) => this.setBookmarkFolders(folders),
|
||||
(rej) => console.error(rej),
|
||||
)
|
||||
.then(({ data: folders }) => this.setBookmarkFolders(folders))
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
})
|
||||
|
|
@ -61,7 +58,7 @@ export const useBookmarkFoldersStore = defineStore('bookmarkFolders', {
|
|||
name,
|
||||
emoji,
|
||||
credentials: useOAuthStore().token,
|
||||
}).then((folder) => {
|
||||
}).then(({ data: folder }) => {
|
||||
this.setBookmarkFolder(folder)
|
||||
return folder
|
||||
})
|
||||
|
|
@ -72,7 +69,7 @@ export const useBookmarkFoldersStore = defineStore('bookmarkFolders', {
|
|||
folderId,
|
||||
name,
|
||||
emoji,
|
||||
}).then((folder) => {
|
||||
}).then(({ data: folder }) => {
|
||||
this.setBookmarkFolder(folder)
|
||||
return folder
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
import { merge } from 'lodash'
|
||||
import { defineStore } from 'pinia'
|
||||
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
|
||||
import { ensureFinalFallback } from 'src/i18n/languages.js'
|
||||
import { listEmojiPacks } from 'src/api/public.js'
|
||||
import { ensureFinalFallback } from 'src/i18n/languages.js'
|
||||
|
||||
import { annotationsLoader } from 'virtual:pleroma-fe/emoji-annotations'
|
||||
|
||||
|
|
@ -188,7 +188,8 @@ export const useEmojiStore = defineStore('emoji', {
|
|||
this.adminPacksLocalLoading = true
|
||||
this.adminPacksLocal = await this.getAdminPacks(
|
||||
useInstanceStore().server,
|
||||
(params) => listEmojiPacks({
|
||||
(params) =>
|
||||
listEmojiPacks({
|
||||
...params,
|
||||
credentials: useOAuthStore().token,
|
||||
}),
|
||||
|
|
@ -221,14 +222,13 @@ export const useEmojiStore = defineStore('emoji', {
|
|||
instance,
|
||||
page: i,
|
||||
pageSize,
|
||||
})
|
||||
.then((pageData) => {
|
||||
if (pageData.error !== undefined) {
|
||||
return Promise.reject(pageData.error)
|
||||
}
|
||||
}).then((pageData) => {
|
||||
if (pageData.error !== undefined) {
|
||||
return Promise.reject(pageData.error)
|
||||
}
|
||||
|
||||
return pageData.packs
|
||||
}),
|
||||
return pageData.packs
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,10 +11,11 @@ import {
|
|||
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
|
||||
validateSetting,
|
||||
} from '../modules/default_config_state.js'
|
||||
import { fetchKnownDomains } from 'src/api/public.js'
|
||||
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
|
||||
import { fetchKnownDomains } from 'src/api/public.js'
|
||||
|
||||
const REMOTE_INTERACTION_URL = '/main/ostatus'
|
||||
|
||||
const ROOT_STATE_DEFINITIONS = {
|
||||
|
|
|
|||
|
|
@ -38,10 +38,7 @@ export const useListsStore = defineStore('lists', {
|
|||
this.fetcher = fetchLists({
|
||||
credentials: useOAuthStore().token,
|
||||
})
|
||||
.then(
|
||||
(lists) => this.setLists(lists),
|
||||
(rej) => console.error(rej),
|
||||
)
|
||||
.then(({ data: lists }) => this.setLists(lists))
|
||||
.catch((e) => {
|
||||
console.error(e)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -20,10 +20,11 @@ import { toRaw } from 'vue'
|
|||
|
||||
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
|
||||
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
|
||||
import { updateProfileJSON } from 'src/api/user.js'
|
||||
import { storage } from 'src/lib/storage.js'
|
||||
import {
|
||||
makeUndefined,
|
||||
|
|
@ -32,7 +33,6 @@ import {
|
|||
validateSetting,
|
||||
} from 'src/modules/default_config_state.js'
|
||||
import { oldDefaultConfigSync } from 'src/modules/old_default_config_state.js'
|
||||
import { updateProfileJSON } from 'src/api/user.js'
|
||||
|
||||
export const VERSION = 2
|
||||
export const NEW_USER_DATE = new Date('2026-03-16') // date of writing this, basically
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ import { toRaw } from 'vue'
|
|||
|
||||
import { useOAuthStore } from 'src/stores/oauth.js'
|
||||
|
||||
import { storage } from 'src/lib/storage.js'
|
||||
import { updateProfileJSON } from 'src/api/user.js'
|
||||
import { storage } from 'src/lib/storage.js'
|
||||
|
||||
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue