Skip to content

Commit

Permalink
update galene plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
deleolajide committed Jun 20, 2023
1 parent b21b839 commit 30f50e5
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 202 deletions.
42 changes: 32 additions & 10 deletions packages/galene/galene-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -2769,6 +2769,8 @@ function formatToken(token, details) {
let url = new URL(window.location.href);
let params = new URLSearchParams();
params.append('token', token.token);
params.append('room', token.group); // BAO
params.append('username', token.username); // BAO
url.search = params.toString();
let foruser = '', by = '', togroup = '';
if(token.username)
Expand Down Expand Up @@ -3992,29 +3994,34 @@ window.onload = async function() {
serverConnection.onchat = addToChatbox;
serverConnection.onusermessage = gotUserMessage;
serverConnection.onfiletransfer = gotFileTransfer;

group = urlParam("group") ? "public/" + urlParam("group") : "public";

token = urlParam("token");
group = urlParam("room") ? urlParam("room") : "public";
setTitle(capitalise(group));
addFilters();
setMediaChoices(false).then(e => reflectSettings());
setMediaChoices(false).then(e => reflectSettings());

handleConnection();
}

async function handleConnection() {
const host = urlParam("host") || location.hostname;
const server = urlParam("server") || location.host;
const username = urlParam("username");
const password = urlParam("password");
const jid = (username && password) ? username + "@" + host : host;

console.debug("handleConnection", connection, host, username);
console.debug("handleConnection", connection, jid);

if (connection) {
await serverConnection.connect(connection, host);
setViewportHeight();

} else {
standalone = true;
connection = new Strophe.Connection((location.protocol == "https:" ? "wss:" : "ws:") + "//" + location.host + "/ws/");
connection = new Strophe.Connection((location.protocol == "http:" ? "ws:" : "wss:") + "//" + server + "/ws/");

connection.connect(host, null, async function (status) {
connection.connect(jid, password, async function (status) {
console.debug("onload xmpp.connect", status);

if (status === Strophe.Status.CONNECTED) {
Expand Down Expand Up @@ -4044,15 +4051,30 @@ function urlParam (name) {

async function amConnected() {
console.debug("amConnected");
const server = urlParam("server") || ((location.protocol == "http:" ? "http:" : "https:") + "//" + location.host + "/galene");
setConnected(true);
connectingAgain = false;

const username = urlParam("username") || localStorage.getItem("galene_username") || prompt("Enter username");
const pw = "";
let username, credentials;

if (token) {
username = urlParam("username") || "";
credentials = {type: 'token', token: token };
}
else

if (urlParam("room")) {
username = urlParam("username") || connection.jid.split("@")[0] || "";
credentials = {
type: 'authServer',
authServer: server + "/auth-server",
location: location.href,
password: urlParam("password") || connection.pass || ""
};
}

try {
await serverConnection.join(group, username, pw);
localStorage.setItem("galene_username", username);
await serverConnection.join(group, username, credentials);
} catch(e) {
console.error(e);
serverConnection.close();
Expand Down
8 changes: 4 additions & 4 deletions packages/galene/galene.css
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
align-items: center;
-webkit-box-pack: justify;
justify-content: space-between;
background: #610a86;
background: #616a86; /* BAO */
}
.navbar {
position: relative;
Expand Down Expand Up @@ -274,7 +274,7 @@
.users-header {
height: 3.5rem;
padding: 10px;
background: #610a86;
background: #616a86; /* BAO */
font-size: .95rem;
font-weight: 500;
}
Expand Down Expand Up @@ -902,7 +902,7 @@ h1 {
}

.peer-active {
border: 2px solid #610a86;
border: 2px solid #616a86; /* BAO */
}

.peer-hidden {
Expand Down Expand Up @@ -1333,7 +1333,7 @@ header .collapse:hover {
}

.file-progress {
accent-color: #610a86;
accent-color: #616a86; /* BAO */
margin-left: 10px;
margin-right: 10px;
}
Expand Down
Loading

0 comments on commit 30f50e5

Please sign in to comment.