remaining backend interactor removals

This commit is contained in:
Henry Jameson 2026-06-15 20:02:22 +03:00
commit 0d9709825f
45 changed files with 1118 additions and 856 deletions

View file

@ -4,16 +4,26 @@ import { defineStore } from 'pinia'
import { useCredentialsStore } from 'src/stores/credentials.js'
import {
addNewEmojiFile,
changeStatusScope,
createEmojiPack,
deleteAccounts,
deleteEmojiPack,
disableMFA,
downloadRemoteEmojiPack,
downloadRemoteEmojiPackZIP,
getAvailableFrontends,
getInstanceConfigDescriptions,
getInstanceDBConfig,
getUserData,
importEmojiFromFS,
installFrontend,
listEmojiPacks,
listRemoteEmojiPacks,
listStatuses,
listUsers,
pushInstanceDBConfig,
reloadEmoji,
requirePasswordChange,
resendConfirmationEmail,
setUsersActivationStatus,
@ -342,6 +352,12 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
})
},
installFrontend() {
return installFrontend({
credentials: useCredentialsStore().current,
})
},
// Statuses stuff
async fetchStatuses(opts) {
const { total, activities } = await listStatuses({
@ -526,5 +542,62 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
window.vuex.commit('updateUserAdminData', { user })
})
},
reloadEmoji() {
return reloadEmoji({ credentials: useCredentialsStore().current })
},
importEmojiFromFS() {
return importEmojiFromFS({ credentials: useCredentialsStore().current })
},
listEmojiPacks() {
return listEmojiPacks({ credentials: useCredentialsStore().current })
},
listRemoteEmojiPacks() {
return listRemoteEmojiPacks({
credentials: useCredentialsStore().current,
})
},
addNewEmojiFile({ packName, file, shortcode, filename }) {
return addNewEmojiFile({
packName,
file,
shortcode,
filename,
credentials: useCredentialsStore().current,
})
},
downloadRemoteEmojiPack({ instance, packName, as }) {
return downloadRemoteEmojiPack({
instance,
packName,
as,
credentials: useCredentialsStore().current,
})
},
downloadRemoteEmojiPackZIP({ url, packName }) {
return downloadRemoteEmojiPackZIP({
url,
packName,
credentials: useCredentialsStore().current,
})
},
createEmojiPack({ name }) {
return createEmojiPack({
name,
credentials: useCredentialsStore().current,
})
},
deleteEmojiPack({ name }) {
return createEmojiPack({
name,
credentials: useCredentialsStore().current,
})
},
saveEmojiPackMetadata({ name, newData }) {
return createEmojiPack({
name,
newData,
credentials: useCredentialsStore().current,
})
},
},
})

View file

@ -6,8 +6,10 @@ import { useCredentialsStore } from 'src/stores/credentials.js'
import {
createBookmarkFolder,
deleteBookmarkFolder,
fetchBookmarkFolders,
updateBookmarkFolder,
} from 'src/services/api/api.service.js'
import { promiseInterval } from 'src/services/promise_interval/promise_interval.js'
export const useBookmarkFoldersStore = defineStore('bookmarkFolders', {
state: () => ({
@ -24,6 +26,23 @@ export const useBookmarkFoldersStore = defineStore('bookmarkFolders', {
},
},
actions: {
startFetching() {
promiseInterval(() => {
this.fetcher = fetchBookmarkFolders({
credentials: useCredentialsStore().current,
})
.then(
(folders) => this.setBookmarkFolders(folders),
(rej) => console.error(rej),
)
.catch((e) => {
console.error(e)
})
}, 240000)
},
stopFetching() {
this.fetcher?.stop()
},
setBookmarkFolders(value) {
this.allFolders = value
},

View file

@ -1,9 +1,11 @@
import { merge } from 'lodash'
import { defineStore } from 'pinia'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { ensureFinalFallback } from 'src/i18n/languages.js'
import { listEmojiPacks } from 'src/services/api/api.service.js'
import { annotationsLoader } from 'virtual:pleroma-fe/emoji-annotations'
@ -183,13 +185,13 @@ export const useEmojiStore = defineStore('emoji', {
async getAdminPacksLocal(refresh) {
if (!refresh && this.adminPacksLocal) return this.adminPacksLocal
const backendInteractor = window.vuex.state.api.backendInteractor
const listFunction = backendInteractor.listEmojiPacks
this.adminPacksLocalLoading = true
this.adminPacksLocal = await this.getAdminPacks(
useInstanceStore().server,
listFunction,
() =>
listEmojiPacks({
credentials: useCredentialsStore().current,
}),
)
this.adminPacksLocalLoading = false
},

View file

@ -1,8 +1,23 @@
import { find, remove } from 'lodash'
import { defineStore } from 'pinia'
import { useCredentialsStore } from 'src/stores/credentials.js'
import {
addAccountsToList,
createList,
deleteList,
fetchLists,
getList,
getListAccounts,
removeAccountsFromList,
updateList,
} from 'src/services/api/api.service.js'
import { promiseInterval } from 'src/services/promise_interval/promise_interval.js'
export const useListsStore = defineStore('lists', {
state: () => ({
fetcher: null,
allLists: [],
allListsObject: {},
}),
@ -18,34 +33,58 @@ export const useListsStore = defineStore('lists', {
},
},
actions: {
startFetching() {
promiseInterval(() => {
this.fetcher = fetchLists({
credentials: useCredentialsStore().current,
})
.then(
(lists) => this.setLists(lists),
(rej) => console.error(rej),
)
.catch((e) => {
console.error(e)
})
}, 240000)
},
stopFetching() {
this.fetcher?.stop()
},
setLists(value) {
this.allLists = value
},
createList({ title }) {
return window.vuex.state.api.backendInteractor
.createList({ title })
.then((list) => {
this.setList({ listId: list.id, title })
return list
})
return createList({
title,
credentials: useCredentialsStore().current,
}).then((list) => {
this.setList({ listId: list.id, title })
return list
})
},
fetchList({ listId }) {
return window.vuex.state.api.backendInteractor
.getList({ listId })
.then((list) => this.setList({ listId: list.id, title: list.title }))
return getList({
listId,
credentials: useCredentialsStore().current,
}).then((list) => this.setList({ listId: list.id, title: list.title }))
},
fetchListAccounts({ listId }) {
return window.vuex.state.api.backendInteractor
.getListAccounts({ listId })
.then((accountIds) => {
if (!this.allListsObject[listId]) {
this.allListsObject[listId] = { accountIds: [] }
}
this.allListsObject[listId].accountIds = accountIds
})
return getListAccounts({
listId,
credentials: useCredentialsStore().current,
}).then((accountIds) => {
if (!this.allListsObject[listId]) {
this.allListsObject[listId] = { accountIds: [] }
}
this.allListsObject[listId].accountIds = accountIds
})
},
setList({ listId, title }) {
window.vuex.state.api.backendInteractor.updateList({ listId, title })
updateList({
listId,
title,
credentials: useCredentialsStore().current,
})
if (!this.allListsObject[listId]) {
this.allListsObject[listId] = { accountIds: [] }
@ -68,46 +107,55 @@ export const useListsStore = defineStore('lists', {
}
this.allListsObject[listId].accountIds = accountIds
if (added.length > 0) {
window.vuex.state.api.backendInteractor.addAccountsToList({
addAccountsToList({
listId,
accountIds: added,
credentials: useCredentialsStore().current,
})
}
if (removed.length > 0) {
window.vuex.state.api.backendInteractor.removeAccountsFromList({
removeAccountsFromList({
listId,
accountIds: removed,
credentials: useCredentialsStore().current,
})
}
},
addListAccount({ listId, accountId }) {
return window.vuex.state.api.backendInteractor
.addAccountsToList({ listId, accountIds: [accountId] })
.then((result) => {
if (!this.allListsObject[listId]) {
this.allListsObject[listId] = { accountIds: [] }
}
this.allListsObject[listId].accountIds.push(accountId)
return result
})
return addAccountsToList({
listId,
accountIds: [accountId],
credentials: useCredentialsStore().current,
}).then((result) => {
if (!this.allListsObject[listId]) {
this.allListsObject[listId] = { accountIds: [] }
}
this.allListsObject[listId].accountIds.push(accountId)
return result
})
},
removeListAccount({ listId, accountId }) {
return window.vuex.state.api.backendInteractor
.removeAccountsFromList({ listId, accountIds: [accountId] })
.then((result) => {
if (!this.allListsObject[listId]) {
this.allListsObject[listId] = { accountIds: [] }
}
const { accountIds } = this.allListsObject[listId]
const set = new Set(accountIds)
set.delete(accountId)
this.allListsObject[listId].accountIds = [...set]
return removeAccountsFromList({
listId,
accountIds: [accountId],
credentials: useCredentialsStore().current,
}).then((result) => {
if (!this.allListsObject[listId]) {
this.allListsObject[listId] = { accountIds: [] }
}
const { accountIds } = this.allListsObject[listId]
const set = new Set(accountIds)
set.delete(accountId)
this.allListsObject[listId].accountIds = [...set]
return result
})
return result
})
},
deleteList({ listId }) {
window.vuex.state.api.backendInteractor.deleteList({ listId })
deleteList({
listId,
credentials: useCredentialsStore().current,
})
delete this.allListsObject[listId]
remove(this.allLists, (list) => list.id === listId)

View file

@ -1,25 +1,33 @@
import { defineStore } from 'pinia'
import { useCredentialsStore } from 'src/stores/credentials.js'
import {
fetchOAuthTokens,
revokeOAuthToken,
} from 'src/services/api/api.service.js'
export const useOAuthTokensStore = defineStore('oauthTokens', {
state: () => ({
tokens: [],
}),
actions: {
fetchTokens() {
window.vuex.state.api.backendInteractor
.fetchOAuthTokens()
.then((tokens) => {
this.swapTokens(tokens)
})
fetchOAuthTokens({
credentials: useCredentialsStore().current,
}).then((tokens) => {
this.swapTokens(tokens)
})
},
revokeToken(id) {
window.vuex.state.api.backendInteractor
.revokeOAuthToken({ id })
.then((response) => {
if (response.status === 201) {
this.swapTokens(this.tokens.filter((token) => token.id !== id))
}
})
revokeOAuthToken({
id,
credentials: useCredentialsStore().current,
}).then((response) => {
if (response.status === 201) {
this.swapTokens(this.tokens.filter((token) => token.id !== id))
}
})
},
swapTokens(tokens) {
this.tokens = tokens

View file

@ -1,6 +1,10 @@
import { merge } from 'lodash'
import { defineStore } from 'pinia'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { fetchPoll, vote } from 'src/services/api/api.service.js'
export const usePollsStore = defineStore('polls', {
state: () => ({
// Contains key = id, value = number of trackers for this poll
@ -19,16 +23,17 @@ export const usePollsStore = defineStore('polls', {
}
},
updateTrackedPoll(pollId) {
window.vuex.state.api.backendInteractor
.fetchPoll({ pollId })
.then((poll) => {
setTimeout(() => {
if (this.trackedPolls[pollId]) {
this.updateTrackedPoll(pollId)
}
}, 30 * 1000)
this.mergeOrAddPoll(poll)
})
fetchPoll({
pollId,
credentials: useCredentialsStore().current,
}).then((poll) => {
setTimeout(() => {
if (this.trackedPolls[pollId]) {
this.updateTrackedPoll(pollId)
}
}, 30 * 1000)
this.mergeOrAddPoll(poll)
})
},
trackPoll(pollId) {
if (!this.trackedPolls[pollId]) {
@ -50,12 +55,14 @@ export const usePollsStore = defineStore('polls', {
}
},
votePoll({ pollId, choices }) {
return window.vuex.state.api.backendInteractor
.vote({ pollId, choices })
.then((poll) => {
this.mergeOrAddPoll(poll)
return poll
})
return vote({
pollId,
choices,
credentials: useCredentialsStore().current,
}).then((poll) => {
this.mergeOrAddPoll(poll)
return poll
})
},
},
})

View file

@ -20,6 +20,7 @@ import { toRaw } from 'vue'
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useLocalConfigStore } from 'src/stores/local_config.js'
@ -31,6 +32,7 @@ import {
validateSetting,
} from 'src/modules/default_config_state.js'
import { oldDefaultConfigSync } from 'src/modules/old_default_config_state.js'
import { updateProfileJSON } from 'src/services/api/api.service.js'
export const VERSION = 2
export const NEW_USER_DATE = new Date('2026-03-16') // date of writing this, basically
@ -789,7 +791,10 @@ export const useSyncConfigStore = defineStore('sync_config', {
if (!needPush) return
this.updateCache({ username: window.vuex.state.users.currentUser.fqn })
const params = { pleroma_settings_store: { 'pleroma-fe': this.cache } }
window.vuex.state.api.backendInteractor.updateProfileJSON({ params })
updateProfileJSON({
params,
credentials: useCredentialsStore().current,
})
},
},
persist: {

View file

@ -14,7 +14,10 @@ import {
import { defineStore } from 'pinia'
import { toRaw } from 'vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { storage } from 'src/lib/storage.js'
import { updateProfileJSON } from 'src/services/api/api.service.js'
export const NEW_USER_DATE = new Date('2022-08-04') // date of writing this, basically
@ -344,12 +347,13 @@ export const useUserHighlightStore = defineStore('user_highlight', {
const params = {
pleroma_settings_store: { user_highlight: this.cache },
}
window.vuex.state.api.backendInteractor
.updateProfileJSON({ params })
.then((user) => {
this.initUserHighlight(user)
this.dirty = false
})
updateProfileJSON({
params,
credentials: useCredentialsStore().current,
}).then((user) => {
this.initUserHighlight(user)
this.dirty = false
})
},
},
persist: {