Make up a device display name

Pass a default device name into react-sdk
This commit is contained in:
Richard van der Hoff 2016-08-12 11:01:01 +01:00
parent bb1854814c
commit 3a819a29b7
2 changed files with 19 additions and 1 deletions

View file

@ -55,7 +55,9 @@
"react-dnd-html5-backend": "^2.1.2",
"react-dom": "^15.2.1",
"react-gemini-scrollbar": "matrix-org/react-gemini-scrollbar#5e97aef",
"sanitize-html": "^1.11.1"
"sanitize-html": "^1.11.1",
"ua-parser-js": "^0.7.10",
"url": "^0.11.0"
},
"devDependencies": {
"babel": "^5.8.23",

View file

@ -44,6 +44,8 @@ var VectorConferenceHandler = require('../VectorConferenceHandler');
var UpdateChecker = require("./updater");
var q = require('q');
var request = require('browser-request');
import UAParser from 'ua-parser-js';
import url from 'url';
import {parseQs, parseQsFromFragment} from './url_utils';
@ -134,6 +136,19 @@ var makeRegistrationUrl = function() {
'#/register';
}
function getDefaultDeviceName() {
// strip query-string and fragment from uri
let u = url.parse(window.location.href);
u.search = "";
u.hash = "";
let app_name = u.format();
let ua = new UAParser();
return app_name + " via " + ua.getBrowser().name +
" on " + ua.getOS().name;
}
window.addEventListener('hashchange', onHashChange);
window.onload = function() {
console.log("window.onload");
@ -238,6 +253,7 @@ async function loadApp() {
startingFragmentQueryParams={fragparts.params}
enableGuest={true}
onLoadCompleted={onLoadCompleted}
default_device_name={getDefaultDeviceName()}
/>,
document.getElementById('matrixchat')
);