Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Room type with Converse.js replacing jitsi #385

Merged
merged 26 commits into from
Apr 8, 2021
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5adf316
initial converse inclusion with creation of streaming room
Mar 14, 2021
7c00673
Merge branch 'master' into chat
Mar 14, 2021
f865b07
cleaned up converse init
Mar 14, 2021
671a839
pushing for andrew to look at
Mar 14, 2021
02165d2
initial configuration for converse
rene-grigory Mar 18, 2021
dfde39e
Merge branch 'master' into chat
rene-grigory Mar 18, 2021
1d57567
merged from upstream
rene-grigory Mar 18, 2021
c10398c
merged from upstream
rene-grigory Mar 18, 2021
dfcdb08
removed node_modules from git
rene-grigory Mar 18, 2021
09b1df7
created auto logout when leaving the room
Mar 19, 2021
1fe98b3
got rid of needless code
Mar 19, 2021
b85be73
ready for styling and cleanup
Mar 19, 2021
f155948
finished hijacking css
rene-grigory Mar 22, 2021
7c00179
Merge branch 'master' into chat
rene-grigory Mar 22, 2021
21f35c3
revered iframe link
rene-grigory Mar 22, 2021
fd36859
code clean up
rene-grigory Mar 22, 2021
d7599ec
Merge branch 'master' into chat
Mar 23, 2021
80adc18
fixed comment in rooms.proto
rene-grigory Mar 23, 2021
9c99bb2
logout user in beforeUnload
rene-grigory Mar 23, 2021
a093676
hide offline users and brought in the latest convers.js lib
rene-grigory Mar 26, 2021
85c5117
Merge branch 'master' into chat
rene-grigory Mar 26, 2021
5165ca7
format cleanup
rene-grigory Apr 1, 2021
30346f8
more cleanup and useing Config.baseUrl to point at the bash service
rene-grigory Apr 1, 2021
4eaa9ed
replaced old listener with MutationObserver since none of the convers…
rene-grigory Apr 1, 2021
83df75c
removed comment and fixed console.error
rene-grigory Apr 2, 2021
f3b7421
added style variables for the chat box
rene-grigory Apr 8, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ app/email_config.sh
app/config/overrides
app/client/styles/themes/_active.scss

# Node Modules
app/client/node_modules/

# Flask
.DS_Store
.env
Expand Down
591 changes: 591 additions & 0 deletions app/client/js/converse.min.js

Large diffs are not rendered by default.

84 changes: 84 additions & 0 deletions app/client/jsx/ChatStreamRoom.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import React, { useEffect } from "react";

/**
* This component is used to render a Converse.js chat component on the
* left side and an IFrame on the right. While this component does have
* the jitsi-video class in the render it is only for placement: there
* is no jitsi video in this component.
*
* This component works in conjunction with the CHATSTREAM room type.
*
* @param props a combo of roomData and jitsiData
* @returns
*/
export const ChatStreamRoom = ({
id: roomId,
name: roomName,
displayName,
boshUrl,
iframeOptions: { src },
}) => {
// register the 'jitsi-plugin' and initialize converse and cleanup after close
useEffect(() => {
let logout = null;
let plugins = null;

// configure the 'jitsi-plugin' to get our hands on the converse api logout
try {
window.converse.plugins.add("jitsi-plugin", {
initialize: function () {
logout = this._converse.api.user.logout;
plugins = this._converse.pluggable.plugins;

// add event listener to restucture the chatbox
this._converse.api.listen.on("chatBoxInsertedIntoDOM", () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently the chatBoxInsertedIntoDOM event will be removed in the next major version: https://github.com/conversejs/converse.js/blob/master/CHANGES.md

We could replace it with one of these events: https://github.com/conversejs/converse.js/blob/master/src/plugins/minimize/index.js#L128-L133

const title = document.querySelector(".chatbox-title__text");
const dd = document.querySelector(".chatbox-title__buttons");

title.innerHTML = roomName;
dd.remove();
});
},
});
} catch (error) {
// do nothing since the plugin is already registered
console.error("Well, that didn't work");
}

// initialize converse
window.converse.initialize({
authentication: "anonymous",
auto_login: true,
auto_join_rooms: [
{ jid: `${roomId}@muc.party.jitsi`, nick: displayName },
],
bosh_service_url: boshUrl,
jid: "guest.party.jitsi",
singleton: true,
clear_cache_on_logout: true,
whitelisted_plugins: ["jitsi-plugin"],
view_mode: "embedded",
});

// listen to beforeunload to logout and cleanup
window.addEventListener("beforeunload", () => {
plugins["jitsi-plugin"] = undefined;
logout();
});

// call the converse api logout at cleanup
return () => {
plugins["jitsi-plugin"] = undefined;
logout();
};
}, []);

return (
<div className="iframe-room">
<div className="jitsi-video"></div>
<div className="iframe-section">
<iframe src={src} height="100%" width="100%" frameBorder="0px"></iframe>
</div>
</div>
);
};
Loading