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