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