Merge branch 'develop' into matthew/scalar
This commit is contained in:
commit
4dfb0e9a90
|
@ -7,3 +7,4 @@
|
||||||
/packages/
|
/packages/
|
||||||
/vector/bundle.*
|
/vector/bundle.*
|
||||||
/vector/components.css
|
/vector/components.css
|
||||||
|
/vector/config.json
|
||||||
|
|
76
README.md
76
README.md
|
@ -3,8 +3,23 @@ Vector/Web
|
||||||
|
|
||||||
Vector is a Matrix web client built using the Matrix React SDK (https://github.com/matrix-org/matrix-react-sdk).
|
Vector is a Matrix web client built using the Matrix React SDK (https://github.com/matrix-org/matrix-react-sdk).
|
||||||
|
|
||||||
Getting started
|
Getting Started
|
||||||
===============
|
===============
|
||||||
|
Vector is a modular webapp built with modern ES6 and requires and npm build system to build.
|
||||||
|
Instructions for building are below, but building from source shouldn't be necessary
|
||||||
|
for simple deployments.
|
||||||
|
|
||||||
|
1. Download the latest version from https://vector.im/packages/
|
||||||
|
1. Untar the tarball on your web server
|
||||||
|
1. Move (or symlink) the vector-x.x.x directory to an appropriate name
|
||||||
|
1. If desired, copy `config.sample.json` to `config.json` and edit it
|
||||||
|
as desired. See below for details.
|
||||||
|
1. Enter the URL into your browser and log into vector!
|
||||||
|
|
||||||
|
Building From Source
|
||||||
|
====================
|
||||||
|
|
||||||
|
If you do wish to build vector from source:
|
||||||
|
|
||||||
1. Install or update `node.js` so that your `npm` is at least at version `2.0.0`
|
1. Install or update `node.js` so that your `npm` is at least at version `2.0.0`
|
||||||
1. Clone the repo: `git clone https://github.com/vector-im/vector-web.git`
|
1. Clone the repo: `git clone https://github.com/vector-im/vector-web.git`
|
||||||
|
@ -13,19 +28,23 @@ Getting started
|
||||||
1. If you are using the `develop` branch of vector, you will probably need to
|
1. If you are using the `develop` branch of vector, you will probably need to
|
||||||
rebuild one of the dependencies, due to https://github.com/npm/npm/issues/3055:
|
rebuild one of the dependencies, due to https://github.com/npm/npm/issues/3055:
|
||||||
`(cd node_modules/matrix-react-sdk && npm install)`
|
`(cd node_modules/matrix-react-sdk && npm install)`
|
||||||
1. Start the development builder and a testing server: `npm start`
|
1. Configure the app by copying `config.sample.json` to `config.json` and modifying
|
||||||
1. Wait a few seconds for the initial build to finish (the command won't
|
it (see below for details)
|
||||||
terminate: it's running a web server for you).
|
1. `npm run package` to build a tarball to deploy. Untaring this file will give
|
||||||
1. Open http://127.0.0.1:8080/ in your browser to see your newly built Vector.
|
a version-specific directory containing all the files that need to go on your
|
||||||
|
web server.
|
||||||
|
|
||||||
With `npm start`, any changes you make to the source files will cause a rebuild so
|
Note that `npm run package` is not supported on Windows, so Windows users can run `npm
|
||||||
your changes will show up when you refresh. This development server also disables
|
run build`, which will build all the necessary files into the `vector`
|
||||||
caching, so do NOT use it in production.
|
directory. The version of Vector will not appear in Settings without
|
||||||
|
using the package script. You can then mount the vector directory on your
|
||||||
|
webserver to actually serve up the app, which is entirely static content.
|
||||||
|
|
||||||
Configuring
|
config.json
|
||||||
===========
|
===========
|
||||||
|
|
||||||
Configure the app by modifying the `config.json` file:
|
You can configure the app by copying `vector/config.sample.json` to
|
||||||
|
`vector/config.json` and customising it:
|
||||||
|
|
||||||
1. `default_hs_url` is the default home server url.
|
1. `default_hs_url` is the default home server url.
|
||||||
1. `default_is_url` is the default identity server url (this is the server used
|
1. `default_is_url` is the default identity server url (this is the server used
|
||||||
|
@ -33,31 +52,13 @@ Configure the app by modifying the `config.json` file:
|
||||||
registering with an email address or adding an email address to your account
|
registering with an email address or adding an email address to your account
|
||||||
will not work.
|
will not work.
|
||||||
|
|
||||||
You will need to re-run `npm run build` after editing `config.json`.
|
|
||||||
|
|
||||||
Deployment
|
|
||||||
==========
|
|
||||||
|
|
||||||
On a Unix-based OS, run `npm run package` to build a tarball package. Untaring
|
|
||||||
this file will give a version-specific directory containing all the files that
|
|
||||||
need to go on your web server.
|
|
||||||
|
|
||||||
The package script is not supported on Windows, so Windows users can run `npm
|
|
||||||
run build`, which will build all the necessary files into the `vector`
|
|
||||||
directory. Note that the version of Vector will not appear in Settings without
|
|
||||||
using the package script. You can then mount the vector directory on your
|
|
||||||
webserver to actually serve up the app, which is entirely static content.
|
|
||||||
|
|
||||||
Development
|
Development
|
||||||
===========
|
===========
|
||||||
|
|
||||||
For simple tweaks, you can work on any of the source files within Vector with
|
Much of the functionality in Vector is actually in the `matrix-react-sdk` and
|
||||||
the setup above, and your changes will cause an instant rebuild.
|
`matrix-js-sdk` modules. It is possible to set these up in a way that makes it
|
||||||
|
easy to track the `develop` branches in git and to make local changes without
|
||||||
However, much of the functionality in Vector is actually in the
|
having to manually rebuild each time.
|
||||||
`matrix-react-sdk` and `matrix-js-sdk` modules. It is possible to set these up
|
|
||||||
in a way that makes it easy to track the `develop` branches in git and to make
|
|
||||||
local changes without having to manually rebuild each time.
|
|
||||||
|
|
||||||
[Be aware that there may be problems with this process under npm version 3.]
|
[Be aware that there may be problems with this process under npm version 3.]
|
||||||
|
|
||||||
|
@ -102,13 +103,14 @@ Finally, build and start vector itself:
|
||||||
+ 1013 hidden modules
|
+ 1013 hidden modules
|
||||||
```
|
```
|
||||||
Remember, the command will not terminate since it runs the web server
|
Remember, the command will not terminate since it runs the web server
|
||||||
and rebuilds source files when they change.
|
and rebuilds source files when they change. This development server also
|
||||||
|
disables caching, so do NOT use it in production.
|
||||||
1. Open http://127.0.0.1:8080/ in your browser to see your newly built Vector.
|
1. Open http://127.0.0.1:8080/ in your browser to see your newly built Vector.
|
||||||
|
|
||||||
When you make changes to `matrix-js-sdk` or `matrix-react-sdk`, you will need
|
When you make changes to `matrix-react-sdk`, you will need to run `npm run
|
||||||
to run `npm run build` in the relevant directory. You can do this automatically
|
build` in the relevant directory. You can do this automatically by instead
|
||||||
by instead running `npm start` in each directory, to start a development
|
running `npm start` in the directory, to start a development builder which
|
||||||
builder which will watch for changes to the files and rebuild automatically.
|
will watch for changes to the files and rebuild automatically.
|
||||||
|
|
||||||
If you add or remove any components from the Vector skin, you will need to rebuild
|
If you add or remove any components from the Vector skin, you will need to rebuild
|
||||||
the skin's index by running, `npm run reskindex`.
|
the skin's index by running, `npm run reskindex`.
|
||||||
|
|
|
@ -27,6 +27,7 @@ module.exports = function (config) {
|
||||||
|
|
||||||
// list of files / patterns to load in the browser
|
// list of files / patterns to load in the browser
|
||||||
files: [
|
files: [
|
||||||
|
'node_modules/babel-polyfill/browser.js',
|
||||||
testFile,
|
testFile,
|
||||||
{pattern: 'vector/img/*', watched: false, included: false, served: true, nocache: false},
|
{pattern: 'vector/img/*', watched: false, included: false, served: true, nocache: false},
|
||||||
],
|
],
|
||||||
|
@ -130,6 +131,11 @@ module.exports = function (config) {
|
||||||
path.resolve('./test'),
|
path.resolve('./test'),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
plugins: [
|
||||||
|
// olm may not be installed, so avoid webpack warnings by
|
||||||
|
// ignoring it.
|
||||||
|
new webpack.IgnorePlugin(/^olm$/),
|
||||||
|
],
|
||||||
devtool: 'inline-source-map',
|
devtool: 'inline-source-map',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
|
@ -33,7 +33,9 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"babel-polyfill": "^6.5.0",
|
"babel-polyfill": "^6.5.0",
|
||||||
|
"browser-request": "^0.3.3",
|
||||||
"classnames": "^2.1.2",
|
"classnames": "^2.1.2",
|
||||||
|
"draft-js": "^0.7.0",
|
||||||
"extract-text-webpack-plugin": "^0.9.1",
|
"extract-text-webpack-plugin": "^0.9.1",
|
||||||
"filesize": "^3.1.2",
|
"filesize": "^3.1.2",
|
||||||
"flux": "~2.0.3",
|
"flux": "~2.0.3",
|
||||||
|
@ -41,8 +43,8 @@
|
||||||
"gfm.css": "^1.1.1",
|
"gfm.css": "^1.1.1",
|
||||||
"highlight.js": "^9.0.0",
|
"highlight.js": "^9.0.0",
|
||||||
"linkifyjs": "^2.0.0-beta.4",
|
"linkifyjs": "^2.0.0-beta.4",
|
||||||
"matrix-js-sdk": "^0.5.4",
|
"matrix-js-sdk": "matrix-org/matrix-js-sdk#develop",
|
||||||
"matrix-react-sdk": "^0.6.3",
|
"matrix-react-sdk": "matrix-org/matrix-react-sdk#develop",
|
||||||
"modernizr": "^3.1.0",
|
"modernizr": "^3.1.0",
|
||||||
"q": "^1.4.1",
|
"q": "^1.4.1",
|
||||||
"react": "^15.0.1",
|
"react": "^15.0.1",
|
||||||
|
|
|
@ -81,18 +81,20 @@ module.exports = React.createClass({
|
||||||
// });
|
// });
|
||||||
},
|
},
|
||||||
|
|
||||||
showRoom: function(roomId) {
|
showRoom: function(roomId, roomAlias) {
|
||||||
// extract the metadata from the publicRooms structure to pass
|
// extract the metadata from the publicRooms structure to pass
|
||||||
// as out-of-band data to view_room, because we get information
|
// as out-of-band data to view_room, because we get information
|
||||||
// here that we can't get other than by joining the room in some
|
// here that we can't get other than by joining the room in some
|
||||||
// cases.
|
// cases.
|
||||||
var room;
|
var room;
|
||||||
|
if (roomId) {
|
||||||
for (var i = 0; i < this.state.publicRooms.length; ++i) {
|
for (var i = 0; i < this.state.publicRooms.length; ++i) {
|
||||||
if (this.state.publicRooms[i].room_id == roomId) {
|
if (this.state.publicRooms[i].room_id == roomId) {
|
||||||
room = this.state.publicRooms[i];
|
room = this.state.publicRooms[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
var oob_data = {};
|
var oob_data = {};
|
||||||
if (room) {
|
if (room) {
|
||||||
if (MatrixClientPeg.get().isGuest()) {
|
if (MatrixClientPeg.get().isGuest()) {
|
||||||
|
@ -114,11 +116,20 @@ module.exports = React.createClass({
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
dis.dispatch({
|
var payload = {
|
||||||
action: 'view_room',
|
|
||||||
room_id: roomId,
|
|
||||||
oob_data: oob_data,
|
oob_data: oob_data,
|
||||||
});
|
action: 'view_room',
|
||||||
|
};
|
||||||
|
// It's not really possible to join Matrix rooms by ID because the HS has no way to know
|
||||||
|
// which servers to start querying. However, there's no other way to join rooms in
|
||||||
|
// this list without aliases at present, so if roomAlias isn't set here we have no
|
||||||
|
// choice but to supply the ID.
|
||||||
|
if (roomAlias) {
|
||||||
|
payload.room_alias = roomAlias;
|
||||||
|
} else {
|
||||||
|
payload.room_id = roomId;
|
||||||
|
}
|
||||||
|
dis.dispatch(payload);
|
||||||
},
|
},
|
||||||
|
|
||||||
getRows: function(filter) {
|
getRows: function(filter) {
|
||||||
|
@ -164,7 +175,7 @@ module.exports = React.createClass({
|
||||||
topic = linkifyString(sanitizeHtml(topic));
|
topic = linkifyString(sanitizeHtml(topic));
|
||||||
|
|
||||||
rows.unshift(
|
rows.unshift(
|
||||||
<tr key={ rooms[i].room_id } onClick={self.showRoom.bind(null, rooms[i].room_id)}>
|
<tr key={ rooms[i].room_id } onClick={self.showRoom.bind(null, rooms[i].room_id, alias)}>
|
||||||
<td className="mx_RoomDirectory_roomAvatar">
|
<td className="mx_RoomDirectory_roomAvatar">
|
||||||
<BaseAvatar width={24} height={24} resizeMethod='crop'
|
<BaseAvatar width={24} height={24} resizeMethod='crop'
|
||||||
name={ name } idName={ name }
|
name={ name } idName={ name }
|
||||||
|
@ -193,7 +204,7 @@ module.exports = React.createClass({
|
||||||
this.forceUpdate();
|
this.forceUpdate();
|
||||||
this.setState({ roomAlias : this.refs.roomAlias.value })
|
this.setState({ roomAlias : this.refs.roomAlias.value })
|
||||||
if (ev.key == "Enter") {
|
if (ev.key == "Enter") {
|
||||||
this.showRoom(this.refs.roomAlias.value);
|
this.showRoom(null, this.refs.roomAlias.value);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -103,7 +103,7 @@ module.exports = React.createClass({
|
||||||
className="mx_SearchBox_search"
|
className="mx_SearchBox_search"
|
||||||
value={ this.state.searchTerm }
|
value={ this.state.searchTerm }
|
||||||
onChange={ this.onChange }
|
onChange={ this.onChange }
|
||||||
placeholder="Search room names"
|
placeholder="Filter room names"
|
||||||
/>
|
/>
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ var sdk = require('matrix-react-sdk');
|
||||||
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
var MatrixClientPeg = require('matrix-react-sdk/lib/MatrixClientPeg');
|
||||||
var UserSettingsStore = require('matrix-react-sdk/lib/UserSettingsStore');
|
var UserSettingsStore = require('matrix-react-sdk/lib/UserSettingsStore');
|
||||||
var Modal = require('matrix-react-sdk/lib/Modal');
|
var Modal = require('matrix-react-sdk/lib/Modal');
|
||||||
var configJson = require("../../../../config.json");
|
|
||||||
|
|
||||||
var notifications = require('../../../notifications');
|
var notifications = require('../../../notifications');
|
||||||
|
|
||||||
|
@ -73,6 +72,8 @@ module.exports = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
// The array of threepids from the JS SDK (required for email notifications)
|
// The array of threepids from the JS SDK (required for email notifications)
|
||||||
threepids: React.PropTypes.array.isRequired,
|
threepids: React.PropTypes.array.isRequired,
|
||||||
|
// The brand string set when creating an email pusher
|
||||||
|
brand: React.PropTypes.string,
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultProps: function() {
|
getDefaultProps: function() {
|
||||||
|
@ -118,9 +119,7 @@ module.exports = React.createClass({
|
||||||
var emailPusherPromise;
|
var emailPusherPromise;
|
||||||
if (event.target.checked) {
|
if (event.target.checked) {
|
||||||
var data = {}
|
var data = {}
|
||||||
if (configJson.brand) {
|
data['brand'] = this.props.brand || 'Vector';
|
||||||
data['brand'] = configJson.brand;
|
|
||||||
}
|
|
||||||
emailPusherPromise = UserSettingsStore.addEmailPusher(address, data);
|
emailPusherPromise = UserSettingsStore.addEmailPusher(address, data);
|
||||||
} else {
|
} else {
|
||||||
var emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address);
|
var emailPusher = UserSettingsStore.getEmailPusher(this.state.pushers, address);
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
.mx_UserPill {
|
||||||
|
color: white;
|
||||||
|
background-color: #76cfa6;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_RoomPill {
|
||||||
|
background-color: white;
|
||||||
|
color: #76cfa6;
|
||||||
|
border: 1px solid #76cfa6;
|
||||||
|
padding: 2px 8px;
|
||||||
|
border-radius: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_Markdown_BOLD {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_Markdown_ITALIC {
|
||||||
|
font-style: italic;
|
||||||
|
}
|
|
@ -17,7 +17,7 @@ limitations under the License.
|
||||||
.mx_EventTile {
|
.mx_EventTile {
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
clear: both;
|
clear: both;
|
||||||
margin-top: 24px;
|
padding-top: 24px;
|
||||||
margin-left: 65px;
|
margin-left: 65px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,15 @@ limitations under the License.
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_EventTile_continuation {
|
.mx_EventTile_continuation {
|
||||||
margin-top: 8px ! important;
|
padding-top: 8px ! important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_EventTile_verified {
|
||||||
|
background-color: #eaf5f0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_EventTile_unverified {
|
||||||
|
background-color: #ffa0a0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_EventTile .mx_SenderProfile {
|
.mx_EventTile .mx_SenderProfile {
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
Copyright 2016 OpenMarket Ltd
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
.mx_MemberDeviceInfo {
|
||||||
|
font-size: 12px;
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_MemberDeviceInfo div {
|
||||||
|
display: inline;
|
||||||
|
margin-right: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_MemberDeviceInfo_textButton {
|
||||||
|
color: #fff;
|
||||||
|
height: 20px;
|
||||||
|
border-radius: 20px;
|
||||||
|
text-align: center;
|
||||||
|
padding-left: 1em;
|
||||||
|
padding-right: 1em;
|
||||||
|
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_MemberDeviceInfo_verify {
|
||||||
|
background-color: #76cfa6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_MemberDeviceInfo_unverify {
|
||||||
|
background-color: #e55e5e;
|
||||||
|
}
|
|
@ -22,15 +22,15 @@ limitations under the License.
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_MessageComposer_row {
|
.mx_MessageComposer_row {
|
||||||
display: table-row;
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_MessageComposer .mx_MessageComposer_avatar {
|
.mx_MessageComposer .mx_MessageComposer_avatar {
|
||||||
display: table-cell;
|
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
padding-right: 28px;
|
padding-right: 28px;
|
||||||
vertical-align: middle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_MessageComposer .mx_MessageComposer_avatar .mx_BaseAvatar {
|
.mx_MessageComposer .mx_MessageComposer_avatar .mx_BaseAvatar {
|
||||||
|
@ -42,9 +42,7 @@ limitations under the License.
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_MessageComposer_noperm_error {
|
.mx_MessageComposer_noperm_error {
|
||||||
display: table-cell;
|
|
||||||
width: 100%;
|
width: 100%;
|
||||||
vertical-align: middle;
|
|
||||||
height: 60px;
|
height: 60px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
|
@ -52,10 +50,22 @@ limitations under the License.
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_MessageComposer_input {
|
.mx_MessageComposer_input {
|
||||||
display: table-cell;
|
flex: 1;
|
||||||
width: 100%;
|
|
||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
height: 60px;
|
min-height: 60px;
|
||||||
|
max-height: 120px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
overflow: auto;
|
||||||
|
transition: 0.6s border-top ease;
|
||||||
|
border-top: 2px solid rgba(255, 255, 255, 0);
|
||||||
|
}
|
||||||
|
.mx_MessageComposer_input_rte {
|
||||||
|
border-top: 2px solid #76cfa6; /* placeholder RTE indicator */
|
||||||
|
}
|
||||||
|
|
||||||
|
.mx_MessageComposer_input .DraftEditor-root {
|
||||||
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.mx_MessageComposer_input textarea {
|
.mx_MessageComposer_input textarea {
|
||||||
|
@ -92,8 +102,8 @@ limitations under the License.
|
||||||
.mx_MessageComposer_hangup,
|
.mx_MessageComposer_hangup,
|
||||||
.mx_MessageComposer_voicecall,
|
.mx_MessageComposer_voicecall,
|
||||||
.mx_MessageComposer_videocall {
|
.mx_MessageComposer_videocall {
|
||||||
display: table-cell;
|
/*display: table-cell;*/
|
||||||
vertical-align: middle;
|
/*vertical-align: middle;*/
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
padding-right: 10px;
|
padding-right: 10px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
|
@ -26,6 +26,7 @@ require('../../vector/components.css');
|
||||||
require('gemini-scrollbar/gemini-scrollbar.css');
|
require('gemini-scrollbar/gemini-scrollbar.css');
|
||||||
require('gfm.css/gfm.css');
|
require('gfm.css/gfm.css');
|
||||||
require('highlight.js/styles/github.css');
|
require('highlight.js/styles/github.css');
|
||||||
|
require('draft-js/dist/Draft.css');
|
||||||
|
|
||||||
|
|
||||||
// add React and ReactPerf to the global namespace, to make them easier to
|
// add React and ReactPerf to the global namespace, to make them easier to
|
||||||
|
@ -40,8 +41,9 @@ var ReactDOM = require("react-dom");
|
||||||
var sdk = require("matrix-react-sdk");
|
var sdk = require("matrix-react-sdk");
|
||||||
sdk.loadSkin(require('../component-index'));
|
sdk.loadSkin(require('../component-index'));
|
||||||
var VectorConferenceHandler = require('../VectorConferenceHandler');
|
var VectorConferenceHandler = require('../VectorConferenceHandler');
|
||||||
var configJson = require("../../config.json");
|
|
||||||
var UpdateChecker = require("./updater");
|
var UpdateChecker = require("./updater");
|
||||||
|
var q = require('q');
|
||||||
|
var request = require('browser-request');
|
||||||
|
|
||||||
var qs = require("querystring");
|
var qs = require("querystring");
|
||||||
|
|
||||||
|
@ -111,6 +113,8 @@ function parseQs(location) {
|
||||||
// Here, we do some crude URL analysis to allow
|
// Here, we do some crude URL analysis to allow
|
||||||
// deep-linking.
|
// deep-linking.
|
||||||
function routeUrl(location) {
|
function routeUrl(location) {
|
||||||
|
if (!window.matrixChat) return;
|
||||||
|
|
||||||
console.log("Routing URL "+window.location);
|
console.log("Routing URL "+window.location);
|
||||||
var params = parseQs(location);
|
var params = parseQs(location);
|
||||||
var loginToken = params.loginToken;
|
var loginToken = params.loginToken;
|
||||||
|
@ -181,7 +185,25 @@ window.onload = function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadApp() {
|
function getConfig() {
|
||||||
|
let deferred = q.defer();
|
||||||
|
|
||||||
|
request(
|
||||||
|
{ method: "GET", url: "config.json", json: true },
|
||||||
|
(err, response, body) => {
|
||||||
|
if (err || response.status < 200 || response.status >= 300) {
|
||||||
|
deferred.reject({err: err, response: response});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
deferred.resolve(body);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return deferred.promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function loadApp() {
|
||||||
if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
|
if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
|
||||||
if (confirm("Vector runs much better as an app on iOS. Get the app?")) {
|
if (confirm("Vector runs much better as an app on iOS. Get the app?")) {
|
||||||
window.location = "https://itunes.apple.com/us/app/vector.im/id1083446067";
|
window.location = "https://itunes.apple.com/us/app/vector.im/id1083446067";
|
||||||
|
@ -189,14 +211,32 @@ function loadApp() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (/Android/.test(navigator.userAgent)) {
|
else if (/Android/.test(navigator.userAgent)) {
|
||||||
if (confirm("Vector runs much better as an app on Vector. Get the app?")) {
|
if (confirm("Vector runs much better as an app on Android. Get the app?")) {
|
||||||
window.location = "https://play.google.com/store/apps/details?id=im.vector.alpha";
|
window.location = "https://play.google.com/store/apps/details?id=im.vector.alpha";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let configJson;
|
||||||
|
let configError;
|
||||||
|
try {
|
||||||
|
configJson = await getConfig();
|
||||||
|
} catch (e) {
|
||||||
|
// On 404 errors, carry on without a config,
|
||||||
|
// but on other errors, fail, otherwise it will
|
||||||
|
// lead to subtle errors where the app runs with
|
||||||
|
// the default config if it fails to fetch config.json.
|
||||||
|
if (e.response.status != 404) {
|
||||||
|
configError = e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log("Vector starting at "+window.location);
|
console.log("Vector starting at "+window.location);
|
||||||
if (validBrowser) {
|
if (configError) {
|
||||||
|
window.matrixChat = ReactDOM.render(<div className="error">
|
||||||
|
Unable to load config file: please refresh the page to try again.
|
||||||
|
</div>, document.getElementById('matrixchat'));
|
||||||
|
} else if (validBrowser) {
|
||||||
var MatrixChat = sdk.getComponent('structures.MatrixChat');
|
var MatrixChat = sdk.getComponent('structures.MatrixChat');
|
||||||
var fragParts = parseQsFromFragment(window.location);
|
var fragParts = parseQsFromFragment(window.location);
|
||||||
window.matrixChat = ReactDOM.render(
|
window.matrixChat = ReactDOM.render(
|
||||||
|
|
|
@ -77,6 +77,7 @@ describe('joining a room', function () {
|
||||||
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
|
httpBackend.when('POST', '/filter').respond(200, { filter_id: 'fid' });
|
||||||
httpBackend.when('GET', '/sync').respond(200, {});
|
httpBackend.when('GET', '/sync').respond(200, {});
|
||||||
httpBackend.when('GET', '/publicRooms').respond(200, {chunk: []});
|
httpBackend.when('GET', '/publicRooms').respond(200, {chunk: []});
|
||||||
|
httpBackend.when('GET', '/directory/room/'+encodeURIComponent(ROOM_ALIAS)).respond(200, { room_id: ROOM_ID });
|
||||||
|
|
||||||
// start with a logged-in client
|
// start with a logged-in client
|
||||||
peg.replaceUsingAccessToken(HS_URL, IS_URL, USER_ID, ACCESS_TOKEN);
|
peg.replaceUsingAccessToken(HS_URL, IS_URL, USER_ID, ACCESS_TOKEN);
|
||||||
|
@ -102,7 +103,7 @@ describe('joining a room', function () {
|
||||||
|
|
||||||
// that should create a roomview which will start a peek; wait
|
// that should create a roomview which will start a peek; wait
|
||||||
// for the peek.
|
// for the peek.
|
||||||
httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ALIAS)+"/initialSync")
|
httpBackend.when('GET', '/rooms/'+encodeURIComponent(ROOM_ID)+"/initialSync")
|
||||||
.respond(401, {errcode: 'M_GUEST_ACCESS_FORBIDDEN'});
|
.respond(401, {errcode: 'M_GUEST_ACCESS_FORBIDDEN'});
|
||||||
return httpBackend.flush();
|
return httpBackend.flush();
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
|
|
Loading…
Reference in New Issue