2018-12-17 19:48:34 +08:00
|
|
|
import React, { memo } from 'react';
|
2018-01-08 12:44:42 +08:00
|
|
|
import { withTracker } from 'meteor/react-meteor-data';
|
2017-03-17 03:57:45 +08:00
|
|
|
import UserListService from '/imports/ui/components/user-list/service';
|
2017-03-29 02:41:48 +08:00
|
|
|
import Settings from '/imports/ui/services/settings';
|
2018-08-10 01:02:18 +08:00
|
|
|
import ChatAlert from './component';
|
2019-01-14 21:23:35 +08:00
|
|
|
import Auth from '/imports/ui/services/auth';
|
|
|
|
import Users from '/imports/api/users';
|
2017-03-17 03:57:45 +08:00
|
|
|
|
2018-08-10 01:02:18 +08:00
|
|
|
const ChatAlertContainer = props => (
|
|
|
|
<ChatAlert {...props} />
|
2017-10-28 03:29:48 +08:00
|
|
|
);
|
2017-03-17 03:57:45 +08:00
|
|
|
|
2018-01-08 12:44:42 +08:00
|
|
|
export default withTracker(() => {
|
2017-03-29 02:41:48 +08:00
|
|
|
const AppSettings = Settings.application;
|
2021-02-02 06:12:04 +08:00
|
|
|
const activeChats = [];
|
|
|
|
// UserListService.getActiveChats();
|
2019-08-02 00:47:11 +08:00
|
|
|
const { loginTime } = Users.findOne({ userId: Auth.userID }, { fields: { loginTime: 1 } });
|
2020-03-06 07:14:22 +08:00
|
|
|
|
|
|
|
const openPanel = Session.get('openPanel');
|
|
|
|
let idChatOpen = Session.get('idChatOpen');
|
|
|
|
|
|
|
|
// Currently the panel can switch from the chat panel to something else and the idChatOpen won't
|
|
|
|
// always reset. A better solution would be to make the openPanel Session variable an
|
|
|
|
// Object { panelType: <String>, panelOptions: <Object> } and then get rid of idChatOpen
|
|
|
|
if (openPanel !== 'chat') {
|
|
|
|
idChatOpen = '';
|
|
|
|
}
|
|
|
|
|
2017-03-17 03:57:45 +08:00
|
|
|
return {
|
2019-01-14 21:23:35 +08:00
|
|
|
audioAlertDisabled: !AppSettings.chatAudioAlerts,
|
|
|
|
pushAlertDisabled: !AppSettings.chatPushAlerts,
|
|
|
|
activeChats,
|
2018-07-27 21:44:21 +08:00
|
|
|
publicUserId: Meteor.settings.public.chat.public_group_id,
|
2019-01-14 21:23:35 +08:00
|
|
|
joinTimestamp: loginTime,
|
2020-03-06 07:14:22 +08:00
|
|
|
idChatOpen,
|
2017-03-17 03:57:45 +08:00
|
|
|
};
|
2018-12-17 19:48:34 +08:00
|
|
|
})(memo(ChatAlertContainer));
|