diff --git a/app/assets/stylesheets/chat.scss b/app/assets/stylesheets/chat.scss
index 4dc9f7740..38cd3585a 100644
--- a/app/assets/stylesheets/chat.scss
+++ b/app/assets/stylesheets/chat.scss
@@ -544,6 +544,50 @@
}
}
+.chat--video-visible {
+ .activechatchannel__conversation {
+ min-width: 25%;
+ @media screen and (min-width: 1440px) {
+ min-width: 45%;
+ }
+ }
+ .activechatchannel__activecontent {
+ &.activechatchannel__activecontent--video {
+ width: 380px;
+ min-width: 380px;
+ @media screen and (max-width: 426px) {
+ width: calc(100% - 16px);
+ min-width: calc(100% - 16px);
+ }
+ iframe {
+ position: absolute;
+ top: 0;
+ left: 0;
+ right: 0;
+ bottom: 0;
+ height: 100%;
+ width: 100%;
+ border: 0px;
+ }
+ }
+ width: 300px;
+ min-width: 300px;
+ @media screen and (min-width: 1000px) {
+ width: 400px;
+ min-width: 400px;
+ }
+ @media screen and (min-width: 1300px) {
+ width: 500px;
+ min-width: 500px;
+ }
+ }
+}
+
+.chat--content-visible .activechatchannel__activecontent.activechatchannel__activecontent--video {
+ width: 280px;
+ min-width: 280px;
+}
+
.live-chat-wrapper .activechatchannel__activecontent {
min-width: 310px;
margin-left: -180px;
diff --git a/app/controllers/video_chats_controller.rb b/app/controllers/video_chats_controller.rb
index 055eca400..42f2ab031 100644
--- a/app/controllers/video_chats_controller.rb
+++ b/app/controllers/video_chats_controller.rb
@@ -9,7 +9,8 @@ class VideoChatsController < ApplicationController
account_sid = ApplicationConfig["TWILIO_ACCOUNT_SID"]
api_key = ApplicationConfig["TWILIO_VIDEO_API_KEY"]
api_secret = ApplicationConfig["TWILIO_VIDEO_API_SECRET"]
- @username = "@" + current_user.username
+ @username = display_username
+ @video_type = video_type
token = Twilio::JWT::AccessToken.new(
account_sid,
api_key,
@@ -25,4 +26,20 @@ class VideoChatsController < ApplicationController
@username = @username
@token = token.to_jwt
end
+
+ private
+
+ def display_username
+ return "@#{params[:username]}" if params[:username] && Rails.env.development? #simpler solo testing in dev
+
+ "@" + current_user.username
+ end
+
+ def video_type
+ if @chat_channel.channel_type == "direct" || @chat_channel.chat_channel_memberships.size < 5
+ "peer-to-peer"
+ else
+ "group"
+ end
+ end
end
diff --git a/app/javascript/chat/__tests__/__snapshots__/chat.test.jsx.snap b/app/javascript/chat/__tests__/__snapshots__/chat.test.jsx.snap
index 33eb91fdd..9338555db 100644
--- a/app/javascript/chat/__tests__/__snapshots__/chat.test.jsx.snap
+++ b/app/javascript/chat/__tests__/__snapshots__/chat.test.jsx.snap
@@ -2,7 +2,7 @@
exports[` should load chat 1`] = `
should render properly and test snapshot 1`] = `
-
-
-
-
-
-
-
-`;
diff --git a/app/javascript/chat/__tests__/video.test.jsx b/app/javascript/chat/__tests__/video.test.jsx
deleted file mode 100644
index 5f50a8b77..000000000
--- a/app/javascript/chat/__tests__/video.test.jsx
+++ /dev/null
@@ -1,37 +0,0 @@
-import { h } from 'preact';
-import render from 'preact-render-to-json';
-import { deep } from 'preact-render-spy';
-import fetch from 'jest-fetch-mock';
-import Video from '../video';
-
-global.fetch = fetch;
-
-let exited;
-exited = false;
-
-const exitVideo = () => {
- exited = true;
-};
-
-describe('
', () => {
- it('should render properly and test snapshot', () => {
- const tree = render(
);
- expect(tree).toMatchSnapshot();
- });
-
- it('should have the proper elements, classes and information', () => {
- const context = deep(
);
-
- // check elements
- expect(context.find('.chat__videocall').exists()).toEqual(true);
- expect(context.find('.chat__remotevideoscreen-0').exists()).toEqual(true);
- expect(context.find('.chat__localvideoscren').exists()).toEqual(true);
- const exitButton = context.find('.chat__videocallexitbutton');
- expect(exitButton.exists()).toEqual(true);
- expect(exitButton.text()).toEqual('×');
-
- // test exit button behaves
- exitButton.simulate('click');
- expect(exited).toEqual(true);
- });
-});
diff --git a/app/javascript/chat/actions.js b/app/javascript/chat/actions.js
index 99354fea4..d60b2493e 100644
--- a/app/javascript/chat/actions.js
+++ b/app/javascript/chat/actions.js
@@ -152,17 +152,6 @@ export function getUnopenedChannelIds(successCb) {
});
}
-export function getTwilioToken(videoChannelName, successCb, failureCb) {
- fetch(`/twilio_tokens/${videoChannelName}`, {
- Accept: 'application/json',
- 'Content-Type': 'application/json',
- credentials: 'same-origin',
- })
- .then(response => response.json())
- .then(successCb)
- .catch(failureCb);
-}
-
export function getContent(url, successCb, failureCb) {
fetch(url, {
Accept: 'application/json',
diff --git a/app/javascript/chat/channels.jsx b/app/javascript/chat/channels.jsx
index 8fd91e154..fc4610f54 100644
--- a/app/javascript/chat/channels.jsx
+++ b/app/javascript/chat/channels.jsx
@@ -11,16 +11,12 @@ const Channels = ({
expanded,
filterQuery,
channelsLoaded,
- incomingVideoCallChannelIds,
}) => {
const channels = chatChannels.map(channel => {
const isActive = parseInt(activeChannelId, 10) === channel.chat_channel_id;
const isUnopened =
!isActive && unopenedChannelIds.includes(channel.chat_channel_id);
let newMessagesIndicator = isUnopened ? 'new' : 'old';
- if (incomingVideoCallChannelIds.indexOf(channel.chat_channel_id) > -1) {
- newMessagesIndicator = 'video';
- }
const otherClassname = isActive
? 'chatchanneltab--active'
: 'chatchanneltab--inactive';
@@ -122,7 +118,6 @@ Channels.propTypes = {
expanded: PropTypes.bool.isRequired,
filterQuery: PropTypes.string.isRequired,
channelsLoaded: PropTypes.bool.isRequired,
- incomingVideoCallChannelIds: PropTypes.arrayOf(PropTypes.string).isRequired,
};
export default Channels;
diff --git a/app/javascript/chat/chat.jsx b/app/javascript/chat/chat.jsx
index ea64df045..a50a2f267 100644
--- a/app/javascript/chat/chat.jsx
+++ b/app/javascript/chat/chat.jsx
@@ -21,7 +21,7 @@ import Compose from './compose';
import Message from './message';
import ActionMessage from './actionMessage';
import Content from './content';
-import Video from './video';
+import VideoContent from './videoContent'
import setupPusher from '../src/utils/pusher';
import debounceAction from '../src/utils/debounceAction';
@@ -61,15 +61,12 @@ export default class Chat extends Component {
currentUserId: chatOptions.currentUserId,
notificationsPermission: null,
activeContent: {},
+ videoPath: null,
expanded: window.innerWidth > 600,
isMobileDevice: typeof window.orientation !== 'undefined',
subscribedPusherChannels: [],
- activeVideoChannelId: null,
- incomingVideoCallChannelIds: [],
- videoCallParticipants: [],
inviteChannels: [],
soundOn: true,
- videoOn: true,
messageOffset: 0,
showDeleteModal: false,
messageDeleteId: null,
@@ -153,32 +150,6 @@ export default class Chat extends Component {
}
}
- liveCoding = (e) => {
- const { activeContent, activeChannelId } = this.state;
- if (activeContent !== { type_of: 'code_editor' }) {
- activeContent[activeChannelId] = { type_of: 'code_editor' };
- this.setState({ activeContent });
- }
- if (document.querySelector('.CodeMirror')) {
- const cm = document.querySelector('.CodeMirror').CodeMirror;
- if (cm && e.context === 'initializing-live-code-channel') {
- window.pusher.channel(e.channel).trigger('client-livecode', {
- value: cm.getValue(),
- cursorPos: cm.getCursor(),
- });
- } else if ((cm && e.keyPressed === true) || e.value.length > 0) {
- const cursorCoords = e.cursorPos;
- const cursorElement = document.createElement('span');
- cursorElement.classList.add('cursorelement');
- cursorElement.style.height = `${
- cursorCoords.bottom - cursorCoords.top
- }px`;
- cm.setValue(e.value);
- cm.setBookmark(e.cursorPos, { widget: cursorElement });
- }
- }
- };
-
filterForActiveChannel = (channels, id) =>
channels.filter(
(channel) => channel.chat_channel_id === parseInt(id, 10),
@@ -196,9 +167,6 @@ export default class Chat extends Component {
channelCleared: this.clearChannel,
redactUserMessages: this.redactUserMessages,
channelError: this.channelError,
- liveCoding: this.liveCoding,
- videoCallInitiated: this.receiveVideoCall,
- videoCallEnded: this.receiveVideoCallHangup,
mentioned: this.mentioned,
messageOpened: this.messageOpened,
});
@@ -479,19 +447,6 @@ export default class Chat extends Component {
}));
};
- receiveVideoCall = (callObj) => {
- this.setState((prevState) => ({
- incomingVideoCallChannelIds: [...prevState, callObj.channelId],
- }));
- };
-
- receiveVideoCallHangup = () => {
- const { videoCallParticipants } = this.state;
- if (videoCallParticipants.size < 1) {
- this.setState({ activeVideoChannelId: null });
- }
- };
-
redactUserMessages = (res) => {
const { messages } = this.state;
const newMessages = hideMessages(messages, res.userId);
@@ -606,10 +561,7 @@ export default class Chat extends Component {
message: '/call',
mentionedUsersId: this.getMentionedUsers(message),
};
- this.setActiveContent({
- path: `/video_chats/${activeChannelId}`,
- type_of: 'article',
- });
+ this.setState({videoPath: 'http://localhost:3000/video_chats/' + activeChannelId})
sendMessage(messageObject, this.handleSuccess, this.handleFailure);
} else if (message.startsWith('/new')) {
this.setActiveContentState(activeChannelId, {
@@ -651,36 +603,6 @@ export default class Chat extends Component {
);
};
- answerVideoCall = () => {
- const { activeChannelId } = this.state;
- this.setState({
- activeVideoChannelId: activeChannelId,
- incomingVideoCallChannelIds: [],
- });
- };
-
- hangupVideoCall = () => {
- const { activeVideoChannelId } = this.state;
- window.pusher
- .channel(`presence-channel-${activeVideoChannelId}`)
- .trigger('client-endvideocall', {});
- this.setState({
- activeVideoChannelId: null,
- });
- };
-
- handleVideoParticipantChange = (participants) => {
- this.setState({ videoCallParticipants: participants });
- };
-
- toggleVideoSound = () => {
- this.setState((prevState) => ({ soundOn: !prevState.soundOn }));
- };
-
- toggleVideoVideo = () => {
- this.setState((prevState) => ({ videoOn: !prevState.videoOn }));
- };
-
triggerSwitchChannel = (id, slug) => {
const {
chatChannels,
@@ -812,6 +734,8 @@ export default class Chat extends Component {
path: `/chat_channel_memberships/${activeChannel.id}/edit`,
type_of: 'article',
});
+ } else if (content.startsWith('sidecar-video')) {
+ this.setState({videoPath: target.href || target.parentElement.href})
} else if (
content.startsWith('sidecar') ||
content.startsWith('article')
@@ -1097,7 +1021,6 @@ export default class Chat extends Component {
channelsLoaded={state.channelsLoaded}
filterQuery={state.filterQuery}
expanded={state.expanded}
- incomingVideoCallChannelIds={state.incomingVideoCallChannelIds}
/>
{notificationsState}
@@ -1115,7 +1038,6 @@ export default class Chat extends Component {
{'>'}