join session by custom url schema

This commit is contained in:
Nuwan 2024-10-11 22:00:10 +05:30
parent 98273bae0d
commit fb80a3a2c5
2 changed files with 41 additions and 0 deletions

View File

@ -549,6 +549,14 @@
const customUrl = response['JKSessionCreateFromCustomUrlEvent']['CustomUrl']
context.JK.createScheduledSessionScreen.launchSessionFromCustomUrlScheme(customUrl)
}
break;
case '3013': //JKJoinSessionFromCustomUrlEvent
logger.log(`[asyncJamClient] 3013 JKJoinSessionFromCustomUrlEvent: ${response['JKJoinSessionFromCustomUrlEvent']['CustomUrl']}`);
if(context.JK.FindSessionScreen){
const customUrl = response['JKJoinSessionFromCustomUrlEvent']['CustomUrl']
context.JK.SessionUtils.joinSessionByCustomUrlScheme(customUrl)
}
break;
default:
break;
}

View File

@ -344,4 +344,37 @@
await context.jamClient.SessionPageLeave();
}
sessionUtils.joinSessionFromCustomUrlScheme = function(urlString) {
let url;
try {
url = new URL(urlString);
} catch (error) {
logger.debug(error);
context.JK.app.notifyAlert("Error", "An invalid URL was given. Couldn't create the session. Please try again.");
return;
}
const hash = decodeURIComponent(url.hash);
const qStr = hash.substring(hash.lastIndexOf('/') + 1);
const qParamsArr = qStr.split('|');
let isCustom = undefined;
let sessionId = undefined;
qParamsArr.forEach(function(q) {
const qp = q.split('~');
if (qp[0] === 'custom') {
isCustom = qp[1];
}
if (qp[0] === 'joinSessionId') {
return sessionId = qp[1];
}});
if (!isCustom || (isCustom !== 'yes')) {
return;
}
if (!sessionId) {
return;
}
this.joinSession(sessionId);
}
})(window, jQuery);