diff --git a/app/main.wasp b/app/main.wasp index fba8738..41f8353 100644 --- a/app/main.wasp +++ b/app/main.wasp @@ -125,6 +125,7 @@ entity Chat {=psl team_name String? team_status String? chatType String? + shouldShowChat Boolean @default(false) proposedUserAction String[] @default([]) userRespondedWithNextAction Boolean @default(false) emailContent String? diff --git a/app/migrations/20240423082334_add_a_field_to_chat_model_to_decide_whether_to_show_the_daily_analysis_chat/migration.sql b/app/migrations/20240423082334_add_a_field_to_chat_model_to_decide_whether_to_show_the_daily_analysis_chat/migration.sql new file mode 100644 index 0000000..9e705bf --- /dev/null +++ b/app/migrations/20240423082334_add_a_field_to_chat_model_to_decide_whether_to_show_the_daily_analysis_chat/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Chat" ADD COLUMN "shouldShowChat" BOOLEAN NOT NULL DEFAULT false; diff --git a/app/migrations/20240423082642_set_the_should_show_chat_value_for_existing_daily_analysis_chats/migration.sql b/app/migrations/20240423082642_set_the_should_show_chat_value_for_existing_daily_analysis_chats/migration.sql new file mode 100644 index 0000000..5e7bb81 --- /dev/null +++ b/app/migrations/20240423082642_set_the_should_show_chat_value_for_existing_daily_analysis_chats/migration.sql @@ -0,0 +1,2 @@ +-- This migration sets the shouldShowChat value to true for all existing daily analysis chats. +UPDATE "Chat" SET "shouldShowChat" = TRUE WHERE "chatType" = 'daily_analysis'; \ No newline at end of file diff --git a/app/src/client/app/ChatPage.tsx b/app/src/client/app/ChatPage.tsx index 6bb7f57..a3a7d06 100644 --- a/app/src/client/app/ChatPage.tsx +++ b/app/src/client/app/ChatPage.tsx @@ -1,4 +1,4 @@ -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { useSocket, useSocketListener } from 'wasp/client/webSocket'; import { type User } from 'wasp/entities'; @@ -54,6 +54,20 @@ const ChatPage = ({ user }: { user: User }) => { { enabled: !!activeChatId } ); + useEffect(() => { + if ( + currentChatDetails && + currentChatDetails.chatType === 'daily_analysis' + ) { + updateCurrentChat({ + id: activeChatId, + data: { + shouldShowChat: true, + }, + }); + } + }, [activeChatUUId, currentChatDetails]); + useSocketListener('smartSuggestionsAddedToDB', updateState); useSocketListener('streamFromTeamFinished', updateState); diff --git a/app/src/client/components/ChatSidebar.tsx b/app/src/client/components/ChatSidebar.tsx index 85e6eb8..23db1b3 100644 --- a/app/src/client/components/ChatSidebar.tsx +++ b/app/src/client/components/ChatSidebar.tsx @@ -5,7 +5,7 @@ import { Link, useHistory } from 'react-router-dom'; import { NavLink, useLocation } from 'react-router-dom'; import Logo from '../static/logo-for-dark-bg.png'; import EditableChatName from './EditableChatName'; - +import { shouldRenderChat } from '../utils/chatUtils'; import { updateCurrentChat } from 'wasp/client/operations'; interface ChatSidebarProps { @@ -189,41 +189,44 @@ const ChatSidebar = ({ {/* */}