From 3a819a29b7c0b3e1e9348e5a9baa0c766fb15f07 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 12 Aug 2016 11:01:01 +0100 Subject: [PATCH 1/2] Make up a device display name Pass a default device name into react-sdk --- package.json | 4 +++- src/vector/index.js | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 3863cd1443..d95348eed9 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/vector/index.js b/src/vector/index.js index 0750109404..6264f744d0 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -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') ); From 17733a66f9b199b351ba87951c2d9116667ab7ab Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Fri, 12 Aug 2016 11:40:25 +0100 Subject: [PATCH 2/2] rename MatrixChat defaultDeviceDisplayName prop --- src/vector/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vector/index.js b/src/vector/index.js index 6264f744d0..fff61bed49 100644 --- a/src/vector/index.js +++ b/src/vector/index.js @@ -137,7 +137,7 @@ var makeRegistrationUrl = function() { } -function getDefaultDeviceName() { +function getDefaultDeviceDisplayName() { // strip query-string and fragment from uri let u = url.parse(window.location.href); u.search = ""; @@ -253,7 +253,7 @@ async function loadApp() { startingFragmentQueryParams={fragparts.params} enableGuest={true} onLoadCompleted={onLoadCompleted} - default_device_name={getDefaultDeviceName()} + defaultDeviceDisplayName={getDefaultDeviceDisplayName()} />, document.getElementById('matrixchat') );