some initial API refactoring

This commit is contained in:
Henry Jameson 2026-06-13 03:10:00 +03:00
commit 4a59c42395
20 changed files with 1368 additions and 1567 deletions

View file

@ -1,4 +1,4 @@
import apiService from '../services/api/api.service.js'
import { markNotificationsAsSeen } from '../services/api/api.service.js'
import {
closeAllDesktopNotifications,
closeDesktopNotification,
@ -154,26 +154,22 @@ export const notifications = {
},
markNotificationsAsSeen({ rootState, state, commit }) {
commit('markNotificationsAsSeen')
apiService
.markNotificationsAsSeen({
id: state.maxId,
credentials: rootState.users.currentUser.credentials,
})
.then(() => {
closeAllDesktopNotifications(rootState)
})
markNotificationsAsSeen({
id: state.maxId,
credentials: rootState.users.currentUser.credentials,
}).then(() => {
closeAllDesktopNotifications(rootState)
})
},
markSingleNotificationAsSeen({ rootState, commit }, { id }) {
commit('markSingleNotificationAsSeen', { id })
apiService
.markNotificationsAsSeen({
single: true,
id,
credentials: rootState.users.currentUser.credentials,
})
.then(() => {
closeDesktopNotification(rootState, { id })
})
markNotificationsAsSeen({
single: true,
id,
credentials: rootState.users.currentUser.credentials,
}).then(() => {
closeDesktopNotification(rootState, { id })
})
},
dismissNotificationLocal({ commit }, { id }) {
commit('dismissNotification', { id })

View file

@ -13,7 +13,12 @@ import {
slice,
} from 'lodash'
import apiService from '../services/api/api.service.js'
import {
deleteStatus,
fetchScrobbles,
fetchStatusHistory,
fetchStatusSource,
} from '../services/api/api.service.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useInterfaceStore } from 'src/stores/interface.js'
@ -131,8 +136,7 @@ const getLatestScrobble = (state, user) => {
state.scrobblesNextFetch[user.id] = Date.now() + 24 * 60 * 60 * 1000
if (!scrobblesSupport) return
apiService
.fetchScrobbles({ accountId: user.id })
fetchScrobbles({ accountId: user.id })
.then((scrobbles) => {
if (scrobbles?.error) {
useInstanceCapabilitiesStore().set('pleromaScrobblesAvailable', false)
@ -607,20 +611,19 @@ const statuses = {
.then((status) => dispatch('addNewStatuses', { statuses: [status] }))
},
fetchStatusSource({ rootState }, status) {
return apiService.fetchStatusSource({
return fetchStatusSource({
id: status.id,
credentials: rootState.users.currentUser.credentials,
})
},
fetchStatusHistory(_, status) {
return apiService.fetchStatusHistory({ status })
return fetchStatusHistory({ status })
},
deleteStatus({ rootState, commit }, status) {
apiService
.deleteStatus({
id: status.id,
credentials: rootState.users.currentUser.credentials,
})
deleteStatus({
id: status.id,
credentials: rootState.users.currentUser.credentials,
})
.then(() => {
commit('setDeleted', { status })
})

View file

@ -9,7 +9,7 @@ import {
uniq,
} from 'lodash'
import apiService from '../services/api/api.service.js'
import { register } from '../services/api/api.service.js'
import backendInteractorService from '../services/backend_interactor_service/backend_interactor_service.js'
import oauthApi from '../services/new_api/oauth.js'
import {
@ -624,7 +624,7 @@ const users = {
try {
const token = await oauthStore.ensureAppToken()
const data = await apiService.register({
const data = await register({
credentials: token,
params: { ...userInfo },
})