Skip to content

Commit

Permalink
Develop rebase (#10)
Browse files Browse the repository at this point in the history
* Document how to turn off Piwik and bug reports (element-hq#6738)

* Fix reskindex on matrix-react-side not being called if using build script

* Add text saying that bug reports aren't automatic

Signed-off-by: Aaron Raimist <aaron@raim.ist>

* Fix double-closed tags

* Use HTTPS cloning for riot-web too

* Silence bluebird warnings

* Disable webpack-dev-server auto reload

As per comment

* Fix Promise.defer warnings in getconfig.js (element-hq#7409)

Signed-off-by: Aaron Raimist <aaron@raim.ist>

* Fix Promise.defer warnings in index.js (element-hq#7409)

Signed-off-by: Aaron Raimist <aaron@raim.ist>

* Fix Promise.defer warnings in WebPlatform.js (element-hq#7409)

Signed-off-by: Aaron Raimist <aaron@raim.ist>

* Fix lint warnings and turn warnings back on (element-hq#7409)

Signed-off-by: Aaron Raimist <aaron@raim.ist>

* Undo turning warnings back on (element-hq#7409)

I guess that turns on warnings for everything, not just riot-web

Signed-off-by: Aaron Raimist <aaron@raim.ist>
  • Loading branch information
Ashaman- authored Oct 9, 2018
1 parent 2bed6e1 commit 2dda0d5
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 81 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ Then similarly with `matrix-react-sdk`:

Finally, build and start Riot itself:

1. `git clone git@github.com:vector-im/riot-web.git`
1. `git clone https://github.com/vector-im/riot-web.git`
1. `cd riot-web`
1. `git checkout develop`
1. `npm install`
Expand Down
54 changes: 26 additions & 28 deletions src/vector/getconfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,33 @@ export async function getVectorConfig(relativeLocation) {
}

function getConfig(configJsonFilename) {
let deferred = Promise.defer();

request(
{ method: "GET", url: configJsonFilename },
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
// Lack of a config isn't an error, we should
// just use the defaults.
// Also treat a blank config as no config, assuming
// the status code is 0, because we don't get 404s
// from file: URIs so this is the only way we can
// not fail if the file doesn't exist when loading
// from a file:// URI.
if (response) {
if (response.status == 404 || (response.status == 0 && body == '')) {
deferred.resolve({});
return new Promise(function(resolve, reject) {
request(
{ method: "GET", url: configJsonFilename },
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
// Lack of a config isn't an error, we should
// just use the defaults.
// Also treat a blank config as no config, assuming
// the status code is 0, because we don't get 404s
// from file: URIs so this is the only way we can
// not fail if the file doesn't exist when loading
// from a file:// URI.
if (response) {
if (response.status == 404 || (response.status == 0 && body == '')) {
resolve({});
}
}
reject({err: err, response: response});
return;
}
deferred.reject({err: err, response: response});
return;
}

// We parse the JSON ourselves rather than use the JSON
// parameter, since this throws a parse error on empty
// which breaks if there's no config.json and we're
// loading from the filesystem (see above).
deferred.resolve(JSON.parse(body));
}
);

return deferred.promise;
// We parse the JSON ourselves rather than use the JSON
// parameter, since this throws a parse error on empty
// which breaks if there's no config.json and we're
// loading from the filesystem (see above).
resolve(JSON.parse(body));
},
);
});
}
58 changes: 30 additions & 28 deletions src/vector/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ import {getVectorConfig} from './getconfig';

let lastLocationHashSet = null;

// Disable warnings for now: we use deprecated bluebird functions
// and need to migrate, but they spam the console with warnings.
Promise.config({warnings: false});

function initRageshake() {
rageshake.init().then(() => {
console.log("Initialised rageshake: See https://bugs.chromium.org/p/chromium/issues/detail?id=583193 to fix line numbers on Chrome.");
Expand Down Expand Up @@ -175,37 +179,35 @@ function makeRegistrationUrl(params) {
}

function getConfig(configJsonFilename) {
let deferred = Promise.defer();

request(
{ method: "GET", url: configJsonFilename },
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
// Lack of a config isn't an error, we should
// just use the defaults.
// Also treat a blank config as no config, assuming
// the status code is 0, because we don't get 404s
// from file: URIs so this is the only way we can
// not fail if the file doesn't exist when loading
// from a file:// URI.
if (response) {
if (response.status == 404 || (response.status == 0 && body == '')) {
deferred.resolve({});
return new Promise(function(resolve, reject) {
request(
{ method: "GET", url: configJsonFilename },
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
// Lack of a config isn't an error, we should
// just use the defaults.
// Also treat a blank config as no config, assuming
// the status code is 0, because we don't get 404s
// from file: URIs so this is the only way we can
// not fail if the file doesn't exist when loading
// from a file:// URI.
if (response) {
if (response.status == 404 || (response.status == 0 && body == '')) {
resolve({});
}
}
reject({err: err, response: response});
return;
}
deferred.reject({err: err, response: response});
return;
}

// We parse the JSON ourselves rather than use the JSON
// parameter, since this throws a parse error on empty
// which breaks if there's no config.json and we're
// loading from the filesystem (see above).
deferred.resolve(JSON.parse(body));
}
);

return deferred.promise;
// We parse the JSON ourselves rather than use the JSON
// parameter, since this throws a parse error on empty
// which breaks if there's no config.json and we're
// loading from the filesystem (see above).
resolve(JSON.parse(body));
},
);
});
}

function onTokenLoginCompleted() {
Expand Down
48 changes: 24 additions & 24 deletions src/vector/platform/WebPlatform.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ export default class WebPlatform extends VectorBasePlatform {
// annoyingly, the latest spec says this returns a
// promise, but this is only supported in Chrome 46
// and Firefox 47, so adapt the callback API.
const defer = Promise.defer();
global.Notification.requestPermission((result) => {
defer.resolve(result);
return new Promise(function(resolve, reject) {
global.Notification.requestPermission((result) => {
resolve(result);
});
});
return defer.promise;
}

displayNotification(title: string, msg: string, avatarUrl: string, room: Object) {
Expand Down Expand Up @@ -103,31 +103,31 @@ export default class WebPlatform extends VectorBasePlatform {
}

_getVersion(): Promise<string> {
const deferred = Promise.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",
qs: { cachebuster: Date.now() },
},
(err, response, body) => {
if (err || response.status < 200 || response.status >= 300) {
if (err === null) err = { status: response.status };
deferred.reject(err);
return;
}

const ver = body.trim();
deferred.resolve(ver);
},
);
return deferred.promise;

return new Promise(function(resolve, reject) {
request(
{
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 };
reject(err);
return;
}

const ver = body.trim();
resolve(ver);
},
);
});
}

getAppVersion(): Promise<string> {
Expand Down
6 changes: 6 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,12 @@ module.exports = {
// don't fill the console up with a mahoosive list of modules
chunks: false,
},

// hot mdule replacement doesn't work (I think we'd need react-hot-reload?)
// so webpack-dev-server reloads the page on every update which is quite
// tedious in Riot since that can take a while.
hot: false,
inline: false,
},
};

Expand Down

0 comments on commit 2dda0d5

Please sign in to comment.