Fix btn Show Welcome Msgs bugs

This commit is contained in:
Gustavo Trott 2023-07-19 11:16:57 -03:00
parent d0697b6270
commit 4a346aae4e
2 changed files with 18 additions and 11 deletions

View File

@ -10,15 +10,15 @@ import scala.util.{ Failure, Success }
case class MeetingWelcomeDbModel(
meetingId: String,
welcomeMsgTemplate: String,
welcomeMsg: String,
welcomeMsgForModerators: String
welcomeMsg: Option[String],
welcomeMsgForModerators: Option[String]
)
class MeetingWelcomeDbTableDef(tag: Tag) extends Table[MeetingWelcomeDbModel](tag, "meeting_welcome") {
val meetingId = column[String]("meetingId", O.PrimaryKey)
val welcomeMsgTemplate = column[String]("welcomeMsgTemplate")
val welcomeMsg = column[String]("welcomeMsg")
val welcomeMsgForModerators = column[String]("welcomeMsgForModerators")
val welcomeMsg = column[Option[String]]("welcomeMsg")
val welcomeMsgForModerators = column[Option[String]]("welcomeMsgForModerators")
// def fk_meetingId: ForeignKeyQuery[MeetingDbTableDef, MeetingDbModel] = foreignKey("fk_meetingId", meetingId, TableQuery[MeetingDbTableDef])(_.meetingId)
@ -32,8 +32,14 @@ object MeetingWelcomeDAO {
MeetingWelcomeDbModel(
meetingId = meetingId,
welcomeMsgTemplate = welcomeProp.welcomeMsgTemplate,
welcomeMsg = welcomeProp.welcomeMsg,
welcomeMsgForModerators = welcomeProp.modOnlyMessage
welcomeMsg = welcomeProp.welcomeMsg match {
case "" => None
case m => Some(m)
},
welcomeMsgForModerators = welcomeProp.modOnlyMessage match {
case "" => None
case m => Some(m)
}
)
)
).onComplete {

View File

@ -98,7 +98,8 @@ export const ChatActions: React.FC = () => {
if (dataPermissions) {
setUserIsmoderator(dataPermissions.user_current[0].isModerator);
setMeetingIsBreakout(dataPermissions.meeting[0].isBreakout);
if (!isEmpty(dataPermissions.user_welcomeMsgs[0].welcomeMsg)) {
if (!isEmpty(dataPermissions.user_welcomeMsgs[0].welcomeMsg || '') ||
!isEmpty(dataPermissions.user_welcomeMsgs[0].welcomeMsgForModerators || '')) {
setShowShowWelcomeMessages(true);
}
}
@ -132,13 +133,13 @@ export const ChatActions: React.FC = () => {
{
key: uniqueIdsRef.current[2],
enable: userIsModerator && !meetingIsBreakout,
icon: 'download',
icon: 'delete',
dataTest: 'chatClear',
label: intl.formatMessage(intlMessages.clear),
onClick: () => clearPublicChatHistory(),
},
{
key: uniqueIdsRef.current[4],
key: uniqueIdsRef.current[3],
enable: showShowWelcomeMessages,
icon: 'about',
dataTest: 'restoreWelcomeMessages',
@ -150,7 +151,7 @@ export const ChatActions: React.FC = () => {
},
];
return dropdownActions.filter((action) => action.enable);
}, [userIsModerator, meetingIsBreakout]);
}, [userIsModerator, meetingIsBreakout, showShowWelcomeMessages]);
if (errorHistory) return <p>Error loading chat history: {JSON.stringify(errorHistory)}</p>;
if (errorPermissions) return <p>Error loading permissions: {JSON.stringify(errorPermissions)}</p>;
return (
@ -181,4 +182,4 @@ export const ChatActions: React.FC = () => {
actions={actions}
/>
);
}
}