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

@ -16,8 +16,15 @@ import {
isScrollable,
} from './chat_layout_utils.js'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInterfaceStore } from 'src/stores/interface.js'
import {
chatMessages,
getOrCreateChat,
sendChatMessage,
} from 'src/services/api/api.service.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faChevronDown, faChevronLeft } from '@fortawesome/free-solid-svg-icons'
@ -115,7 +122,6 @@ const Chat = {
mobileLayout: (store) => store.layoutType === 'mobile',
}),
...mapState({
backendInteractor: (state) => state.api.backendInteractor,
mastoUserSocketStatus: (state) => state.api.mastoUserSocketStatus,
currentUser: (state) => state.users.currentUser,
}),
@ -267,42 +273,46 @@ const Chat = {
const fetchOlderMessages = !!maxId
const sinceId = fetchLatest && chatMessageService.maxId
return this.backendInteractor
.chatMessages({ id: chatId, maxId, sinceId })
.then((messages) => {
// Clear the current chat in case we're recovering from a ws connection loss.
if (isFirstFetch) {
chatService.clear(chatMessageService)
}
return chatMessages({
id: chatId,
maxId,
sinceId,
credentials: useCredentialsStore().current,
}).then((messages) => {
// Clear the current chat in case we're recovering from a ws connection loss.
if (isFirstFetch) {
chatService.clear(chatMessageService)
}
const positionBeforeUpdate = getScrollPosition()
this.$store
.dispatch('addChatMessages', { chatId, messages })
.then(() => {
this.$nextTick(() => {
if (fetchOlderMessages) {
this.handleScrollUp(positionBeforeUpdate)
}
const positionBeforeUpdate = getScrollPosition()
this.$store
.dispatch('addChatMessages', { chatId, messages })
.then(() => {
this.$nextTick(() => {
if (fetchOlderMessages) {
this.handleScrollUp(positionBeforeUpdate)
}
// In vertical screens, the first batch of fetched messages may not always take the
// full height of the scrollable container.
// If this is the case, we want to fetch the messages until the scrollable container
// is fully populated so that the user has the ability to scroll up and load the history.
if (!isScrollable() && messages.length > 0) {
this.fetchChat({
maxId: this.currentChatMessageService.minId,
})
}
})
// In vertical screens, the first batch of fetched messages may not always take the
// full height of the scrollable container.
// If this is the case, we want to fetch the messages until the scrollable container
// is fully populated so that the user has the ability to scroll up and load the history.
if (!isScrollable() && messages.length > 0) {
this.fetchChat({
maxId: this.currentChatMessageService.minId,
})
}
})
})
})
})
},
async startFetching() {
let chat = this.findOpenedChatByRecipientId(this.recipientId)
if (!chat) {
try {
chat = await this.backendInteractor.getOrCreateChat({
chat = await getOrCreateChat({
accountId: this.recipientId,
credentials: useCredentialsStore().current,
})
} catch (e) {
console.error('Error creating or getting a chat', e)
@ -369,8 +379,10 @@ const Chat = {
doSendMessage({ params, fakeMessage, retriesLeft = MAX_RETRIES }) {
if (retriesLeft <= 0) return
this.backendInteractor
.sendChatMessage(params)
sendChatMessage({
params,
credentials: useCredentialsStore().current,
})
.then((data) => {
this.$store.dispatch('addChatMessages', {
chatId: this.currentChat.id,

View file

@ -3,6 +3,10 @@ import { mapGetters, mapState } from 'vuex'
import BasicUserCard from 'src/components/basic_user_card/basic_user_card.vue'
import UserAvatar from 'src/components/user_avatar/user_avatar.vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { chats } from 'src/services/api/api.service.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faChevronLeft, faSearch } from '@fortawesome/free-solid-svg-icons'
@ -22,7 +26,9 @@ const chatNew = {
}
},
async created() {
const { chats } = await this.backendInteractor.chats()
const { chats } = await chats({
credentials: useCredentialsStore().current,
})
chats.forEach((chat) => this.suggestions.push(chat.account))
},
computed: {
@ -38,7 +44,6 @@ const chatNew = {
},
...mapState({
currentUser: (state) => state.users.currentUser,
backendInteractor: (state) => state.api.backendInteractor,
}),
...mapGetters(['findUser']),
},

View file

@ -7,9 +7,12 @@ import QuickViewSettings from 'src/components/quick_view_settings/quick_view_set
import ThreadTree from 'src/components/thread_tree/thread_tree.vue'
import { WSConnectionStatus } from '../../services/api/api.service.js'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInterfaceStore } from 'src/stores/interface'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { fetchConversation, fetchStatus } from 'src/services/api/api.service.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faAngleDoubleDown,
@ -436,17 +439,20 @@ const conversation = {
methods: {
fetchConversation() {
if (this.status) {
this.$store.state.api.backendInteractor
.fetchConversation({ id: this.statusId })
.then(({ ancestors, descendants }) => {
this.$store.dispatch('addNewStatuses', { statuses: ancestors })
this.$store.dispatch('addNewStatuses', { statuses: descendants })
this.setHighlight(this.originalStatusId)
})
fetchConversation({
id: this.statusId,
credentials: useCredentialsStore().current,
}).then(({ ancestors, descendants }) => {
this.$store.dispatch('addNewStatuses', { statuses: ancestors })
this.$store.dispatch('addNewStatuses', { statuses: descendants })
this.setHighlight(this.originalStatusId)
})
} else {
this.loadStatusError = null
this.$store.state.api.backendInteractor
.fetchStatus({ id: this.statusId })
fetchStatus({
id: this.statusId,
credentials: useCredentialsStore().current,
})
.then((status) => {
this.$store.dispatch('addNewStatuses', { statuses: [status] })
this.fetchConversation()

View file

@ -3,8 +3,11 @@ import { defineAsyncComponent } from 'vue'
import { notificationsFromStore } from '../../services/notification_utils/notification_utils.js'
import BasicUserCard from '../basic_user_card/basic_user_card.vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { approveUser, denyUser } from 'src/services/api/api.service.js'
const FollowRequestCard = {
props: ['user'],
components: {
@ -48,7 +51,10 @@ const FollowRequestCard = {
}
},
doApprove() {
this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
approveUser({
id: this.user.id,
credentials: useCredentialsStore().current,
})
this.$store.dispatch('removeFollowRequest', this.user)
const notifId = this.findFollowRequestNotificationId()
@ -70,12 +76,14 @@ const FollowRequestCard = {
},
doDeny() {
const notifId = this.findFollowRequestNotificationId()
this.$store.state.api.backendInteractor
.denyUser({ id: this.user.id })
.then(() => {
this.$store.dispatch('dismissNotificationLocal', { id: notifId })
this.$store.dispatch('removeFollowRequest', this.user)
})
denyUser({
id: this.user.id,
credentials: useCredentialsStore().current,
}).then(() => {
this.$store.dispatch('dismissNotificationLocal', { id: notifId })
this.$store.dispatch('removeFollowRequest', this.user)
})
this.hideDenyConfirmDialog()
},
},

View file

@ -13,10 +13,12 @@ import {
highlightStyle,
} from '../../services/user_highlighter/user_highlighter.js'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
import { approveUser, denyUser } from 'src/services/api/api.service.js'
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
import { library } from '@fortawesome/fontawesome-svg-core'
@ -142,7 +144,10 @@ const Notification = {
}
},
doApprove() {
this.$store.state.api.backendInteractor.approveUser({ id: this.user.id })
approveUser({
id: this.user.id,
credentials: useCredentialsStore().current,
})
this.$store.dispatch('removeFollowRequest', this.user)
this.$store.dispatch('markSingleNotificationAsSeen', {
id: this.notification.id,
@ -163,14 +168,15 @@ const Notification = {
}
},
doDeny() {
this.$store.state.api.backendInteractor
.denyUser({ id: this.user.id })
.then(() => {
this.$store.dispatch('dismissNotificationLocal', {
id: this.notification.id,
})
this.$store.dispatch('removeFollowRequest', this.user)
denyUser({
id: this.user.id,
credentials: useCredentialsStore().current,
}).then(() => {
this.$store.dispatch('dismissNotificationLocal', {
id: this.notification.id,
})
this.$store.dispatch('removeFollowRequest', this.user)
})
this.hideDenyConfirmDialog()
},
},

View file

@ -1,3 +1,7 @@
import { useCredentialsStore } from 'src/stores/credentials.js'
import { fetchUser } from 'src/services/api/api.service.js'
const RemoteUserResolver = {
data: () => ({
error: false,
@ -7,10 +11,11 @@ const RemoteUserResolver = {
},
methods: {
redirect() {
const acct =
this.$route.params.username + '@' + this.$route.params.hostname
this.$store.state.api.backendInteractor
.fetchUser({ id: acct })
const id = this.$route.params.username + '@' + this.$route.params.hostname
fetchUser({
id,
credentials: useCredentialsStore().current,
})
.then((externalUser) => {
if (externalUser.error) {
this.error = true

View file

@ -11,6 +11,7 @@ import ModifiedIndicator from '../helpers/modified_indicator.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import StringSetting from '../helpers/string_setting.vue'
import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
import { useEmojiStore } from 'src/stores/emoji.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInterfaceStore } from 'src/stores/interface.js'
@ -98,10 +99,10 @@ const EmojiTab = {
methods: {
reloadEmoji() {
this.$store.state.api.backendInteractor.reloadEmoji()
useAdminSettingsStore().reloadEmoji()
},
importFromFS() {
this.$store.state.api.backendInteractor.importEmojiFromFS()
useAdminSettingsStore().importEmojiFromFS()
},
emojiAddr(name) {
if (this.pack.remote !== undefined) {
@ -113,7 +114,7 @@ const EmojiTab = {
},
createEmojiPack() {
this.$store.state.api.backendInteractor
useAdminSettingsStore()
.createEmojiPack({ name: this.newPackName })
.then((resp) => resp.json())
.then((resp) => {
@ -130,7 +131,7 @@ const EmojiTab = {
})
},
deleteEmojiPack() {
this.$store.state.api.backendInteractor
useAdminSettingsStore()
.deleteEmojiPack({ name: this.packName })
.then((resp) => resp.json())
.then((resp) => {
@ -157,7 +158,7 @@ const EmojiTab = {
return edited !== def
},
savePackMetadata() {
this.$store.state.api.backendInteractor
useAdminSettingsStore()
.saveEmojiPackMetadata({ name: this.packName, newData: this.packMeta })
.then((resp) => resp.json())
.then((resp) => {
@ -182,7 +183,7 @@ const EmojiTab = {
useEmojiStore()
.getAdminPacks(
this.remotePackInstance,
this.$store.state.api.backendInteractor.listEmojiPacks,
useAdminSettingsStore().listEmojiPacks,
)
.then((allPacks) => {
this.knownLocalPacks = allPacks
@ -195,7 +196,7 @@ const EmojiTab = {
useEmojiStore()
.getAdminPacks(
this.remotePackInstance,
this.$store.state.api.backendInteractor.listRemoteEmojiPacks,
useAdminSettingsStore().listRemoteEmojiPacks,
)
.then((allPacks) => {
let inst = this.remotePackInstance
@ -226,7 +227,7 @@ const EmojiTab = {
this.remotePackDownloadAs = this.pack.remote.baseName
}
this.$store.state.api.backendInteractor
useAdminSettingsStore()
.downloadRemoteEmojiPack({
instance: this.pack.remote.instance,
packName: this.pack.remote.baseName,
@ -247,7 +248,7 @@ const EmojiTab = {
})
},
downloadRemoteURLPack() {
this.$store.state.api.backendInteractor
useAdminSettingsStore()
.downloadRemoteEmojiPackZIP({
url: this.remotePackURL,
packName: this.newPackName,
@ -268,7 +269,7 @@ const EmojiTab = {
})
},
downloadRemoteFilePack() {
this.$store.state.api.backendInteractor
useAdminSettingsStore()
.downloadRemoteEmojiPackZIP({
file: this.remotePackFile[0],
packName: this.newPackName,

View file

@ -71,7 +71,7 @@ const FrontendsTab = {
const payload = { name, ref }
this.working = true
this.$store.state.api.backendInteractor
useAdminSettingsStore()
.installFrontend({ payload })
.finally(() => {
this.working = false

View file

@ -153,6 +153,14 @@ import Popover from 'components/popover/popover.vue'
import SelectComponent from 'components/select/select.vue'
import { defineAsyncComponent } from 'vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import {
addNewEmojiFile,
deleteEmojiFile,
updateEmojiFile,
} from 'src/services/api/api.service.js'
export default {
components: {
Popover,
@ -243,14 +251,14 @@ export default {
saveEditedEmoji() {
if (!this.isEdited) return
this.$store.state.api.backendInteractor
.updateEmojiFile({
packName: this.packName,
shortcode: this.shortcode,
newShortcode: this.editedShortcode,
newFilename: this.editedFile,
force: false,
})
updateEmojiFile({
packName: this.packName,
shortcode: this.shortcode,
newShortcode: this.editedShortcode,
newFilename: this.editedFile,
force: false,
credentials: useCredentialsStore().current,
})
.then((resp) => {
if (resp.error !== undefined) {
this.$emit('displayError', resp.error)
@ -263,18 +271,18 @@ export default {
},
uploadEmoji() {
let packName = this.remote === undefined ? this.packName : this.copyToPack
this.$store.state.api.backendInteractor
.addNewEmojiFile({
packName: packName,
file:
this.remote === undefined
? this.uploadURL !== ''
? this.uploadURL
: this.uploadFile[0]
: this.emojiAddr(this.file),
shortcode: this.editedShortcode,
filename: this.editedFile,
})
addNewEmojiFile({
packName: packName,
file:
this.remote === undefined
? this.uploadURL !== ''
? this.uploadURL
: this.uploadFile[0]
: this.emojiAddr(this.file),
shortcode: this.editedShortcode,
filename: this.editedFile,
credentials: useCredentialsStore().current,
})
.then((resp) => resp.json())
.then((resp) => {
if (resp.error !== undefined) {
@ -297,8 +305,11 @@ export default {
deleteEmoji() {
this.deleteModalVisible = false
this.$store.state.api.backendInteractor
.deleteEmojiFile({ packName: this.packName, shortcode: this.shortcode })
deleteEmojiFile({
packName: this.packName,
shortcode: this.shortcode,
credentials: useCredentialsStore().current,
})
.then((resp) => resp.json())
.then((resp) => {
if (resp.error !== undefined) {

View file

@ -10,9 +10,11 @@ import SharedComputedObject from '../helpers/shared_computed_object.js'
import UnitSetting from '../helpers/unit_setting.vue'
import Preview from './old_theme_tab/theme_preview.vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { normalizeThemeData, useInterfaceStore } from 'src/stores/interface.js'
import { updateProfileImages } from 'src/services/api/api.service.js'
import { newImporter } from 'src/services/export_import/export_import.js'
import {
adoptStyleSheets,
@ -484,8 +486,10 @@ const AppearanceTab = {
}
this.backgroundUploading = true
this.$store.state.api.backendInteractor
.updateProfileImages({ background })
updateProfileImages({
background,
credentials: useCredentialsStore().current,
})
.then((data) => {
this.$store.commit('addNewUsers', [data])
this.$store.commit('setCurrentUser', data)

View file

@ -11,11 +11,13 @@ import IntegerSetting from '../helpers/integer_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import UnitSetting from '../helpers/unit_setting.vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { updateProfile } from 'src/services/api/api.service.js'
import localeService from 'src/services/locale/locale.service.js'
import { cacheKey, clearCache, emojiCacheKey } from 'src/services/sw/sw.js'
@ -164,12 +166,13 @@ const ComposingTab = {
),
}
this.$store.state.api.backendInteractor
.updateProfile({ params })
.then((user) => {
this.$store.commit('addNewUsers', [user])
this.$store.commit('setCurrentUser', user)
})
updateProfile({
params,
credentials: useCredentialsStore().current,
}).then((user) => {
this.$store.commit('addNewUsers', [user])
this.$store.commit('setCurrentUser', user)
})
},
updateFont(key, value) {
useSyncConfigStore().setSimplePrefAndSave({

View file

@ -4,8 +4,20 @@ import Checkbox from 'src/components/checkbox/checkbox.vue'
import Exporter from 'src/components/exporter/exporter.vue'
import Importer from 'src/components/importer/importer.vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useOAuthTokensStore } from 'src/stores/oauth_tokens.js'
import {
addBackup,
exportFriends,
fetchBlocks,
fetchMutes,
importBlocks,
importFollows,
importMutes,
listBackups,
} from 'src/services/api/api.service.js'
const DataImportExportTab = {
data() {
return {
@ -28,42 +40,51 @@ const DataImportExportTab = {
},
computed: {
...mapState({
backendInteractor: (state) => state.api.backendInteractor,
user: (state) => state.users.currentUser,
}),
},
methods: {
getFollowsContent() {
return this.backendInteractor
.exportFriends({ id: this.user.id })
.then(this.generateExportableUsersContent)
return exportFriends({
id: this.user.id,
credentials: useCredentialsStore().current,
}).then(this.generateExportableUsersContent)
},
getBlocksContent() {
return this.backendInteractor
.fetchBlocks()
.then(this.generateExportableUsersContent)
return fetchBlocks({
credentials: useCredentialsStore().current,
}).then(this.generateExportableUsersContent)
},
getMutesContent() {
return this.backendInteractor
.fetchMutes()
.then(this.generateExportableUsersContent)
return fetchMutes({
credentials: useCredentialsStore().current,
}).then(this.generateExportableUsersContent)
},
importFollows(file) {
return this.backendInteractor.importFollows({ file }).then((status) => {
return importFollows({
file,
credentials: useCredentialsStore().current,
}).then((status) => {
if (!status) {
throw new Error('failed')
}
})
},
importBlocks(file) {
return this.backendInteractor.importBlocks({ file }).then((status) => {
return importBlocks({
file,
credentials: useCredentialsStore().current,
}).then((status) => {
if (!status) {
throw new Error('failed')
}
})
},
importMutes(file) {
return this.backendInteractor.importMutes({ file }).then((status) => {
return importMutes({
file,
credentials: useCredentialsStore().current,
}).then((status) => {
if (!status) {
throw new Error('failed')
}
@ -83,8 +104,9 @@ const DataImportExportTab = {
.join('\n')
},
addBackup() {
this.$store.state.api.backendInteractor
.addBackup()
addBackup({
credentials: useCredentialsStore().current,
})
.then(() => {
this.addedBackup = true
this.addBackupError = false
@ -96,8 +118,9 @@ const DataImportExportTab = {
.then(() => this.fetchBackups())
},
fetchBackups() {
this.$store.state.api.backendInteractor
.listBackups()
listBackups({
credentials: useCredentialsStore().current,
})
.then((res) => {
this.backups = res
this.listBackupsError = false

View file

@ -8,12 +8,14 @@ import FloatSetting from '../helpers/float_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import UnitSetting from '../helpers/unit_setting.vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useLocalConfigStore } from 'src/stores/local_config.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { updateProfile } from 'src/services/api/api.service.js'
import localeService from 'src/services/locale/locale.service.js'
const GeneralTab = {
@ -58,12 +60,13 @@ const GeneralTab = {
),
}
this.$store.state.api.backendInteractor
.updateProfile({ params })
.then((user) => {
this.$store.commit('addNewUsers', [user])
this.$store.commit('setCurrentUser', user)
})
updateProfile({
params,
credentials: useCredentialsStore().current,
}).then((user) => {
this.$store.commit('addNewUsers', [user])
this.$store.commit('setCurrentUser', user)
})
},
updateFont(path, value) {
useLocalConfigStore().set({ path, value })

View file

@ -9,9 +9,12 @@ import MuteCard from 'src/components/mute_card/mute_card.vue'
import ProgressButton from 'src/components/progress_button/progress_button.vue'
import TabSwitcher from 'src/components/tab_switcher/tab_switcher.jsx'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useOAuthTokensStore } from 'src/stores/oauth_tokens.js'
import { importBlocks, importFollows } from 'src/services/api/api.service.js'
const MutesAndBlocks = {
data() {
return {
@ -54,22 +57,24 @@ const MutesAndBlocks = {
return () => this.$store.dispatch('fetch' + group, this.userId)
},
importFollows(file) {
return this.$store.state.api.backendInteractor
.importFollows({ file })
.then((status) => {
if (!status) {
throw new Error('failed')
}
})
return importFollows({
file,
credentials: useCredentialsStore().current,
}).then((status) => {
if (!status) {
throw new Error('failed')
}
})
},
importBlocks(file) {
return this.$store.state.api.backendInteractor
.importBlocks({ file })
.then((status) => {
if (!status) {
throw new Error('failed')
}
})
return importBlocks({
file,
credentials: useCredentialsStore().current,
}).then((status) => {
if (!status) {
throw new Error('failed')
}
})
},
generateExportableUsersContent(users) {
// Get addresses

View file

@ -1,6 +1,10 @@
import BooleanSetting from '../helpers/boolean_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { updateNotificationSettings } from 'src/services/api/api.service.js'
const NotificationsTab = {
data() {
return {
@ -27,7 +31,8 @@ const NotificationsTab = {
},
methods: {
updateNotificationSettings() {
this.$store.state.api.backendInteractor.updateNotificationSettings({
updateNotificationSettings({
credentials: useCredentialsStore().current,
settings: this.notificationSettings,
})
},

View file

@ -3,6 +3,10 @@ import UserCard from 'src/components/user_card/user_card.vue'
import BooleanSetting from '../helpers/boolean_setting.vue'
import SharedComputedObject from '../helpers/shared_computed_object.js'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { updateProfile } from 'src/services/api/api.service.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faCircleNotch,
@ -35,9 +39,10 @@ const ProfileTab = {
const params = {
locked: this.locked,
}
this.$store.state.api.backendInteractor
.updateProfile({ params })
updateProfile({
params,
credentials: useCredentialsStore().current,
})
.then((user) => {
this.$store.commit('addNewUsers', [user])
this.$store.commit('setCurrentUser', user)

View file

@ -5,6 +5,15 @@ import Confirm from './confirm.vue'
import RecoveryCodes from './mfa_backup_codes.vue'
import TOTP from './mfa_totp.vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import {
generateMfaBackupCodes,
mfaConfirmOTP,
mfaSetupOTP,
settingsMFA,
} from 'src/services/api/api.service.js'
const Mfa = {
data: () => ({
settings: {
@ -71,9 +80,6 @@ const Mfa = {
confirmNewBackupCodes() {
return this.backupCodes.getNewCodes
},
...mapState({
backendInteractor: (state) => state.api.backendInteractor,
}),
},
methods: {
@ -87,7 +93,9 @@ const Mfa = {
this.backupCodes.inProgress = true
this.backupCodes.codes = []
return this.backendInteractor.generateMfaBackupCodes().then((res) => {
return generateMfaBackupCodes({
credentials: useCredentialsStore().current,
}).then((res) => {
this.backupCodes.codes = res.codes
this.backupCodes.inProgress = false
})
@ -112,7 +120,9 @@ const Mfa = {
// prepare setup OTP
this.setupState.state = 'setupOTP'
this.setupState.setupOTPState = 'prepare'
this.backendInteractor.mfaSetupOTP().then((res) => {
mfaSetupOTP({
credentials: useCredentialsStore().current,
}).then((res) => {
this.otpSettings = res
this.setupState.setupOTPState = 'confirm'
})
@ -120,18 +130,17 @@ const Mfa = {
doConfirmOTP() {
// handler confirm enable OTP
this.error = null
this.backendInteractor
.mfaConfirmOTP({
token: this.otpConfirmToken,
password: this.currentPassword,
})
.then((res) => {
if (res.error) {
this.error = res.error
return
}
this.completeSetup()
})
mfaConfirmOTP({
token: this.otpConfirmToken,
password: this.currentPassword,
credentials: useCredentialsStore().current,
}).then((res) => {
if (res.error) {
this.error = res.error
return
}
this.completeSetup()
})
},
completeSetup() {
@ -152,7 +161,9 @@ const Mfa = {
// fetch settings from server
async fetchSettings() {
const result = await this.backendInteractor.settingsMFA()
const result = await settingsMFA({
credentials: useCredentialsStore().current,
})
if (result.error) return
this.settings = result.settings
this.settings.available = true

View file

@ -2,6 +2,10 @@ import { mapState } from 'vuex'
import Confirm from './confirm.vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { mfaDisableOTP } from 'src/services/api/api.service.js'
export default {
props: ['settings'],
data: () => ({
@ -17,9 +21,6 @@ export default {
isActivated() {
return this.settings.totp
},
...mapState({
backendInteractor: (state) => state.api.backendInteractor,
}),
},
methods: {
doActivate() {
@ -36,19 +37,18 @@ export default {
// confirm deactivate TOTP method
this.error = null
this.inProgress = true
this.backendInteractor
.mfaDisableOTP({
password: this.currentPassword,
})
.then((res) => {
this.inProgress = false
if (res.error) {
this.error = res.error
return
}
this.deactivate = false
this.$emit('deactivate')
})
mfaDisableOTP({
password: this.currentPassword,
credentials: useCredentialsStore().current,
}).then((res) => {
this.inProgress = false
if (res.error) {
this.error = res.error
return
}
this.deactivate = false
this.$emit('deactivate')
})
},
},
}

View file

@ -2,10 +2,20 @@ import Checkbox from 'src/components/checkbox/checkbox.vue'
import ProgressButton from 'src/components/progress_button/progress_button.vue'
import Mfa from './mfa.vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useOAuthTokensStore } from 'src/stores/oauth_tokens'
import {
addAlias,
changeEmail,
changePassword,
deleteAccount,
deleteAlias,
listAliases,
moveAccount,
} from 'src/services/api/api.service.js'
import localeService from 'src/services/locale/locale.service.js'
const SecurityTab = {
@ -65,78 +75,79 @@ const SecurityTab = {
this.deletingAccount = true
},
deleteAccount() {
this.$store.state.api.backendInteractor
.deleteAccount({ password: this.deleteAccountConfirmPasswordInput })
.then((res) => {
if (res.status === 'success') {
this.$store.dispatch('logout')
this.$router.push({ name: 'root' })
} else {
this.deleteAccountError = res.error
}
})
deleteAccount({
credentials: useCredentialsStore().current,
password: this.deleteAccountConfirmPasswordInput,
}).then((res) => {
if (res.status === 'success') {
this.$store.dispatch('logout')
this.$router.push({ name: 'root' })
} else {
this.deleteAccountError = res.error
}
})
},
changePassword() {
const params = {
password: this.changePasswordInputs[0],
newPassword: this.changePasswordInputs[1],
newPasswordConfirmation: this.changePasswordInputs[2],
credentials: useCredentialsStore().current,
}
this.$store.state.api.backendInteractor
.changePassword(params)
.then((res) => {
if (res.status === 'success') {
this.changedPassword = true
this.changePasswordError = false
this.logout()
} else {
this.changedPassword = false
this.changePasswordError = res.error
}
})
changePassword(params).then((res) => {
if (res.status === 'success') {
this.changedPassword = true
this.changePasswordError = false
this.logout()
} else {
this.changedPassword = false
this.changePasswordError = res.error
}
})
},
changeEmail() {
const params = {
email: this.newEmail,
password: this.changeEmailPassword,
credentials: useCredentialsStore().current,
}
this.$store.state.api.backendInteractor
.changeEmail(params)
.then((res) => {
if (res.status === 'success') {
this.changedEmail = true
this.changeEmailError = false
} else {
this.changedEmail = false
this.changeEmailError = res.error
}
})
changeEmail(params).then((res) => {
if (res.status === 'success') {
this.changedEmail = true
this.changeEmailError = false
} else {
this.changedEmail = false
this.changeEmailError = res.error
}
})
},
moveAccount() {
const params = {
targetAccount: this.moveAccountTarget,
password: this.moveAccountPassword,
credentials: useCredentialsStore().current,
}
this.$store.state.api.backendInteractor
.moveAccount(params)
.then((res) => {
if (res.status === 'success') {
this.movedAccount = true
this.moveAccountError = false
} else {
this.movedAccount = false
this.moveAccountError = res.error
}
})
moveAccount(params).then((res) => {
if (res.status === 'success') {
this.movedAccount = true
this.moveAccountError = false
} else {
this.movedAccount = false
this.moveAccountError = res.error
}
})
},
removeAlias(alias) {
this.$store.state.api.backendInteractor
.deleteAlias({ alias })
.then(() => this.fetchAliases())
deleteAlias({
alias,
credentials: useCredentialsStore().current,
}).then(() => this.fetchAliases())
},
addAlias() {
this.$store.state.api.backendInteractor
.addAlias({ alias: this.addAliasTarget })
addAlias({
alias: this.addAliasTarget,
credentials: useCredentialsStore().current,
})
.then(() => {
this.addedAlias = true
this.addAliasError = false
@ -149,8 +160,9 @@ const SecurityTab = {
.then(() => this.fetchAliases())
},
fetchAliases() {
this.$store.state.api.backendInteractor
.listAliases()
listAliases({
credentials: useCredentialsStore().current,
})
.then((res) => {
this.aliases = res.aliases
this.listAliasesError = false

View file

@ -2,6 +2,7 @@ import Popover from 'components/popover/popover.vue'
import SelectComponent from 'components/select/select.vue'
import { mapState } from 'pinia'
import { useAdminSettingsStore } from 'src/stores/admin_settings'
import { useEmojiStore } from 'src/stores/emoji'
import { useInterfaceStore } from 'src/stores/interface'
@ -37,7 +38,7 @@ export default {
})
},
copyToLocalPack() {
this.$store.state.api.backendInteractor
useAdminSettingsStore()
.addNewEmojiFile({
packName: this.packName,
file: this.$attrs.src,

View file

@ -16,6 +16,7 @@ import Select from 'src/components/select/select.vue'
import UserAvatar from 'src/components/user_avatar/user_avatar.vue'
import UserLink from 'src/components/user_link/user_link.vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useEmojiStore } from 'src/stores/emoji.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
@ -25,6 +26,7 @@ import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { usePostStatusStore } from 'src/stores/post_status'
import { useUserHighlightStore } from 'src/stores/user_highlight.js'
import { updateProfile } from 'src/services/api/api.service.js'
import { propsToNative } from 'src/services/attributes_helper/attributes_helper.service.js'
import localeService from 'src/services/locale/locale.service.js'
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
@ -597,8 +599,7 @@ export default {
params.header = this.newBannerFile
}
this.$store.state.api.backendInteractor
.updateProfile({ params })
updateProfile({ params })
.then((user) => {
this.newFields.splice(this.newFields.length)
merge(this.newFields, user.fields)

View file

@ -5,8 +5,11 @@ import List from 'src/components/list/list.vue'
import Modal from 'src/components/modal/modal.vue'
import UserLink from 'src/components/user_link/user_link.vue'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useReportsStore } from 'src/stores/reports.js'
import { reportUser } from 'src/services/api/api.service.js'
const UserReportingModal = {
components: {
List,
@ -71,9 +74,9 @@ const UserReportingModal = {
comment: this.comment,
forward: this.forward,
statusIds: [...this.statusIdsToReport],
credentials: useCredentialsStore().current,
}
this.$store.state.api.backendInteractor
.reportUser({ ...params })
reportUser({ ...params })
.then(() => {
this.processing = false
this.resetState()

View file

@ -1,8 +1,11 @@
import FollowCard from 'src/components/follow_card/follow_card.vue'
import apiService from '../../services/api/api.service.js'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { fetchUser, suggestions } from 'src/services/api/api.service.js'
const WhoToFollow = {
components: {
FollowCard,
@ -17,21 +20,22 @@ const WhoToFollow = {
},
methods: {
showWhoToFollow(reply) {
reply.forEach((i) => {
this.$store.state.api.backendInteractor
.fetchUser({ id: i.acct })
.then((externalUser) => {
if (!externalUser.error) {
this.$store.commit('addNewUsers', [externalUser])
this.users.push(externalUser)
}
})
reply.forEach(({ id }) => {
fetchUser({
id,
credentials: useCredentialsStore().current,
}).then((externalUser) => {
if (!externalUser.error) {
this.$store.commit('addNewUsers', [externalUser])
this.users.push(externalUser)
}
})
})
},
getWhoToFollow() {
const credentials = this.$store.state.users.currentUser.credentials
const credentials = useCredentialsStore().current
if (credentials) {
apiService.suggestions({ credentials }).then((reply) => {
suggestions({ credentials }).then((reply) => {
this.showWhoToFollow(reply)
})
}

View file

@ -1,10 +1,10 @@
import { shuffle } from 'lodash'
import apiService from '../../services/api/api.service.js'
import { useCredentialsStore } from 'src/stores/credentials.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { fetchUser, suggestions } from 'src/services/api/api.service.js'
import generateProfileLink from 'src/services/user_profile_link_generator/user_profile_link_generator'
function showWhoToFollow(panel, reply) {
@ -18,14 +18,15 @@ function showWhoToFollow(panel, reply) {
toFollow.img = img
toFollow.name = name
panel.$store.state.api.backendInteractor
.fetchUser({ id: name })
.then((externalUser) => {
if (!externalUser.error) {
panel.$store.commit('addNewUsers', [externalUser])
toFollow.id = externalUser.id
}
})
fetchUser({
id: name,
credentials: useCredentialsStore().current,
}).then((externalUser) => {
if (!externalUser.error) {
panel.$store.commit('addNewUsers', [externalUser])
toFollow.id = externalUser.id
}
})
})
}
@ -35,7 +36,7 @@ function getWhoToFollow(panel) {
panel.usersToFollow.forEach((toFollow) => {
toFollow.name = 'Loading...'
})
apiService.suggestions({ credentials }).then((reply) => {
suggestions({ credentials }).then((reply) => {
showWhoToFollow(panel, reply)
})
}