improved on logic for open private chat
This commit is contained in:
parent
717a1e2db2
commit
0d1b085d54
@ -45,7 +45,7 @@ const propTypes = {
|
||||
actionsbar: PropTypes.element,
|
||||
closedCaption: PropTypes.element,
|
||||
userListIsOpen: PropTypes.bool.isRequired,
|
||||
chat: PropTypes.element,
|
||||
chatIsOpen: PropTypes.bool.isRequired,
|
||||
locale: PropTypes.string,
|
||||
intl: intlShape.isRequired,
|
||||
};
|
||||
@ -57,7 +57,6 @@ const defaultProps = {
|
||||
media: null,
|
||||
actionsbar: null,
|
||||
closedCaption: null,
|
||||
chat: null,
|
||||
locale: 'en',
|
||||
};
|
||||
|
||||
@ -65,8 +64,6 @@ class App extends Component {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
console.log('1');
|
||||
|
||||
this.state = {
|
||||
compactUserList: false,
|
||||
enableResize: !window.matchMedia(MOBILE_MEDIA).matches,
|
||||
@ -162,7 +159,7 @@ class App extends Component {
|
||||
<div
|
||||
className={cx(styles.userList, userListStyle)}
|
||||
aria-label={intl.formatMessage(intlMessages.userListLabel)}
|
||||
aria-hidden={chatIsOpen /* TODO 4767 -- Why is this not `userListIsOpen` */}
|
||||
aria-hidden={chatIsOpen}
|
||||
>
|
||||
<UserListContainer />
|
||||
</div>
|
||||
@ -301,7 +298,7 @@ class App extends Component {
|
||||
}
|
||||
|
||||
render() {
|
||||
const { params, userListIsOpen } = this.props;
|
||||
const { userListIsOpen } = this.props;
|
||||
const { enableResize } = this.state;
|
||||
|
||||
return (
|
||||
@ -321,7 +318,7 @@ class App extends Component {
|
||||
<ModalContainer />
|
||||
<AudioContainer />
|
||||
<ToastContainer />
|
||||
{/* <ChatAlertContainer currentChatID={params.chatID} /> TODO 4767 */}
|
||||
<ChatAlertContainer />
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ export default injectIntl(withModalMounter(withTracker(({ intl, baseControls })
|
||||
closedCaption: getCaptionsStatus() ? <ClosedCaptionsContainer /> : null,
|
||||
fontSize: getFontSize(),
|
||||
userListIsOpen: Boolean(Session.get('isUserListOpen')),
|
||||
chatIsOpen: Boolean(Session.get('isChatOpen')),
|
||||
chatIsOpen: Boolean(Session.get('isChatOpen') && Session.get('isUserListOpen')),
|
||||
};
|
||||
})(AppContainer)));
|
||||
|
||||
|
@ -57,7 +57,6 @@ const Chat = (props) => {
|
||||
<Button
|
||||
onClick={() => {
|
||||
Session.set('isChatOpen', false);
|
||||
alert('A');
|
||||
}}
|
||||
aria-label={intl.formatMessage(intlMessages.hideChatLabel, { 0: title })}
|
||||
accessKey={HIDE_CHAT_AK}
|
||||
|
@ -31,7 +31,7 @@ const intlMessages = defineMessages({
|
||||
class ChatContainer extends Component {
|
||||
componentDidMount() {
|
||||
// in case of reopening a chat, need to make sure it's removed from closed list
|
||||
ChatService.removeFromClosedChatsSession(this.props.chatID); // TODO 4767
|
||||
ChatService.removeFromClosedChatsSession();
|
||||
}
|
||||
render() {
|
||||
return (
|
||||
@ -100,7 +100,7 @@ export default injectIntl(withTracker(({ intl }) => {
|
||||
const lastReadMessageTime = ChatService.lastReadMessageTime(chatID);
|
||||
|
||||
return {
|
||||
chatID,
|
||||
chatID: Session.get('idChatOpen'),
|
||||
chatName,
|
||||
title,
|
||||
messages,
|
||||
@ -115,13 +115,13 @@ export default injectIntl(withTracker(({ intl }) => {
|
||||
handleClosePrivateChat: chatId => ChatService.closePrivateChat(chatId),
|
||||
|
||||
handleSendMessage: (message) => {
|
||||
ChatService.updateScrollPosition(chatID, null);
|
||||
return ChatService.sendGroupMessage(chatID, message);
|
||||
ChatService.updateScrollPosition(null);
|
||||
return ChatService.sendGroupMessage(message);
|
||||
},
|
||||
|
||||
handleScrollUpdate: position => ChatService.updateScrollPosition(chatID, position),
|
||||
handleScrollUpdate: position => ChatService.updateScrollPosition(position),
|
||||
|
||||
handleReadMessage: timestamp => ChatService.updateUnreadMessage(chatID, timestamp),
|
||||
handleReadMessage: timestamp => ChatService.updateUnreadMessage(timestamp),
|
||||
},
|
||||
};
|
||||
})(ChatContainer));
|
||||
|
@ -129,7 +129,6 @@ class MessageForm extends Component {
|
||||
render() {
|
||||
const {
|
||||
intl, chatTitle, chatName, disabled,
|
||||
minMessageLength, maxMessageLength,
|
||||
} = this.props;
|
||||
|
||||
const { hasErrors, error } = this.state;
|
||||
|
@ -86,7 +86,8 @@ const getPublicGroupMessages = () => {
|
||||
return publicGroupMessages;
|
||||
};
|
||||
|
||||
const getPrivateGroupMessages = (chatID) => {
|
||||
const getPrivateGroupMessages = () => {
|
||||
const chatID = Session.get('idChatOpen');
|
||||
const sender = getUser(Auth.userID);
|
||||
|
||||
const privateChat = GroupChat.findOne({
|
||||
@ -141,7 +142,8 @@ const lastReadMessageTime = (receiverID) => {
|
||||
return UnreadMessages.get(chatType);
|
||||
};
|
||||
|
||||
const sendGroupMessage = (chatID, message) => {
|
||||
const sendGroupMessage = (message) => {
|
||||
const chatID = Session.get('idChatOpen');
|
||||
const isPublicChat = chatID === PUBLIC_CHAT_ID;
|
||||
|
||||
let chatId = PUBLIC_GROUP_CHAT_ID;
|
||||
@ -186,20 +188,22 @@ const getScrollPosition = (receiverID) => {
|
||||
};
|
||||
|
||||
const updateScrollPosition =
|
||||
(receiverID, position) => ScrollCollection.upsert(
|
||||
{ receiver: receiverID },
|
||||
position => ScrollCollection.upsert(
|
||||
{ receiver: Session.get('idChatOpen') },
|
||||
{ $set: { position } },
|
||||
);
|
||||
|
||||
const updateUnreadMessage = (receiverID, timestamp) => {
|
||||
const isPublic = receiverID === PUBLIC_CHAT_ID;
|
||||
const chatType = isPublic ? PUBLIC_GROUP_CHAT_ID : receiverID;
|
||||
const updateUnreadMessage = (timestamp) => {
|
||||
const chatID = Session.get('idChatOpen');
|
||||
const isPublic = chatID === PUBLIC_CHAT_ID;
|
||||
const chatType = isPublic ? PUBLIC_GROUP_CHAT_ID : chatID;
|
||||
return UnreadMessages.update(chatType, timestamp);
|
||||
};
|
||||
|
||||
const clearPublicChatHistory = () => (makeCall('clearPublicChatHistory'));
|
||||
|
||||
const closePrivateChat = (chatID) => {
|
||||
const closePrivateChat = () => {
|
||||
const chatID = Session.get('idChatOpen');
|
||||
const currentClosedChats = Storage.getItem(CLOSED_CHAT_LIST_KEY) || [];
|
||||
|
||||
if (_.indexOf(currentClosedChats, chatID) < 0) {
|
||||
@ -210,7 +214,8 @@ const closePrivateChat = (chatID) => {
|
||||
};
|
||||
|
||||
// if this private chat has been added to the list of closed ones, remove it
|
||||
const removeFromClosedChatsSession = (chatID) => {
|
||||
const removeFromClosedChatsSession = () => {
|
||||
const chatID = Session.get('idChatOpen');
|
||||
const currentClosedChats = Storage.getItem(CLOSED_CHAT_LIST_KEY);
|
||||
if (_.indexOf(currentClosedChats, chatID) > -1) {
|
||||
Storage.setItem(CLOSED_CHAT_LIST_KEY, _.without(currentClosedChats, chatID));
|
||||
|
@ -8,10 +8,9 @@ import ListSeparator from './separator/component';
|
||||
import ListTitle from './title/component';
|
||||
|
||||
const propTypes = {
|
||||
/* We should recheck this proptype, sometimes we need to create an container and send to dropdown,
|
||||
but with this */
|
||||
// proptype, is not possible.
|
||||
children: PropTypes.arrayOf((propValue, key, componentName, location, propFullName) => { // TODO 4767
|
||||
/* We should recheck this proptype, sometimes we need to create an container and send to
|
||||
dropdown, but with this proptype, is not possible. */
|
||||
children: PropTypes.arrayOf((propValue, key, componentName, propFullName) => {
|
||||
if (propValue[key].type !== ListItem &&
|
||||
propValue[key].type !== ListSeparator &&
|
||||
propValue[key].type !== ListTitle) {
|
||||
|
@ -79,22 +79,19 @@ class NavBar extends Component {
|
||||
this.handleToggleUserList = this.handleToggleUserList.bind(this);
|
||||
}
|
||||
|
||||
handleToggleUserList() {
|
||||
this.props.toggleUserList();
|
||||
}
|
||||
|
||||
componentDidUpdate(oldProps) {
|
||||
const {
|
||||
breakouts,
|
||||
getBreakoutJoinURL,
|
||||
isBreakoutRoom,
|
||||
mountModal,
|
||||
} = this.props;
|
||||
|
||||
const hadBreakouts = oldProps.breakouts.length;
|
||||
const hasBreakouts = breakouts.length;
|
||||
|
||||
if (!hasBreakouts && hadBreakouts) {
|
||||
closeBreakoutJoinConfirmation(this.props.mountModal);
|
||||
closeBreakoutJoinConfirmation(mountModal);
|
||||
}
|
||||
|
||||
breakouts.forEach((breakout) => {
|
||||
@ -112,6 +109,10 @@ class NavBar extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
handleToggleUserList() {
|
||||
this.props.toggleUserList();
|
||||
}
|
||||
|
||||
inviteUserToBreakout(breakout) {
|
||||
const {
|
||||
mountModal,
|
||||
|
@ -11,10 +11,10 @@ import DropdownList from '/imports/ui/components/dropdown/list/component';
|
||||
import DropdownListItem from '/imports/ui/components/dropdown/list/item/component';
|
||||
import DropdownListSeparator from '/imports/ui/components/dropdown/list/separator/component';
|
||||
import _ from 'lodash';
|
||||
import { Session } from 'meteor/session';
|
||||
import { styles } from './styles';
|
||||
import UserName from './../user-name/component';
|
||||
import UserIcons from './../user-icons/component';
|
||||
import { Session } from 'meteor/session';
|
||||
|
||||
const messages = defineMessages({
|
||||
presenter: {
|
||||
@ -235,7 +235,7 @@ class UserDropdown extends Component {
|
||||
intl.formatMessage(messages.ChatLabel),
|
||||
() => {
|
||||
Session.set('idChatOpen', user.id);
|
||||
console.error(`__ idChatOpen: ${Session.get('idChatOpen')}`);
|
||||
Session.set('isChatOpen', true);
|
||||
},
|
||||
'chat',
|
||||
));
|
||||
|
Loading…
Reference in New Issue
Block a user