fix chats api
This commit is contained in:
parent
4a59c42395
commit
28efd7ebd2
6 changed files with 63 additions and 24 deletions
|
|
@ -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 })
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue