Fix chatdoc create issue (#18)
This commit is contained in:
1 parent
4473b5558e
commit
4e53f40a6a
5 files changed
+30
-13
No files matched your search
@@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"type": "patch",
|
||||||
|
"comment": "fix chatdoc create issue",
|
||||||
|
"packageName": "@acedatacloud/hub",
|
||||||
|
"email": "cqc@cuiqingcai.com",
|
||||||
|
"dependentChangeType": "patch"
|
||||||
|
}
|
||||||
@@ -32,11 +32,11 @@ export const setConversations = async ({ commit }: any, payload: IChatConversati
|
|||||||
export const setConversation = async ({ commit, state }: any, payload: IChatConversation): Promise<void> => {
|
export const setConversation = async ({ commit, state }: any, payload: IChatConversation): Promise<void> => {
|
||||||
log(setConversation, 'set conversation', payload);
|
log(setConversation, 'set conversation', payload);
|
||||||
const conversations = state.conversations;
|
const conversations = state.conversations;
|
||||||
const index = conversations.findIndex((conversation: IChatConversation) => conversation.id === payload.id);
|
const index = conversations?.findIndex((conversation: IChatConversation) => conversation.id === payload.id);
|
||||||
if (index > -1) {
|
if (index > -1) {
|
||||||
conversations[index] = payload;
|
conversations[index] = payload;
|
||||||
} else {
|
} else {
|
||||||
conversations.unshift(payload);
|
conversations?.unshift(payload);
|
||||||
}
|
}
|
||||||
commit('setConversations', conversations);
|
commit('setConversations', conversations);
|
||||||
log(setConversation, 'set conversation success', conversations);
|
log(setConversation, 'set conversation success', conversations);
|
||||||
|
|||||||
@@ -29,16 +29,26 @@ export const setRepository = async ({ commit }: any, payload: { repository: ICha
|
|||||||
|
|
||||||
export const getApplication = async ({
|
export const getApplication = async ({
|
||||||
commit,
|
commit,
|
||||||
rootState
|
rootState,
|
||||||
|
state
|
||||||
}: ActionContext<IChatdocState, IRootState>): Promise<IApplication> => {
|
}: ActionContext<IChatdocState, IRootState>): Promise<IApplication> => {
|
||||||
log(getApplication, 'start to get application for chat');
|
return new Promise(async (resolve, reject) => {
|
||||||
const { data: applications } = await applicationOperator.getAll({
|
state.status.getApplication = Status.Request;
|
||||||
user_id: rootState.user.id,
|
applicationOperator
|
||||||
service_id: CHATDOC_SERVICE_ID
|
.getAll({
|
||||||
|
user_id: rootState?.user?.id,
|
||||||
|
service_id: CHATDOC_SERVICE_ID
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
state.status.getApplication = Status.Success;
|
||||||
|
commit('setApplication', response.data.items[0]);
|
||||||
|
resolve(response.data.items[0]);
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
state.status.getApplication = Status.Error;
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
log(getApplication, 'get application for chat success', applications);
|
|
||||||
commit('setApplication', applications?.items?.[0]);
|
|
||||||
return applications.items?.[0];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const resetAll = ({ commit }: ActionContext<IChatdocState, IRootState>): void => {
|
export const resetAll = ({ commit }: ActionContext<IChatdocState, IRootState>): void => {
|
||||||
|
|||||||
@@ -17,10 +17,10 @@ export const setApplication = (state: IChatdocState, payload: IApplication): voi
|
|||||||
|
|
||||||
export const setRepositories = (state: IChatdocState, payload: IChatdocRepository[]): void => {
|
export const setRepositories = (state: IChatdocState, payload: IChatdocRepository[]): void => {
|
||||||
const currentRepositories = state.repositories;
|
const currentRepositories = state.repositories;
|
||||||
if (currentRepositories) {
|
if (currentRepositories && payload) {
|
||||||
// merge current repositories into payload
|
// merge current repositories into payload
|
||||||
payload.forEach((repository: IChatdocRepository) => {
|
payload.forEach((repository: IChatdocRepository) => {
|
||||||
const index = currentRepositories.findIndex((item: IChatdocRepository) => item.id === repository.id);
|
const index = currentRepositories?.findIndex((item: IChatdocRepository) => item.id === repository.id);
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
payload[index] = {
|
payload[index] = {
|
||||||
...currentRepositories[index],
|
...currentRepositories[index],
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ export const getApplication = async ({
|
|||||||
state.status.getApplication = Status.Request;
|
state.status.getApplication = Status.Request;
|
||||||
applicationOperator
|
applicationOperator
|
||||||
.getAll({
|
.getAll({
|
||||||
user_id: rootState.user.id,
|
user_id: rootState?.user?.id,
|
||||||
service_id: MIDJOURNEY_SERVICE_ID
|
service_id: MIDJOURNEY_SERVICE_ID
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
|||||||
Reference in new issue
Block a user