Skip to content

Commit

Permalink
Merge branch 'dev' into mainnet
Browse files Browse the repository at this point in the history
  • Loading branch information
serefyarar committed Jun 28, 2024
2 parents 13c6dba + 91a9dc5 commit 3057027
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
13 changes: 9 additions & 4 deletions web-app/src/components/site/indexes/AskIndexes/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
selectConversation,
setMessages,
} from "@/store/slices/conversationSlice";
import { selectDID } from "@/store/slices/didSlice";
import { selectDID, updateConversation } from "@/store/slices/didSlice";
import { selectIndex } from "@/store/slices/indexSlice";
import { useAppDispatch, useAppSelector } from "@/store/store";
import { API_ENDPOINTS } from "@/utils/constants";
Expand Down Expand Up @@ -110,7 +110,7 @@ const AskIndexes: FC<AskIndexesProps> = ({ sources }) => {
const response = await dispatch(
createConversation({
sources: [id],
summary: messageStr,
summary: "New chat",
api,
}),
).unwrap();
Expand Down Expand Up @@ -217,9 +217,14 @@ const AskIndexes: FC<AskIndexesProps> = ({ sources }) => {
};
const handleIncomingMessage = (p: any) => {
isLocalUpdate.current = true;

if (p.channel === "end") {
// dispatch(setMessages(streamingMessages));
return;
if (viewedConversation && viewedConversation.summary === `New chat`) {
api!.getConversationWithSummary(viewedConversation.id).then((c) => {
dispatch(updateConversation(c));
});
return;
}
}

if (p.channel === "update") {
Expand Down
15 changes: 13 additions & 2 deletions web-app/src/store/slices/didSlice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ const didSlice = createSlice({
? state.conversations.filter((c: any) => c.id !== action.payload)
: [];
},
updateConversation: (state, action) => {
state.conversations = state.conversations
? state.conversations.map((c: any) =>
c.id === action.payload.id ? action.payload : c,
)
: [];
},
},
extraReducers: (builder) => {
builder
Expand Down Expand Up @@ -182,7 +189,11 @@ export const selectIndexes = (state: any) => state.did.indexes;
export const selectAvatar = (state: any) => state.did.avatar;
export const selectProfileLoading = (state: any) => state.did.loading;

export const { setProfile, addConversation, removeConversation } =
didSlice.actions;
export const {
setProfile,
addConversation,
removeConversation,
updateConversation,
} = didSlice.actions;

export default didSlice.reducer;

0 comments on commit 3057027

Please sign in to comment.