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
|
|
@ -1,4 +1,3 @@
|
|||
import { fetchTimeline } from 'src/api/public.js'
|
||||
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
||||
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
|
|
@ -6,6 +5,8 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j
|
|||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||
|
||||
import { fetchTimeline } from 'src/api/public.js'
|
||||
|
||||
const update = ({ store, notifications, older }) => {
|
||||
store.dispatch('addNewNotifications', { notifications, older })
|
||||
}
|
||||
|
|
@ -97,6 +98,7 @@ const fetchNotifications = ({ store, args, older }) => {
|
|||
throw new Error(`${response.status} ${response.statusText}`)
|
||||
}
|
||||
}
|
||||
|
||||
const notifications = response.data
|
||||
update({ store, notifications, older })
|
||||
return notifications
|
||||
|
|
|
|||
|
|
@ -37,15 +37,16 @@ const postStatus = ({
|
|||
preview,
|
||||
idempotencyKey,
|
||||
})
|
||||
.then((data) => {
|
||||
if (!data.error && !preview) {
|
||||
store.dispatch('addNewStatuses', {
|
||||
statuses: [data],
|
||||
timeline: 'friends',
|
||||
showImmediately: true,
|
||||
noIdUpdate: true, // To prevent missing notices on next pull.
|
||||
})
|
||||
}
|
||||
.then(({ data }) => {
|
||||
if (preview) return data
|
||||
|
||||
store.dispatch('addNewStatuses', {
|
||||
statuses: [data],
|
||||
timeline: 'friends',
|
||||
showImmediately: true,
|
||||
noIdUpdate: true, // To prevent missing notices on next pull.
|
||||
})
|
||||
|
||||
return data
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
@ -67,7 +68,7 @@ const editStatus = ({
|
|||
}) => {
|
||||
const mediaIds = map(media, 'id')
|
||||
|
||||
return editStatus({
|
||||
return apiEditStatus({
|
||||
id: statusId,
|
||||
credentials: store.state.users.currentUser.credentials,
|
||||
status,
|
||||
|
|
@ -77,15 +78,14 @@ const editStatus = ({
|
|||
mediaIds,
|
||||
contentType,
|
||||
})
|
||||
.then((data) => {
|
||||
if (!data.error) {
|
||||
store.dispatch('addNewStatuses', {
|
||||
statuses: [data],
|
||||
timeline: 'friends',
|
||||
showImmediately: true,
|
||||
noIdUpdate: true, // To prevent missing notices on next pull.
|
||||
})
|
||||
}
|
||||
.then(({ data }) => {
|
||||
store.dispatch('addNewStatuses', {
|
||||
statuses: [data],
|
||||
timeline: 'friends',
|
||||
showImmediately: true,
|
||||
noIdUpdate: true, // To prevent missing notices on next pull.
|
||||
})
|
||||
|
||||
return data
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
@ -98,12 +98,14 @@ const editStatus = ({
|
|||
|
||||
const uploadMedia = ({ store, formData }) => {
|
||||
const credentials = store.state.users.currentUser.credentials
|
||||
return apiUploadMedia({ credentials, formData })
|
||||
return apiUploadMedia({ credentials, formData }).then(({ data }) => data)
|
||||
}
|
||||
|
||||
const setMediaDescription = ({ store, id, description }) => {
|
||||
const credentials = store.state.users.currentUser.credentials
|
||||
return apiSetMediaDescription({ credentials, id, description })
|
||||
return apiSetMediaDescription({ credentials, id, description }).then(
|
||||
({ data }) => data,
|
||||
)
|
||||
}
|
||||
|
||||
const statusPosterService = {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import { camelCase } from 'lodash'
|
||||
|
||||
import { fetchTimeline } from 'src/api/public.js'
|
||||
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
||||
|
||||
import { useInstanceStore } from 'src/stores/instance.js'
|
||||
|
|
@ -8,6 +7,8 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j
|
|||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||
|
||||
import { fetchTimeline } from 'src/api/public.js'
|
||||
|
||||
const update = ({
|
||||
store,
|
||||
statuses,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue