Merge branch 'develop' into markjh/attachment_iframe_css
This commit is contained in:
commit
6c21391ff5
12 changed files with 230 additions and 41 deletions
|
@ -22,7 +22,8 @@ module.exports = React.createClass({
|
|||
displayName: 'ViewSource',
|
||||
|
||||
propTypes: {
|
||||
onFinished: React.PropTypes.func.isRequired
|
||||
content: React.PropTypes.object.isRequired,
|
||||
onFinished: React.PropTypes.func.isRequired,
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
|
@ -45,10 +46,9 @@ module.exports = React.createClass({
|
|||
return (
|
||||
<div className="mx_ViewSource">
|
||||
<pre>
|
||||
{JSON.stringify(this.props.mxEvent.event, null, 2)}
|
||||
{JSON.stringify(this.props.content, null, 2)}
|
||||
</pre>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -47,7 +47,16 @@ module.exports = React.createClass({
|
|||
onViewSourceClick: function() {
|
||||
var ViewSource = sdk.getComponent('structures.ViewSource');
|
||||
Modal.createDialog(ViewSource, {
|
||||
mxEvent: this.props.mxEvent
|
||||
content: this.props.mxEvent.event,
|
||||
}, 'mx_Dialog_viewsource');
|
||||
if (this.props.onFinished) this.props.onFinished();
|
||||
},
|
||||
|
||||
onViewClearSourceClick: function() {
|
||||
const ViewSource = sdk.getComponent('structures.ViewSource');
|
||||
Modal.createDialog(ViewSource, {
|
||||
// FIXME: _clearEvent is private
|
||||
content: this.props.mxEvent._clearEvent,
|
||||
}, 'mx_Dialog_viewsource');
|
||||
if (this.props.onFinished) this.props.onFinished();
|
||||
},
|
||||
|
@ -97,6 +106,7 @@ module.exports = React.createClass({
|
|||
var eventStatus = this.props.mxEvent.status;
|
||||
var resendButton;
|
||||
var viewSourceButton;
|
||||
var viewClearSourceButton;
|
||||
var redactButton;
|
||||
var cancelButton;
|
||||
var permalinkButton;
|
||||
|
@ -133,6 +143,14 @@ module.exports = React.createClass({
|
|||
</div>
|
||||
);
|
||||
|
||||
if (this.props.mxEvent.getType() !== this.props.mxEvent.getWireType()) {
|
||||
viewClearSourceButton = (
|
||||
<div className="mx_MessageContextMenu_field" onClick={this.onViewClearSourceClick}>
|
||||
View Decrypted Source
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (this.props.eventTileOps) {
|
||||
if (this.props.eventTileOps.isWidgetHidden()) {
|
||||
unhidePreviewButton = (
|
||||
|
@ -174,6 +192,7 @@ module.exports = React.createClass({
|
|||
{redactButton}
|
||||
{cancelButton}
|
||||
{viewSourceButton}
|
||||
{viewClearSourceButton}
|
||||
{unhidePreviewButton}
|
||||
{permalinkButton}
|
||||
{UserSettingsStore.isFeatureEnabled('rich_text_editor') ? quoteButton : null}
|
||||
|
|
|
@ -54,7 +54,6 @@ 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';
|
||||
|
@ -120,6 +119,8 @@ var lastLoadedScreen = null;
|
|||
// so a web page can update the URL bar appropriately.
|
||||
var onNewScreen = function(screen) {
|
||||
console.log("newscreen "+screen);
|
||||
// just remember the most recent screen while we are loading, so that the
|
||||
// user doesn't see the URL bar doing a dance
|
||||
if (!loaded) {
|
||||
lastLoadedScreen = screen;
|
||||
} else {
|
||||
|
@ -142,33 +143,7 @@ var makeRegistrationUrl = function() {
|
|||
'#/register';
|
||||
}
|
||||
|
||||
|
||||
function getDefaultDeviceDisplayName() {
|
||||
// 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");
|
||||
if (!validBrowser) {
|
||||
return;
|
||||
}
|
||||
UpdateChecker.start();
|
||||
routeUrl(window.location);
|
||||
loaded = true;
|
||||
if (lastLoadedScreen) {
|
||||
onNewScreen(lastLoadedScreen);
|
||||
lastLoadedScreen = null;
|
||||
}
|
||||
}
|
||||
|
||||
function getConfig() {
|
||||
let deferred = q.defer();
|
||||
|
@ -259,6 +234,8 @@ async function loadApp() {
|
|||
Unable to load config file: please refresh the page to try again.
|
||||
</div>, document.getElementById('matrixchat'));
|
||||
} else if (validBrowser) {
|
||||
UpdateChecker.start();
|
||||
|
||||
var MatrixChat = sdk.getComponent('structures.MatrixChat');
|
||||
|
||||
window.matrixChat = ReactDOM.render(
|
||||
|
@ -271,10 +248,19 @@ async function loadApp() {
|
|||
startingFragmentQueryParams={fragparts.params}
|
||||
enableGuest={true}
|
||||
onLoadCompleted={onLoadCompleted}
|
||||
defaultDeviceDisplayName={getDefaultDeviceDisplayName()}
|
||||
defaultDeviceDisplayName={PlatformPeg.get().getDefaultDeviceDisplayName()}
|
||||
/>,
|
||||
document.getElementById('matrixchat')
|
||||
);
|
||||
|
||||
routeUrl(window.location);
|
||||
|
||||
// we didn't propagate screen changes to the URL bar while we were loading; do it now.
|
||||
loaded = true;
|
||||
if (lastLoadedScreen) {
|
||||
onNewScreen(lastLoadedScreen);
|
||||
lastLoadedScreen = null;
|
||||
}
|
||||
}
|
||||
else {
|
||||
console.error("Browser is missing required features.");
|
||||
|
@ -285,7 +271,6 @@ async function loadApp() {
|
|||
validBrowser = true;
|
||||
console.log("User accepts the compatibility risks.");
|
||||
loadApp();
|
||||
window.onload(); // still do the same code paths for compatible clients
|
||||
}} />,
|
||||
document.getElementById('matrixchat')
|
||||
);
|
||||
|
|
|
@ -35,6 +35,27 @@ function onUpdateDownloaded(ev, releaseNotes, ver, date, updateURL) {
|
|||
});
|
||||
}
|
||||
|
||||
function platformFriendlyName() {
|
||||
console.log(window.process);
|
||||
switch (window.process.platform) {
|
||||
case 'darwin':
|
||||
return 'macOS';
|
||||
case 'freebsd':
|
||||
return 'FreeBSD';
|
||||
case 'openbsd':
|
||||
return 'OpenBSD';
|
||||
case 'sunos':
|
||||
return 'SunOS';
|
||||
case 'win32':
|
||||
return 'Windows';
|
||||
default:
|
||||
// Sorry, Linux users: you get lumped into here,
|
||||
// but only because Linux's capitalisation is
|
||||
// normal. We do care about you.
|
||||
return window.process.platform[0].toUpperCase + window.process.platform.slice(1);
|
||||
}
|
||||
}
|
||||
|
||||
export default class ElectronPlatform extends VectorBasePlatform {
|
||||
setNotificationCount(count: number) {
|
||||
super.setNotificationCount(count);
|
||||
|
@ -101,4 +122,8 @@ export default class ElectronPlatform extends VectorBasePlatform {
|
|||
// it should exit.
|
||||
electron.ipcRenderer.send('install_update');
|
||||
}
|
||||
|
||||
getDefaultDeviceDisplayName() {
|
||||
return "Riot Desktop on " + platformFriendlyName();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,4 +39,12 @@ export default class VectorBasePlatform extends BasePlatform {
|
|||
*/
|
||||
installUpdate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a sensible default display name for the
|
||||
* device Vector is running on
|
||||
*/
|
||||
getDefaultDeviceDisplayName() {
|
||||
return "Unknown device";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,6 +23,9 @@ import request from 'browser-request';
|
|||
import dis from 'matrix-react-sdk/lib/dispatcher.js';
|
||||
import q from 'q';
|
||||
|
||||
import url from 'url';
|
||||
import UAParser from 'ua-parser-js';
|
||||
|
||||
export default class WebPlatform extends VectorBasePlatform {
|
||||
constructor() {
|
||||
super();
|
||||
|
@ -128,8 +131,18 @@ export default class WebPlatform extends VectorBasePlatform {
|
|||
|
||||
_getVersion() {
|
||||
const deferred = q.defer();
|
||||
|
||||
// We add a cachebuster to the request to make sure that we know about
|
||||
// the most recent version on the origin server. That might not
|
||||
// actually be the version we'd get on a reload (particularly in the
|
||||
// presence of intermediate caching proxies), but still: we're trying
|
||||
// to tell the user that there is a new version.
|
||||
request(
|
||||
{ method: "GET", url: "version" },
|
||||
{
|
||||
method: "GET",
|
||||
url: "version",
|
||||
qs: { cachebuster: Date.now() },
|
||||
},
|
||||
(err, response, body) => {
|
||||
if (err || response.status < 200 || response.status >= 300) {
|
||||
if (err == null) err = { status: response.status };
|
||||
|
@ -170,4 +183,16 @@ export default class WebPlatform extends VectorBasePlatform {
|
|||
installUpdate() {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
getDefaultDeviceDisplayName() {
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue