fix chats api
This commit is contained in:
parent
4a59c42395
commit
28efd7ebd2
6 changed files with 63 additions and 24 deletions
|
|
@ -107,7 +107,7 @@ const StatusActionButtons = {
|
|||
button
|
||||
.action?.(this.funcArg)
|
||||
.then(() => this.$emit('onSuccess'))
|
||||
.catch((err) => this.$emit('onError', err.error.error))
|
||||
.catch((err) => this.$emit('onError', err))
|
||||
},
|
||||
onExtraClose() {
|
||||
this.showPin = false
|
||||
|
|
|
|||
|
|
@ -9,6 +9,10 @@ import {
|
|||
} from '../services/entity_normalizer/entity_normalizer.service.js'
|
||||
import { promiseInterval } from '../services/promise_interval/promise_interval.js'
|
||||
|
||||
import { useCredentialsStore } from 'src/stores/credentials.js'
|
||||
|
||||
import { chats } from 'src/services/api/api.service.js'
|
||||
|
||||
const emptyChatList = () => ({
|
||||
data: [],
|
||||
idStore: {},
|
||||
|
|
@ -36,7 +40,7 @@ const unreadChatCount = (state) => {
|
|||
return sumBy(state.chatList.data, 'unread')
|
||||
}
|
||||
|
||||
const chats = {
|
||||
const chatsModule = {
|
||||
state: { ...defaultState },
|
||||
getters: {
|
||||
currentChat: (state) => state.openedChats[state.currentChatId],
|
||||
|
|
@ -60,8 +64,10 @@ const chats = {
|
|||
commit('setChatListFetcher', { fetcher: undefined })
|
||||
},
|
||||
fetchChats({ dispatch, rootState }) {
|
||||
return rootState.api.backendInteractor.chats().then(({ chats }) => {
|
||||
dispatch('addNewChats', { chats })
|
||||
return chats({
|
||||
credentials: useCredentialsStore().current,
|
||||
}).then(({ chatList }) => {
|
||||
dispatch('addNewChats', { chats: chatList })
|
||||
return chats
|
||||
})
|
||||
},
|
||||
|
|
@ -262,4 +268,4 @@ const chats = {
|
|||
},
|
||||
}
|
||||
|
||||
export default chats
|
||||
export default chatsModule
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import {
|
|||
fetchStatusSource,
|
||||
} from '../services/api/api.service.js'
|
||||
|
||||
import { useCredentialsStore } from 'src/stores/credentials.js'
|
||||
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
|
||||
import { useInterfaceStore } from 'src/stores/interface.js'
|
||||
|
||||
|
|
@ -613,7 +614,7 @@ const statuses = {
|
|||
fetchStatusSource({ rootState }, status) {
|
||||
return fetchStatusSource({
|
||||
id: status.id,
|
||||
credentials: rootState.users.currentUser.credentials,
|
||||
credentials: useCredentialsStore().current,
|
||||
})
|
||||
},
|
||||
fetchStatusHistory(_, status) {
|
||||
|
|
@ -622,7 +623,7 @@ const statuses = {
|
|||
deleteStatus({ rootState, commit }, status) {
|
||||
deleteStatus({
|
||||
id: status.id,
|
||||
credentials: rootState.users.currentUser.credentials,
|
||||
credentials: useCredentialsStore().current,
|
||||
})
|
||||
.then(() => {
|
||||
commit('setDeleted', { status })
|
||||
|
|
|
|||
|
|
@ -347,13 +347,13 @@ export const setReportState = ({ id, state, credentials }) => {
|
|||
}
|
||||
|
||||
export const getInstanceDBConfig = ({ credentials }) =>
|
||||
get({
|
||||
promisedRequest({
|
||||
url: CONFIG_URL,
|
||||
credentials,
|
||||
})
|
||||
|
||||
export const getInstanceConfigDescriptions = ({ credentials }) =>
|
||||
get({
|
||||
promisedRequest({
|
||||
url: DESCRIPTIONS_URL,
|
||||
credentials,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1504,9 +1504,9 @@ export const chats = ({ credentials }) =>
|
|||
promisedRequest({
|
||||
url: PLEROMA_CHATS_URL,
|
||||
credentials,
|
||||
}).then((data) => {
|
||||
chats: data.map(parseChat).filter((c) => c)
|
||||
})
|
||||
}).then((data) => ({
|
||||
chatList: data.map(parseChat).filter((c) => c),
|
||||
}))
|
||||
|
||||
export const getOrCreateChat = ({ accountId, credentials }) =>
|
||||
promisedRequest({
|
||||
|
|
|
|||
|
|
@ -8,10 +8,12 @@ import {
|
|||
deleteAccounts,
|
||||
disableMFA,
|
||||
getAvailableFrontends,
|
||||
getInstanceConfigDescriptions,
|
||||
getInstanceDBConfig,
|
||||
getUserData,
|
||||
listStatuses,
|
||||
listUsers,
|
||||
pushInstanceDBConfig,
|
||||
requirePasswordChange,
|
||||
resendConfirmationEmail,
|
||||
setUsersActivationStatus,
|
||||
|
|
@ -85,12 +87,20 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
})
|
||||
}
|
||||
} else {
|
||||
this.setInstanceAdminSettings({ backendDbConfig })
|
||||
this.setInstanceAdminSettings({
|
||||
credentials: useCredentialsStore().current,
|
||||
backendDbConfig,
|
||||
})
|
||||
}
|
||||
})
|
||||
if (this.descriptions === null) {
|
||||
fetchInstanceConfigDescriptions().then((backendDescriptions) =>
|
||||
this.setInstanceAdminDescriptions({ backendDescriptions }),
|
||||
getInstanceConfigDescriptions({
|
||||
credentials: useCredentialsStore().current,
|
||||
}).then((backendDescriptions) =>
|
||||
this.setInstanceAdminDescriptions({
|
||||
credentials: useCredentialsStore().current,
|
||||
backendDescriptions,
|
||||
}),
|
||||
)
|
||||
}
|
||||
},
|
||||
|
|
@ -223,13 +233,22 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
})
|
||||
|
||||
pushInstanceDBConfig({
|
||||
credentials: useCredentialsStore().current,
|
||||
payload: {
|
||||
configs: changed,
|
||||
},
|
||||
})
|
||||
.then(() => fetchInstanceDBConfig())
|
||||
.then(() =>
|
||||
getInstanceDBConfig({
|
||||
credentials: useCredentialsStore().current,
|
||||
}),
|
||||
)
|
||||
.then((backendDbConfig) =>
|
||||
this.setInstanceAdminSettings({ backendDbConfig }),
|
||||
this.setInstanceAdminSettings({
|
||||
credentials: useCredentialsStore().current,
|
||||
|
||||
backendDbConfig,
|
||||
}),
|
||||
)
|
||||
},
|
||||
pushAdminSetting({ path, value }) {
|
||||
|
|
@ -251,6 +270,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
}
|
||||
|
||||
pushInstanceDBConfig({
|
||||
credentials: useCredentialsStore().current,
|
||||
payload: {
|
||||
configs: [
|
||||
{
|
||||
|
|
@ -261,9 +281,16 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
],
|
||||
},
|
||||
})
|
||||
.then(() => fetchInstanceDBConfig())
|
||||
.then(() =>
|
||||
getInstanceDBConfig({
|
||||
credentials: useCredentialsStore().current,
|
||||
}),
|
||||
)
|
||||
.then((backendDbConfig) =>
|
||||
this.setInstanceAdminSettings({ backendDbConfig }),
|
||||
this.setInstanceAdminSettings({
|
||||
credentials: useCredentialsStore().current,
|
||||
backendDbConfig,
|
||||
}),
|
||||
)
|
||||
},
|
||||
resetAdminSetting({ path }) {
|
||||
|
|
@ -274,6 +301,7 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
this.modifiedPaths.delete(path)
|
||||
|
||||
return pushInstanceDBConfig({
|
||||
credentials: useCredentialsStore().current,
|
||||
payload: {
|
||||
configs: [
|
||||
{
|
||||
|
|
@ -285,7 +313,11 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
],
|
||||
},
|
||||
})
|
||||
.then(() => fetchInstanceDBConfig())
|
||||
.then(() =>
|
||||
getInstanceDBConfig({
|
||||
credentials: useCredentialsStore().current,
|
||||
}),
|
||||
)
|
||||
.then((backendDbConfig) =>
|
||||
this.setInstanceAdminSettings({ backendDbConfig }),
|
||||
)
|
||||
|
|
@ -389,16 +421,16 @@ export const useAdminSettingsStore = defineStore('adminSettings', {
|
|||
const screen_names = users.map((u) => u.screen_name)
|
||||
|
||||
return resendConfirmationEmail({
|
||||
credentials: useCredentialsStore().current,
|
||||
screen_names,
|
||||
credentials: useCredentialsStore().current,
|
||||
screen_names,
|
||||
})
|
||||
},
|
||||
requirePasswordChange({ users }) {
|
||||
const screen_names = users.map((u) => u.screen_name)
|
||||
|
||||
return requirePasswordChange({
|
||||
credentials: useCredentialsStore().current,
|
||||
screen_names,
|
||||
credentials: useCredentialsStore().current,
|
||||
screen_names,
|
||||
})
|
||||
},
|
||||
// Singular only!
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue