...
 
Commits (113)
Changes in [1.6.3](https://github.com/vector-im/riot-web/releases/tag/v1.6.3) (2020-06-04)
==========================================================================================
[Full Changelog](https://github.com/vector-im/riot-web/compare/v1.6.3-rc.1...v1.6.3)
## Security notice
Riot Web 1.6.3 fixes a vulnerability in single sign-on (SSO) deployments where Riot Web could be confused into sending authentication details to an attacker-controlled server. Thanks to Quentin Gliech for responsibly disclosing this via Matrix's Security Disclosure Policy.
## All changes
* Fix login loop where the sso flow returns to `#/login` to release
[\#13915](https://github.com/vector-im/riot-web/pull/13915)
Changes in [1.6.3-rc.1](https://github.com/vector-im/riot-web/releases/tag/v1.6.3-rc.1) (2020-06-02)
====================================================================================================
[Full Changelog](https://github.com/vector-im/riot-web/compare/v1.6.2...v1.6.3-rc.1)
* Upgrade to JS SDK 6.2.0-rc.1 and React SDK 2.7.0-rc.2
* Get rid of welcome.html's Chat with Riot Bot button
[\#13842](https://github.com/vector-im/riot-web/pull/13842)
* Update from Weblate
[\#13886](https://github.com/vector-im/riot-web/pull/13886)
* Allow deferring of Update Toast until the next morning
[\#13864](https://github.com/vector-im/riot-web/pull/13864)
* Give contextual feedback for manual update check instead of banner
[\#13862](https://github.com/vector-im/riot-web/pull/13862)
* Add app-load doc
[\#13834](https://github.com/vector-im/riot-web/pull/13834)
* Update Modular hosting link
[\#13777](https://github.com/vector-im/riot-web/pull/13777)
* Replace New Version Bar with a Toast
[\#13776](https://github.com/vector-im/riot-web/pull/13776)
* Remove webpack-build-notifier from lockfile
[\#13814](https://github.com/vector-im/riot-web/pull/13814)
* Add media queries and mobile viewport (#12142)
[\#13818](https://github.com/vector-im/riot-web/pull/13818)
* Fix @types/react conflict in matrix-react-sdk
[\#13809](https://github.com/vector-im/riot-web/pull/13809)
* Fix manual update checking, super in arrow funcs doesn't work
[\#13808](https://github.com/vector-im/riot-web/pull/13808)
* Update from Weblate
[\#13806](https://github.com/vector-im/riot-web/pull/13806)
* Convert platforms to Typescript
[\#13756](https://github.com/vector-im/riot-web/pull/13756)
* Fix EventEmitter typescript signature in node typings
[\#13764](https://github.com/vector-im/riot-web/pull/13764)
* Add docs and labs flag for new room list implementation
[\#13675](https://github.com/vector-im/riot-web/pull/13675)
* Add font scaling labs setting.
[\#13352](https://github.com/vector-im/riot-web/pull/13352)
* Add labs flag for alternate message layouts
[\#13350](https://github.com/vector-im/riot-web/pull/13350)
* Move dispatcher references in support of TypeScript conversion
[\#13666](https://github.com/vector-im/riot-web/pull/13666)
* Update from Weblate
[\#13704](https://github.com/vector-im/riot-web/pull/13704)
* Replace favico.js dependency with simplified variant grown from it
[\#13649](https://github.com/vector-im/riot-web/pull/13649)
* Remove Electron packaging scripts
[\#13688](https://github.com/vector-im/riot-web/pull/13688)
* Fix postcss order to allow mixin variables to work
[\#13674](https://github.com/vector-im/riot-web/pull/13674)
* Pass screenAfterLogin through SSO in the callback url
[\#13650](https://github.com/vector-im/riot-web/pull/13650)
Changes in [1.6.2](https://github.com/vector-im/riot-web/releases/tag/v1.6.2) (2020-05-22)
==========================================================================================
[Full Changelog](https://github.com/vector-im/riot-web/compare/v1.6.1...v1.6.2)
......
......@@ -26,10 +26,12 @@
"defaultCountryCode": "GB",
"showLabsSettings": false,
"features": {
"feature_font_scaling": "labs",
"feature_pinning": "labs",
"feature_custom_status": "labs",
"feature_custom_tags": "labs",
"feature_state_counters": "labs"
"feature_state_counters": "labs",
"feature_irc_ui": "labs"
},
"default_federate": true,
"default_theme": "light",
......
# App load order
Old slow flow:
![image](https://user-images.githubusercontent.com/2403652/73848963-00a2a080-4821-11ea-97d4-1200fc2638f3.png)
Current more parallel flow:
![image](https://user-images.githubusercontent.com/2403652/83146440-303a2900-a0ee-11ea-806b-4f53f039b957.png)
<details><summary>Code</summary>
<p>
<pre><code>
digraph G {
node [shape=box];
subgraph cluster_0 {
color=orange;
node [style=filled];
label = "index.ts";
entrypoint, s0, ready [shape=point];
rageshake, config, i18n, theme, skin, olm [shape=parallelogram];
mobile [shape=diamond, label="mobile"];
modernizr [shape=diamond];
redirect, incompatible [shape=egg];
entrypoint -> rageshake;
rageshake -> mobile [color=blue];
mobile -> s0 [label="No"];
mobile -> redirect [label="Yes"];
s0 -> platform;
s0 -> olm;
platform -> config;
config -> i18n [color=blue];
config -> theme [color=blue];
config -> skin [color=blue];
i18n -> modernizr [color=blue];
theme -> modernizr [color=blue];
skin -> modernizr [color=blue];
modernizr -> ready [label="Yes"];
modernizr -> incompatible [label="No"];
incompatible -> ready [label="user ignore"];
olm -> ready [color=red];
config -> ready [color=red];
skin -> ready [color=red];
theme -> ready [color=red];
i18n -> ready [color=red];
}
subgraph cluster_1 {
color = green;
node [style=filled];
label = "init.tsx";
ready -> loadApp;
loadApp -> matrixchat;
}
}
</code></pre>
</p>
</details>
Key:
+ Parallelogram: async/await task
+ Box: sync task
+ Diamond: conditional branch
+ Egg: user interaction
+ Blue arrow: async task is allowed to settle but allowed to fail
+ Red arrow: async task success is asserted
Notes:
+ A task begins when all its dependencies (arrows going into it) are fulfilled.
+ The success of setting up rageshake is never asserted, riot-web has a fallback path for running without IDB (and thus rageshake).
+ Everything is awaited to be settled before the Modernizr check, to allow it to make use of things like i18n if they are successful.
Underlying dependencies:
![image](https://user-images.githubusercontent.com/2403652/73848977-08624500-4821-11ea-9830-bb0317c41086.png)
......@@ -7,6 +7,11 @@ to `Settings->Labs`. This list is non-exhaustive and subject to change, chat in
**Be warned! Labs features are not finalised, they may be fragile, they may change, they may be
dropped. Ask in the room if you are unclear about any details here.**
## Font scaling (`feature_font_scaling`)
Enables font scaling options for accessibility. To alter the scale check the
appearance tab in settings.
## Message pinning (`feature_pinning`)
Allows you to pin messages in the room. To pin a message, use the 3 dots to the right of the message
......@@ -106,3 +111,15 @@ adds an ability for end users to add themes themselves by using a URL to the JSO
theme definition.
For some sample themes, check out [aaronraimist/riot-web-themes](https://github.com/aaronraimist/riot-web-themes).
## New room list (`feature_new_room_list`) (in development)
A complete rewrite of the room list is underway to increase performance, stability,
and general usability. This is expected to take a while to complete and as such might
be missing critical features - please use at your own risk, though do report bugs!
## IRC message layout (`feature_irc_ui`)
Adds an option to change the message layout to an IRC style ` timestamp | avatar
| name | message `
{
"name": "riot-web",
"productName": "Riot",
"version": "1.6.2",
"version": "1.6.3",
"description": "A feature-rich client for Matrix.org",
"author": "New Vector Ltd.",
"repository": {
......@@ -58,11 +58,10 @@
},
"dependencies": {
"browser-request": "^0.3.3",
"favico.js": "^0.3.10",
"gfm.css": "^1.1.2",
"highlight.js": "^9.13.1",
"matrix-js-sdk": "6.1.0",
"matrix-react-sdk": "2.6.1",
"matrix-js-sdk": "6.2.0",
"matrix-react-sdk": "2.7.0",
"olm": "https://packages.matrix.org/npm/olm/olm-3.1.4.tgz",
"postcss-easings": "^2.0.0",
"prop-types": "^15.7.2",
......@@ -89,7 +88,9 @@
"@babel/preset-typescript": "^7.7.4",
"@babel/register": "^7.7.4",
"@babel/runtime": "^7.7.6",
"@types/flux": "^3.1.9",
"@types/modernizr": "^3.5.3",
"@types/node": "^12.12.41",
"@types/react": "16.9",
"@types/react-dom": "^16.9.4",
"autoprefixer": "^9.7.3",
......
......@@ -96,19 +96,10 @@ h1::after {
color: #2e2f32 !important;
}
.mx_ButtonHeadline {
margin-bottom: 14px;
}
.mx_ButtonLabel {
margin-left: 20px;
}
.mx_ButtonWrapperText {
font-size: 13px;
margin-bottom: 10px;
}
.mx_Header_title {
font-size: 24px;
font-weight: 600;
......@@ -158,6 +149,23 @@ we don't have an account and should hide them. No account == no guest account ei
display: none;
}
.mx_ButtonRow.mx_WelcomePage_guestFunctions {
margin-top: 20px;
}
.mx_ButtonRow.mx_WelcomePage_guestFunctions > div {
margin: 0 auto;
}
@media only screen and (max-width: 480px) {
.mx_ButtonRow {
flex-direction: column;
}
.mx_ButtonRow > * {
margin: 0 0 10px 0;
}
}
</style>
<div class="mx_Parent">
......@@ -182,15 +190,8 @@ we don't have an account and should hide them. No account == no guest account ei
<!-- BEGIN Ansible: Remove these lines when guest access is disabled -->
<div class="mx_ButtonRow mx_WelcomePage_guestFunctions">
<div>
<div class="mx_ButtonWrapperText">_t("Need help?")</div>
<a href="#/user/@riot-bot:matrix.org?action=chat" class="mx_ButtonParent mx_SecondaryButton mx_Button_iconHelp">
<div class="mx_ButtonLabel">_t("Chat with Riot Bot")</div>
</a>
</div>
<div>
<div class="mx_ButtonWrapperText">_t("Explore rooms")</div>
<a href="#/directory" class="mx_ButtonParent mx_SecondaryButton mx_Button_iconRoomDirectory">
<div class="mx_ButtonLabel">_t("Room Directory")</div>
<div class="mx_ButtonLabel">_t("Explore rooms")</div>
</a>
</div>
</div>
......
......@@ -10,7 +10,7 @@
"https://scalar-staging.vector.im/api",
"https://scalar-staging.riot.im/scalar/api"
],
"hosting_signup_link": "https://modular.im/?utm_source=riot-web&utm_medium=web",
"hosting_signup_link": "https://modular.im/services/matrix-hosting-riot?utm_source=riot-web&utm_medium=web",
"bug_report_endpoint_url": "https://riot.im/bugreports/submit",
"features": {
},
......
......@@ -10,9 +10,10 @@
"https://scalar-staging.vector.im/api",
"https://scalar-staging.riot.im/scalar/api"
],
"hosting_signup_link": "https://modular.im/?utm_source=riot-web&utm_medium=web",
"hosting_signup_link": "https://modular.im/services/matrix-hosting-riot?utm_source=riot-web&utm_medium=web",
"bug_report_endpoint_url": "https://riot.im/bugreports/submit",
"features": {
"feature_font_scaling": "labs",
"feature_pinning": "labs",
"feature_custom_status": "labs",
"feature_custom_tags": "labs",
......@@ -22,7 +23,9 @@
"feature_dm_verification": "labs",
"feature_bridge_state": "labs",
"feature_presence_in_room_list": "labs",
"feature_custom_themes": "labs"
"feature_custom_themes": "labs",
"feature_new_room_list": "labs",
"feature_irc_ui": "labs"
},
"piwik": {
"url": "https://piwik.riot.im/",
......
#!/bin/bash
usage() {
echo "Usage: $0 -v <version> -d <config directory> [-n]"
echo
echo "version: commit-ish to check out and build"
echo "config directory: a path to a directory containing"
echo "config.json, a json config file to ship with the build"
echo "and env.sh, a file to source environment variables"
echo "from."
echo "-n: build with no config file."
echo
echo "The update_base_url value from config.json is used to set up auto-update."
echo
echo "Environment variables:"
echo " OSSLSIGNCODE_SIGNARGS: Arguments to pass to osslsigncode when signing"
echo " NOTARIZE_APPLE_ID: Apple ID to use for notarisation. The password for"
echo " this account must be set in NOTARIZE_CREDS in the keychain."
}
confdir=
version=
skipcfg=0
while getopts "d:v:n" opt; do
case $opt in
d)
confdir=$OPTARG
;;
v)
version=$OPTARG
;;
n)
skipcfg=1
;;
\?)
echo "Invalid option: -$OPTARG" >&2
usage
exit
;;
esac
done
if [ -z "$version" ]; then
echo "No version supplied"
usage
exit
fi
conffile="$confdir/config.json"
if [ -z "$conffile" ] && [ "$skipcfg" = 0 ]; then
echo "No config file given. Use -c to supply a config file or"
echo "-n to build with no config file (and no auto update)."
exit
fi
if [ -n "$conffile" ]; then
update_base_url=`jq -r .update_base_url $conffile`
if [ -z "$update_base_url" ]; then
echo "No update URL supplied. Use update_base_url: null if you really"
echo "want a build with no auto-update."
usage
exit
fi
# Make sure the base URL ends in a slash if it doesn't already
update_base_url=`echo $update_base_url | sed -e 's#\([^\/]\)$#\1\/#'`
fi
if [ ! -f package.json ]; then
echo "No package.json found. This script must be run from"
echo "the riot-web directory."
exit
fi
[ -f "$confdir/env.sh" ] && . "$confdir/env.sh"
if [ -z "$NOTARIZE_APPLE_ID" ]; then
echo "NOTARIZE_APPLE_ID is not set"
exit
fi
osslsigncode -h 2> /dev/null
if [ $? -ne 255 ]; then # osslsigncode exits with 255 after printing usage...
echo "osslsigncode not found"
exit
fi
# Test that altool can get its credentials for notarising the mac app
xcrun altool -u "$NOTARIZE_APPLE_ID" -p '@keychain:NOTARIZE_CREDS' --list-apps || exit
# Get the token password: we'll need it later, but get it now so we fail early if it's not there
token_password=`security find-generic-password -s riot_signing_token -w`
if [ $? -ne 0 ]; then
echo "riot_signing_token not found in keychain"
exit
fi
set -e
echo "Building $version using Update base URL $update_base_url"
projdir=`pwd`
builddir=`mktemp -d 2>/dev/null || mktemp -d -t 'buildtmp'`
pushd "$builddir"
git clone "$projdir" .
git checkout "$version"
# Figure out what version we're building
vername=`jq -r .version package.json`
if [ -n "$conffile" ]; then
popd
cp "$conffile" "$builddir/"
pushd "$builddir"
fi
# We use Git branch / commit dependencies for some packages, and Yarn seems
# to have a hard time getting that right. See also
# https://github.com/yarnpkg/yarn/issues/4734. As a workaround, we clean the
# global cache here to ensure we get the right thing.
yarn cache clean
yarn install
yarn build:electron
popd
distdir="$builddir/electron_app/dist"
pubdir="$projdir/electron_app/pub"
rm -r "$pubdir" || true
mkdir -p "$pubdir"
rm -r "$projdir/electron_app/dist" || true
mkdir -p "$projdir/electron_app/dist"
# Install packages: what the user downloads the first time,
# (DMGs for mac, exe installer for windows)
mkdir -p "$pubdir/install/macos"
cp $distdir/*.dmg "$pubdir/install/macos/"
mkdir -p "$pubdir/install/win32/ia32/"
cp $distdir/squirrel-windows-ia32/*.exe "$pubdir/install/win32/ia32/"
mkdir -p "$pubdir/install/win32/x64/"
cp $distdir/squirrel-windows/*.exe "$pubdir/install/win32/x64/"
# Packages for auto-update
mkdir -p "$pubdir/update/macos"
cp $distdir/*-mac.zip "$pubdir/update/macos/"
echo "$vername" > "$pubdir/update/macos/latest"
mkdir -p "$pubdir/update/win32/ia32/"
cp $distdir/squirrel-windows-ia32/*.nupkg "$pubdir/update/win32/ia32/"
cp $distdir/squirrel-windows-ia32/RELEASES "$pubdir/update/win32/ia32/"
mkdir -p "$pubdir/update/win32/x64/"
cp $distdir/squirrel-windows/*.nupkg "$pubdir/update/win32/x64/"
cp $distdir/squirrel-windows/RELEASES "$pubdir/update/win32/x64/"
# Move the deb to the main project dir's dist folder
# (just the 64 bit one - the 32 bit one still gets built because
# it's one arch argument for all platforms and we still want 32 bit
# windows, but 32 bit linux is unsupported as of electron 4 and no
# longer appears to work).
cp $distdir/*_amd64.deb "$projdir/electron_app/dist/"
rm -rf "$builddir"
echo "$pubdir can now be hosted on your web server."
echo "deb archives are in electron_app/dist/ - these should be added into your debian repository"
const { notarize } = require('electron-notarize');
exports.default = async function(context) {
const { electronPlatformName, appOutDir } = context;
if (electronPlatformName === 'darwin') {
const appName = context.packager.appInfo.productFilename;
// We get the password from keychain. The keychain stores
// user IDs too, but apparently altool can't get the user ID
// from the keychain, so we need to get it from the environment.
const userId = process.env.NOTARIZE_APPLE_ID;
if (userId === undefined) {
console.warn(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +
"! Skipping macOS notarisation. !\n" +
"! User ID not found, set NOTARIZE_APPLE_ID. !\n" +
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
);
return;
}
console.log("Notarising macOS app. This may be some time.");
return await notarize({
appBundleId: 'im.riot.app',
appPath: `${appOutDir}/${appName}.app`,
appleId: userId,
appleIdPassword: '@keychain:NOTARIZE_CREDS',
});
}
};
const { exec, execFile } = require('child_process');
const fs = require('fs');
const path = require('path');
const shellescape = require('shell-escape');
exports.default = async function(options) {
const inPath = options.path;
const appOutDir = path.dirname(inPath);
// get the token passphrase from the keychain
let tokenPassphrase;
try {
tokenPassphrase = await new Promise((resolve, reject) => {
execFile(
'security',
['find-generic-password', '-s', 'riot_signing_token', '-w'],
{},
(err, stdout) => {
if (err) {
reject(err);
} else {
resolve(stdout.trim());
}
},
);
});
} catch (err) {
console.warn(
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n" +
"! Skipping Windows signing. !\n" +
"! Signing token not found in keychain. !\n" +
"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!",
);
return;
}
return new Promise((resolve, reject) => {
let cmdLine = 'osslsigncode sign ';
if (process.env.OSSLSIGNCODE_SIGNARGS) {
cmdLine += process.env.OSSLSIGNCODE_SIGNARGS + ' ';
}
const tmpFile = path.join(
appOutDir,
'tmp_' + Math.random().toString(36).substring(2, 15) + '.exe',
);
const args = [
'-h', options.hash,
'-pass', tokenPassphrase,
'-in', inPath,
'-out', tmpFile,
];
if (options.isNest) args.push('-nest');
cmdLine += shellescape(args);
let signStdout;
const signproc = exec(cmdLine, {}, (error, stdout) => {
signStdout = stdout;
});
signproc.on('exit', (code) => {
if (code !== 0) {
console.log("Running", cmdLine);
console.log(signStdout);
console.error("osslsigncode failed with code " + code);
reject("osslsigncode failed with code " + code);
return;
}
fs.rename(tmpFile, inPath, (err) => {
if (err) {
console.error("Error renaming file", err);
reject(err);
} else {
resolve();
}
});
});
});
};
......@@ -24,5 +24,18 @@ declare global {
// electron-only
ipcRenderer: any;
// opera-only
opera: any;
// https://developer.mozilla.org/en-US/docs/Web/API/InstallTrigger
InstallTrigger: any;
}
}
// add method which is missing from the node typing
declare module "url" {
interface Url {
format(): string;
}
}
/*
Copyright 2020 New Vector 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.
*/
interface IParams {
// colour parameters
bgColor: string;
textColor: string;
// font styling parameters
fontFamily: string;
fontWeight: "normal" | "italic" | "bold" | "bolder" | "lighter" | number;
// positioning parameters
isUp: boolean;
isLeft: boolean;
}
const defaults: IParams = {
bgColor: "#d00",
textColor: "#fff",
fontFamily: "sans-serif", // Arial,Verdana,Times New Roman,serif,sans-serif,...
fontWeight: "bold", // normal,italic,oblique,bold,bolder,lighter,100,200,300,400,500,600,700,800,900
isUp: false,
isLeft: false,
};
// Allows dynamic rendering of a circular badge atop the loaded favicon
// supports colour, font and basic positioning parameters.
// Based upon https://github.com/ejci/favico.js/blob/master/favico.js [MIT license]
export default class Favicon {
private readonly browser = {
ff: typeof window.InstallTrigger !== "undefined",
opera: !!window.opera || navigator.userAgent.includes("Opera"),
};
private readonly params: IParams;
private readonly canvas: HTMLCanvasElement;
private readonly baseImage: HTMLImageElement;
private context: CanvasRenderingContext2D;
private icons: HTMLLinkElement[];
private isReady: boolean = false;
// callback to run once isReady is asserted, allows for a badge to be queued for when it can be shown
private readyCb = () => {};
constructor(params: Partial<IParams> = {}) {
this.params = {...defaults, ...params};
this.icons = Favicon.getIcons();
// create work canvas
this.canvas = document.createElement("canvas");
// create clone of favicon as a base
this.baseImage = document.createElement("img");
const lastIcon = this.icons[this.icons.length - 1];
if (lastIcon.hasAttribute("href")) {
this.baseImage.setAttribute("crossOrigin", "anonymous");
this.baseImage.onload = () => {
// get height and width of the favicon
this.canvas.height = (this.baseImage.height > 0) ? this.baseImage.height : 32;
this.canvas.width = (this.baseImage.width > 0) ? this.baseImage.width : 32;
this.context = this.canvas.getContext("2d");
this.ready();
};
this.baseImage.setAttribute("src", lastIcon.getAttribute("href"));
} else {
this.canvas.height = this.baseImage.height = 32;
this.canvas.width = this.baseImage.width = 32;
this.context = this.canvas.getContext("2d");
this.ready();
}
}
private reset() {
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
this.context.drawImage(this.baseImage, 0, 0, this.canvas.width, this.canvas.height);
}
private options(n: number | string, params: IParams) {
const opt = {
n: ((typeof n) === "number") ? Math.abs(n as number | 0) : n,
len: ("" + n).length,
// badge positioning constants as percentages
x: 0.4,
y: 0.4,
w: 0.6,
h: 0.6,
};
// apply positional transformations
if (params.isUp) {
if (opt.y < 0.6) {
opt.y = opt.y - 0.4;
} else {
opt.y = opt.y - 2 * opt.y + (1 - opt.w);
}
}
if (params.isLeft) {
if (opt.x < 0.6) {
opt.x = opt.x - 0.4;
} else {
opt.x = opt.x - 2 * opt.x + (1 - opt.h);
}
}
// scale the position to the canvas
opt.x = this.canvas.width * opt.x;
opt.y = this.canvas.height * opt.y;
opt.w = this.canvas.width * opt.w;
opt.h = this.canvas.height * opt.h;
return opt;
}
private circle(n: number | string, opts?: Partial<IParams>) {
const params = {...this.params, ...opts};
const opt = this.options(n, params);
let more = false;
if (opt.len === 2) {
opt.x = opt.x - opt.w * 0.4;
opt.w = opt.w * 1.4;
more = true;
} else if (opt.len >= 3) {
opt.x = opt.x - opt.w * 0.65;
opt.w = opt.w * 1.65;
more = true;
}
this.context.clearRect(0, 0, this.canvas.width, this.canvas.height);
this.context.drawImage(this.baseImage, 0, 0, this.canvas.width, this.canvas.height);
this.context.beginPath();
const fontSize = Math.floor(opt.h * (opt.n > 99 ? 0.85 : 1)) + "px";
this.context.font = `${params.fontWeight} ${fontSize} ${params.fontFamily}`;
this.context.textAlign = "center";
if (more) {
this.context.moveTo(opt.x + opt.w / 2, opt.y);
this.context.lineTo(opt.x + opt.w - opt.h / 2, opt.y);
this.context.quadraticCurveTo(opt.x + opt.w, opt.y, opt.x + opt.w, opt.y + opt.h / 2);
this.context.lineTo(opt.x + opt.w, opt.y + opt.h - opt.h / 2);
this.context.quadraticCurveTo(opt.x + opt.w, opt.y + opt.h, opt.x + opt.w - opt.h / 2, opt.y + opt.h);
this.context.lineTo(opt.x + opt.h / 2, opt.y + opt.h);
this.context.quadraticCurveTo(opt.x, opt.y + opt.h, opt.x, opt.y + opt.h - opt.h / 2);
this.context.lineTo(opt.x, opt.y + opt.h / 2);
this.context.quadraticCurveTo(opt.x, opt.y, opt.x + opt.h / 2, opt.y);
} else {
this.context.arc(opt.x + opt.w / 2, opt.y + opt.h / 2, opt.h / 2, 0, 2 * Math.PI);
}
this.context.fillStyle = params.bgColor;
this.context.fill();
this.context.closePath();
this.context.beginPath();
this.context.stroke();
this.context.fillStyle = params.textColor;
if ((typeof opt.n) === "number" && opt.n > 999) {
const count = ((opt.n > 9999) ? 9 : Math.floor(opt.n as number / 1000)) + "k+";
this.context.fillText(count, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.2));
} else {
this.context.fillText("" + opt.n, Math.floor(opt.x + opt.w / 2), Math.floor(opt.y + opt.h - opt.h * 0.15));
}
this.context.closePath();
}
private ready() {
if (this.isReady) return;
this.isReady = true;
this.readyCb();
}
private setIcon(canvas) {
setImmediate(() => {
this.setIconSrc(canvas.toDataURL("image/png"));
});
}
private setIconSrc(url) {
// if is attached to fav icon
if (this.browser.ff || this.browser.opera) {
// for FF we need to "recreate" element, attach to dom and remove old <link>
const old = this.icons[this.icons.length - 1];
const newIcon = window.document.createElement("link");
this.icons = [newIcon];
newIcon.setAttribute("rel", "icon");
newIcon.setAttribute("type", "image/png");
window.document.getElementsByTagName("head")[0].appendChild(newIcon);
newIcon.setAttribute("href", url);
if (old.parentNode) {
old.parentNode.removeChild(old);
}
} else {
this.icons.forEach(icon => {
icon.setAttribute("href", url);
});
}
}
public badge(content: number | string, opts?: Partial<IParams>) {
if (!this.isReady) {
this.readyCb = () => {
this.badge(content, opts);
}
return;
}
if (typeof content === "string" || content > 0) {
this.circle(content, opts);
} else {
this.reset();
}
this.setIcon(this.canvas);
}
private static getLinks() {
const icons: HTMLLinkElement[] = [];
const links = window.document.getElementsByTagName("head")[0].getElementsByTagName("link");
for (let i = 0; i < links.length; i++) {
if ((/(^|\s)icon(\s|$)/i).test(links[i].getAttribute("rel"))) {
icons.push(links[i]);
}
}
return icons;
}
private static getIcons() {
// get favicon link elements
let elms = Favicon.getLinks();
if (elms.length === 0) {
elms = [window.document.createElement("link")];
elms[0].setAttribute("rel", "icon");
window.document.getElementsByTagName("head")[0].appendChild(elms[0]);
}
elms.forEach(item => {
item.setAttribute("type", "image/png");
});
return elms;
}
}
......@@ -31,8 +31,5 @@
"Decentralised, encrypted chat &amp; collaboration powered by [matrix]": "Decentralised, encrypted chat &amp; collaboration powered by [matrix]",
"Sign In": "Sign In",
"Create Account": "Create Account",
"Need help?": "Need help?",
"Chat with Riot Bot": "Chat with Riot Bot",
"Explore rooms": "Explore rooms",
"Room Directory": "Room Directory"
"Explore rooms": "Explore rooms"
}
......@@ -26,5 +26,15 @@
"Open user settings": "Ireki erabiltzailearen ezarpenak",
"Missing indexeddb worker script!": "indexeddb langile scripta falta da!",
"Unable to load config file: please refresh the page to try again.": "Ezin izan da konfigurazio fitxategia kargatu: Saiatu orria birkargatzen.",
"Previous/next recently visited room or community": "Berriki bisitatutako aurreko/hurrengo gela edo komunitatea"
"Previous/next recently visited room or community": "Berriki bisitatutako aurreko/hurrengo gela edo komunitatea",
"Riot Desktop (%(platformName)s)": "Riot Desktop (%(platformName)s)",
"%(appName)s (%(browserName)s, %(osName)s)": "%(appName)s (%(browserName)s, %(osName)s)",
"Unsupported browser": "Onartu gabeko nabigatzailea",
"Your browser can't run Riot": "Zure nabigatzaileak ezin du Riot abiatu",
"Riot uses advanced browser features which aren't supported by your current browser.": "Riotek zure oraingo nabigatzailean erabilgarri ez dauden ezaugarri aurreratuak erabiltzen ditu .",
"Please install <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink>, or <safariLink>Safari</safariLink> for the best experience.": "Instalatu <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink>, edo <safariLink>Safari</safariLink> esperientzia hobe baterako.",
"You can continue using your current browser, but some or all features may not work and the look and feel of the application may be incorrect.": "Zure oraingo nabigatzailea erabiltzen jarraitu dezakezu, baina ezaugarri batzuk agian ez dute funtzionatuko eta itxura desegokia izan daiteke.",
"I understand the risks and wish to continue": "Arriskuak ulertzen ditut eta jarraitu nahi dut",
"Go to Riot.im": "Joan Riot.im gunera",
"Failed to start": "Huts egin du abiatzean"
}
{
"Dismiss": "Hylkää",
"Unknown device": "Tuntematon laite",
"Welcome to Riot.im": "Tervetuloa Riot.im-palveluun",
"Welcome to Riot.im": "Tervetuloa Riot.im-sovellukseen",
"Custom Server Options": "Palvelinasetukset",
"Riot Desktop on %(platformName)s": "Riot Desktop, %(platformName)s",
"You need to be using HTTPS to place a screen-sharing call.": "Sinun täytyy käyttää HTTPS-yhteyttä, jotta voit jakaa ruudun puhelussa.",
......@@ -22,5 +22,18 @@
"Your Riot configuration contains invalid JSON. Please correct the problem and reload the page.": "Riot-asetuksissasi on virheellistä JSONia. Korjaa ongelma ja lataa sivu uudelleen.",
"The message from the parser is: %(message)s": "Viesti jäsentimeltä: %(message)s",
"Invalid JSON": "Virheellinen JSON",
"Missing indexeddb worker script!": "Indexeddb-suorittajan skripti puuttuu!"
"Missing indexeddb worker script!": "Indexeddb-suorittajan skripti puuttuu!",
"Unable to load config file: please refresh the page to try again.": "Asetustiedostoa ei voi ladata. Yritä uudelleen lataamalla sivu uudelleen.",
"Open user settings": "Avaa käyttäjäasetukset",
"Previous/next recently visited room or community": "Edellinen/seuraava hiljattain vierailtu huone tai yhteisö",
"Riot Desktop (%(platformName)s)": "Riot Desktop (%(platformName)s)",
"Go to your browser to complete Sign In": "Tee kirjautuminen loppuun selaimessasi",
"%(appName)s (%(browserName)s, %(osName)s)": "%(appName)s (%(browserName)s, %(osName)s)",
"Unsupported browser": "Selainta ei tueta",
"Your browser can't run Riot": "Riot ei toimi selaimellasi",
"Riot uses advanced browser features which aren't supported by your current browser.": "Riot käyttää edistyneitä selaimen ominaisuuksia, joita nykyinen selaimesi ei tue.",
"Please install <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink>, or <safariLink>Safari</safariLink> for the best experience.": "Asenna <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink> tai <safariLink>Safari</safariLink>, jotta kaikki toimii parhaiten.",
"You can continue using your current browser, but some or all features may not work and the look and feel of the application may be incorrect.": "Voit käyttää edelleen nykyistä selaintasi, mutta jotkut tai kaikki ominaisuudet eivät ehkä toimi ja sovelluksen ulkoasu voi olla virheellinen.",
"I understand the risks and wish to continue": "Ymmärrän riskit ja haluan jatkaa",
"Failed to start": "Käynnistys ei onnistunut"
}
......@@ -10,7 +10,7 @@
"Decentralised, encrypted chat &amp; collaboration powered by [matrix]": "Conversas e colaboración descentralizada e cifrada grazas a [matrix]",
"Chat with Riot Bot": "Conversa co bot de Riot",
"You can use the custom server options to sign into other Matrix servers by specifying a different homeserver URL. This allows you to use Riot with an existing Matrix account on a different homeserver.": "Podes usar as opcións de servidor personalizado para iniciar sesión en outros servidores Matrix especificando unha dirección diferente de servidor doméstico. Con esto podes usar Riot cunha conta Matrix existente noutro servidor doméstico.",
"Sign In": "Entrar",
"Sign In": "Conectar",
"Create Account": "Crear conta",
"Need help?": "¿Precisas axuda?",
"Explore rooms": "Explorar salas",
......@@ -18,8 +18,23 @@
"Your Riot configuration contains invalid JSON. Please correct the problem and reload the page.": "A configuración de Riot contén JSON non válido. Corrixe o problema e recarga a páxina.",
"The message from the parser is: %(message)s": "A mensaxe desde o intérprete é: %(message)s",
"Invalid JSON": "JSON non válido",
"Your Riot is misconfigured": "Riot está mal configurado",
"Your Riot is misconfigured": "O teu Riot está mal configurado",
"Unexpected error preparing the app. See console for details.": "Fallo non agardado ao preparar a app. Detalles na consola.",
"Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.": "Configuración non válida: só se pode indicar un de default_server_config, default_server_name, ou default_hs_url.",
"Invalid configuration: no default server specified.": "Configuración non válida: non se indicou servidor por omisión."
"Invalid configuration: no default server specified.": "Configuración non válida: non se indicou servidor por omisión.",
"Missing indexeddb worker script!": "Falta o script indexeddb!",
"Unable to load config file: please refresh the page to try again.": "Non se cargou o ficheiro de configuración: actualiza a páxina para reintentalo.",
"Open user settings": "Abrir axustes do usuario",
"Previous/next recently visited room or community": "Anterior/seguinte sala ou comunidade recentes",
"Riot Desktop (%(platformName)s)": "Riot Desktop (%(platformName)s)",
"Go to your browser to complete Sign In": "Abre o navegador para realizar a Conexión",
"%(appName)s (%(browserName)s, %(osName)s)": "%(appName)s (%(browserName)s, %(osName)s)",
"Unsupported browser": "Navegador non soportado",
"Your browser can't run Riot": "O teu navegador non pode executar Riot",
"Riot uses advanced browser features which aren't supported by your current browser.": "Riot utiliza funcións avanzadas dos navegadores que o teu actual non soporta.",
"Please install <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink>, or <safariLink>Safari</safariLink> for the best experience.": "Instala <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink>, ou <safariLink>Safari</safariLink> para ter unha mellor experiencia.",
"You can continue using your current browser, but some or all features may not work and the look and feel of the application may be incorrect.": "Podes continuar co teu navegador, pero algunhas características poderían non funcionar e o aspecto da aplicación podería non ser o correcto.",
"I understand the risks and wish to continue": "Entendo os riscos e desexo continuar",
"Go to Riot.im": "Ir a Riot.im",
"Failed to start": "Fallou o inicio"
}
......@@ -10,7 +10,7 @@
"Dismiss": "Atmesti",
"Decentralised, encrypted chat &amp; collaboration powered by [matrix]": "Decentralizuoti, šifruoti pokalbiai ir bendradarbiavimas, veikiantis su [matrix]",
"Sign In": "Prisijungti",
"Create Account": "Sukurti paskyrą",
"Create Account": "Sukurti Paskyrą",
"Need help?": "Reikia pagalbos?",
"Explore rooms": "Žvalgyti kambarius",
"Room Directory": "Kambarių katalogas",
......@@ -21,7 +21,20 @@
"Unexpected error preparing the app. See console for details.": "Netikėta klaida ruošiant programą. Norėdami sužinoti daugiau detalių, žiūrėkite konsolę.",
"Invalid configuration: can only specify one of default_server_config, default_server_name, or default_hs_url.": "Klaidinga konfigūracija: galima nurodyti tik vieną iš default_server_config, default_server_name, arba default_hs_url.",
"Invalid configuration: no default server specified.": "Klaidinga konfigūracija: nenurodytas numatytasis serveris.",
"You can use the custom server options to sign into other Matrix servers by specifying a different homeserver URL. This allows you to use Riot with an existing Matrix account on a different homeserver.": "Jūs galite naudoti pasirinktinius serverio nustatymus, kad prisijungtumėte prie kitų Matrix serverių, nurodydami kito serverio URL. Tai leidžia jums naudotis Riot su esama Matrix paskyra kitame serveryje.",
"You can use the custom server options to sign into other Matrix servers by specifying a different homeserver URL. This allows you to use Riot with an existing Matrix account on a different homeserver.": "Jūs galite naudoti pasirinktinius serverio nustatymus, kad prisijungtumėte prie kitų Matrix serverių, nurodydami kito serverio URL. Tai leidžia jums naudotis Riot su kitame serveryje esančia Matrix paskyra.",
"Go to your browser to complete Sign In": "Norėdami užbaigti prisijungimą, eikite į naršyklę",
"Open user settings": "Atverti vartotojo nustatymus"
"Open user settings": "Atverti vartotojo nustatymus",
"Missing indexeddb worker script!": "Trūksta indexeddb worker skripto!",
"Unable to load config file: please refresh the page to try again.": "Nepavyko įkelti konfigūracijos failo: iš naujo užkraukite puslapį ir bandykite dar kartą.",
"Previous/next recently visited room or community": "Ankstesnis/sekantis neseniai lankytas kambarys ar bendruomenė",
"Riot Desktop (%(platformName)s)": "Riot Kompiuteriui (%(platformName)s)",
"%(appName)s (%(browserName)s, %(osName)s)": "%(appName)s (%(browserName)s, %(osName)s)",
"Unsupported browser": "Nepalaikoma naršyklė",
"Your browser can't run Riot": "Jūsų naršyklė negali paleisti Riot",
"Riot uses advanced browser features which aren't supported by your current browser.": "Riot naudoja išplėstines funkcijas, kurių jūsų dabartinė naršyklė nepalaiko.",
"Please install <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink>, or <safariLink>Safari</safariLink> for the best experience.": "Riot geriausiai veikia su <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink>, arba <safariLink>Safari</safariLink> naršyklėmis.",
"You can continue using your current browser, but some or all features may not work and the look and feel of the application may be incorrect.": "Jūs galite toliau naudotis savo dabartine naršykle, bet kai kurios arba visos funkcijos gali neveikti ir programos išvaizda bei sąsaja gali būti neteisingai rodoma.",
"I understand the risks and wish to continue": "Suprantu šią riziką ir noriu tęsti",
"Go to Riot.im": "Eiti į Riot.im",
"Failed to start": "Nepavyko paleisti"
}
......@@ -21,5 +21,16 @@
"Your Riot configuration contains invalid JSON. Please correct the problem and reload the page.": "Jūsu Riot konfigurācijā ir nederīgs JSON. Lūdzu, izlabojiet problēmu un ielādējiet lapu atkārtoti.",
"The message from the parser is: %(message)s": "Ziņojums no parsētāja ir: %(message)s",
"Invalid JSON": "Nederīgs JSON",
"Your Riot is misconfigured": "Jūsu Riot ir nepareizi konfigurēts"
"Your Riot is misconfigured": "Jūsu Riot ir nepareizi konfigurēts",
"Unable to load config file: please refresh the page to try again.": "Neizdevās ielādēt config datni: lūdzu pārlādē lapu lai mēģinātu vēlreiz.",
"Open user settings": "Atver lietotāja iestatījumus",
"Go to your browser to complete Sign In": "Aizej uz savu pārlūku lai pabeigtu Piekļuvi",
"Unsupported browser": "Neatbalstīts pārlūks",
"Your browser can't run Riot": "Tavs pārlūks nevar palaist Riot",
"Riot uses advanced browser features which aren't supported by your current browser.": "",
"Please install <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink>, or <safariLink>Safari</safariLink> for the best experience.": "Lūdzu instalē <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink>, vai <safariLink>Safari</safariLink> priekš labākās pieredzes.",
"You can continue using your current browser, but some or all features may not work and the look and feel of the application may be incorrect.": "Tu vari turpināt izmantot savu pašreizējo pārlūku, bet dažas vai visas funkcijas nestrādās, un lietotnes izskats var būt nepareizs.",
"I understand the risks and wish to continue": "Es pieņemu riskus un vēlos turpināt",
"Go to Riot.im": "Ej uz Riot.im",
"Failed to start": "Neizdevās palaist"
}
......@@ -26,5 +26,15 @@
"Unable to load config file: please refresh the page to try again.": "Nemožno načítať konfiguračný súbor: prosím, obnovte stránku a skúste to znova.",
"Open user settings": "Otvoriť používateľské nastavenia",
"Previous/next recently visited room or community": "Predchádzajúca/ďalšia nedávno navštívená miestnosť alebo komunita",
"Go to your browser to complete Sign In": "Prejdite do prehliadača a dokončite prihlásenie"
"Go to your browser to complete Sign In": "Prejdite do prehliadača a dokončite prihlásenie",
"Riot Desktop (%(platformName)s)": "Riot Desktop (%(platformName)s)",
"%(appName)s (%(browserName)s, %(osName)s)": "%(appName)s (%(browserName)s, %(osName)s)",
"Unsupported browser": "Nepodporovaný prehliadač",
"Your browser can't run Riot": "Váš prehliadač nerozbehne Riot",
"Riot uses advanced browser features which aren't supported by your current browser.": "Riot používa komplexnejšie funkcie prehliadača, ktoré nie sú podporované vo vašom prehliadači.",
"Please install <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink>, or <safariLink>Safari</safariLink> for the best experience.": "Prosím, nainštalujte si <chromeLink>Chrome</chromeLink>, <firefoxLink>Firefox</firefoxLink> alebo <safariLink>Safari</safariLink> pre najlepší zážitok.",
"You can continue using your current browser, but some or all features may not work and the look and feel of the application may be incorrect.": "Môžete naďalej používať váš súčasný prehliadač, ale niektoré alebo všetky funkcie nemusia fungovať a zážitok z aplikácie nemusí byť optimálny.",
"I understand the risks and wish to continue": "Rozumiem riziku a chcem pokračovať",
"Go to Riot.im": "Prejsť na Riot.im",
"Failed to start": "Zapnutie zlyhalo"
}
......@@ -35,5 +35,6 @@
"You can continue using your current browser, but some or all features may not work and the look and feel of the application may be incorrect.": "Mund të vazhdoni të përdorni shfletuesin tuaj të tanishëm, por disa ose krejt veçoritë mund të mos funksionojnë dhe pamja dhe ndjesitë prej aplikacionit të mos jenë të sakta.",
"I understand the risks and wish to continue": "I kuptoj rreziqet dhe dëshiroj të vazhdoj",
"Go to Riot.im": "Shko te Riot.im",
"Failed to start": "S’u arrit të nisej"
"Failed to start": "S’u arrit të nisej",
"Missing indexeddb worker script!": "Mungon programth worker-i indexeddb-je!"
}
......@@ -15,6 +15,7 @@
<link rel="manifest" href="manifest.json">
<meta name="referrer" content="no-referrer">
<link rel="shortcut icon" href="<%= require('../../res/vector-icons/favicon.ico') %>">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-title" content="Riot">
<meta name="application-name" content="Riot">
<meta name="msapplication-TileColor" content="#da532c">
......
// @flow
/*
Copyright 2016 Aviral Dasgupta
Copyright 2016 OpenMarket Ltd
Copyright 2018 New Vector Ltd
Copyright 2018, 2020 New Vector Ltd
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
......@@ -20,11 +18,10 @@ limitations under the License.
*/
import BasePlatform from 'matrix-react-sdk/src/BasePlatform';
import { _t } from 'matrix-react-sdk/src/languageHandler';
import dis from 'matrix-react-sdk/src/dispatcher';
import {_t} from 'matrix-react-sdk/src/languageHandler';
import {getVectorConfig} from "../getconfig";
import Favico from 'favico.js';
import Favicon from "../../favicon";
export const updateCheckStatusEnum = {
CHECKING: 'CHECKING',
......@@ -37,14 +34,8 @@ export const updateCheckStatusEnum = {
/**
* Vector-specific extensions to the BasePlatform template
*/
export default class VectorBasePlatform extends BasePlatform {
constructor() {
super();
this.showUpdateCheck = false;
this.startUpdateCheck = this.startUpdateCheck.bind(this);
this.stopUpdateCheck = this.stopUpdateCheck.bind(this);
}
export default abstract class VectorBasePlatform extends BasePlatform {
protected _favicon: Favicon;
async getConfig(): Promise<{}> {
return getVectorConfig();
......@@ -55,62 +46,27 @@ export default class VectorBasePlatform extends BasePlatform {
}
/**
* Delay creating the `Favico` instance until first use (on the first notification) as
* it uses canvas, which can trigger a permission prompt in Firefox's resist
* fingerprinting mode.
* Delay creating the `Favicon` instance until first use (on the first notification) as
* it uses canvas, which can trigger a permission prompt in Firefox's resist fingerprinting mode.
* See https://github.com/vector-im/riot-web/issues/9605.
*/
get favicon() {
if (this._favicon) {
return this._favicon;
}
// The 'animations' are really low framerate and look terrible.
// Also it re-starts the animation every time you set the badge,
// and we set the state each time, even if the value hasn't changed,
// so we'd need to fix that if enabling the animation.
this._favicon = new Favico({ animation: 'none' });
return this._favicon;
return this._favicon = new Favicon();
}
_updateFavicon() {
try {
// This needs to be in in a try block as it will throw
// if there are more than 100 badge count changes in
// its internal queue
let bgColor = "#d00";
let notif = this.notificationCount;
if (this.errorDidOccur) {
notif = notif || "×";
bgColor = "#f00";
}
const doUpdate = () => {
this.favicon.badge(notif, {
bgColor: bgColor,
});
};
doUpdate();
// HACK: Workaround for Chrome 78+ and dependency incompatibility.
// The library we use doesn't appear to work in Chrome 78, likely due to their
// changes surrounding tab behaviour. Tabs went through a bit of a redesign and
// restructuring in Chrome 78, so it's not terribly surprising that the library
// doesn't work correctly. The library we use hasn't been updated in years and
// does not look easy to fix/fork ourselves - we might as well write our own that
// doesn't include animation/webcam/etc support. However, that's a bit difficult
// so for now we'll just trigger the update twice.
//
// Note that trying to reproduce the problem in isolation doesn't seem to work:
// see https://gist.github.com/turt2live/5ab87919918adbfd7cfb8f1ad10f2409 for
// an example (you'll need your own web server to host that).
if (window.chrome) {
doUpdate();
}
} catch (e) {
console.warn(`Failed to set badge count: ${e.message}`);
let bgColor = "#d00";
let notif: string | number = this.notificationCount;
if (this.errorDidOccur) {
notif = notif || "×";
bgColor = "#f00";
}
this.favicon.badge(notif, { bgColor });
}
setNotificationCount(count: number) {
......@@ -131,41 +87,6 @@ export default class VectorBasePlatform extends BasePlatform {
startUpdater() {
}
/**
* Whether we can call checkForUpdate on this platform build
*/
async canSelfUpdate(): boolean {
return false;
}
startUpdateCheck() {
this.showUpdateCheck = true;
dis.dispatch({
action: 'check_updates',
value: { status: updateCheckStatusEnum.CHECKING },
});
}
stopUpdateCheck() {
this.showUpdateCheck = false;
dis.dispatch({
action: 'check_updates',
value: false,
});
}
getUpdateCheckStatusEnum() {
return updateCheckStatusEnum;
}
/**
* Update the currently running app to the latest available
* version and replace this instance of the app with the
* new version.
*/
installUpdate() {
}
/**
* Get a sensible default display name for the
* device Vector is running on
......
// @flow
/*
Copyright 2016 Aviral Dasgupta
Copyright 2016 OpenMarket Ltd
......@@ -18,10 +16,15 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import VectorBasePlatform, {updateCheckStatusEnum} from './VectorBasePlatform';
import VectorBasePlatform from './VectorBasePlatform';
import {UpdateCheckStatus} from "matrix-react-sdk/src/BasePlatform";
import request from 'browser-request';
import dis from 'matrix-react-sdk/src/dispatcher';
import { _t } from 'matrix-react-sdk/src/languageHandler';
import dis from 'matrix-react-sdk/src/dispatcher/dispatcher';
import {_t} from 'matrix-react-sdk/src/languageHandler';
import {Room} from "matrix-js-sdk/src/models/room";
import {hideToast as hideUpdateToast, showToast as showUpdateToast} from "matrix-react-sdk/src/toasts/UpdateToast";
import {Action} from "matrix-react-sdk/src/dispatcher/actions";
import { CheckUpdatesPayload } from 'matrix-react-sdk/src/dispatcher/payloads/CheckUpdatesPayload';
import url from 'url';
import UAParser from 'ua-parser-js';
......@@ -29,13 +32,7 @@ import UAParser from 'ua-parser-js';
const POKE_RATE_MS = 10 * 60 * 1000; // 10 min
export default class WebPlatform extends VectorBasePlatform {
constructor() {
super();
this.runningVersion = null;
this.startUpdateCheck = this.startUpdateCheck.bind(this);
this.stopUpdateCheck = this.stopUpdateCheck.bind(this);
}
private runningVersion: string = null;
getHumanReadableName(): string {
return 'Web Platform'; // no translation required: only used for analytics
......@@ -46,7 +43,7 @@ export default class WebPlatform extends VectorBasePlatform {
* notifications, otherwise false.
*/
supportsNotifications(): boolean {
return Boolean(global.Notification);
return Boolean(window.Notification);
}
/**
......@@ -54,7 +51,7 @@ export default class WebPlatform extends VectorBasePlatform {
* to display notifications. Otherwise false.
*/
maySendNotifications(): boolean {
return global.Notification.permission === 'granted';
return window.Notification.permission === 'granted';
}
/**
......@@ -69,27 +66,27 @@ export default class WebPlatform extends VectorBasePlatform {
// promise, but this is only supported in Chrome 46
// and Firefox 47, so adapt the callback API.
return new Promise(function(resolve, reject) {
global.Notification.requestPermission((result) => {
window.Notification.requestPermission((result) => {
resolve(result);
});
});
}
displayNotification(title: string, msg: string, avatarUrl: string, room: Object) {
displayNotification(title: string, msg: string, avatarUrl: string, room: Room) {
const notifBody = {
body: msg,
tag: "vector",
silent: true, // we play our own sounds
};
if (avatarUrl) notifBody['icon'] = avatarUrl;
const notification = new global.Notification(title, notifBody);
const notification = new window.Notification(title, notifBody);
notification.onclick = function() {
dis.dispatch({
action: 'view_room',
room_id: room.roomId,
});
global.focus();
window.focus();
notification.close();
};
}
......@@ -131,45 +128,42 @@ export default class WebPlatform extends VectorBasePlatform {
startUpdater() {
this.pollForUpdate();
setInterval(this.pollForUpdate.bind(this), POKE_RATE_MS);
setInterval(this.pollForUpdate, POKE_RATE_MS);
}
async canSelfUpdate(): boolean {
async canSelfUpdate(): Promise<boolean> {
return true;
}
pollForUpdate() {
pollForUpdate = () => {
return this._getVersion().then((ver) => {
if (this.runningVersion === null) {
this.runningVersion = ver;
} else if (this.runningVersion !== ver) {
dis.dispatch({
action: 'new_version',
currentVersion: this.runningVersion,
newVersion: ver,
});
// Return to skip a MatrixChat state update
return;
if (this.shouldShowUpdate(ver)) {
showUpdateToast(this.runningVersion, ver);
}
return { status: UpdateCheckStatus.Ready };
} else {
hideUpdateToast();
}
return { status: updateCheckStatusEnum.NOTAVAILABLE };
return { status: UpdateCheckStatus.NotAvailable };
}, (err) => {
console.error("Failed to poll for update", err);
return {
status: updateCheckStatusEnum.ERROR,
status: UpdateCheckStatus.Error,
detail: err.message || err.status ? err.status.toString() : 'Unknown Error',
};
});
}
};
startUpdateCheck() {
if (this.showUpdateCheck) return;
super.startUpdateCheck();
this.pollForUpdate().then((updateState) => {
if (!this.showUpdateCheck) return;
if (!updateState) return;
dis.dispatch({
action: 'check_updates',
value: updateState,
dis.dispatch<CheckUpdatesPayload>({
action: Action.CheckUpdates,
...updateState,
});
});
}
......@@ -204,9 +198,9 @@ export default class WebPlatform extends VectorBasePlatform {
});
}
screenCaptureErrorString(): ?string {
screenCaptureErrorString(): string | null {
// it won't work at all if you're not on HTTPS so whine whine whine
if (!global.window || global.window.location.protocol !== "https:") {
if (window.location.protocol !== "https:") {
return _t("You need to be using HTTPS to place a screen-sharing call.");
}
return null;
......
......@@ -29,7 +29,7 @@ import * as jssdk from 'matrix-js-sdk';
import * as sdk from 'matrix-react-sdk';
import {MatrixClientPeg} from 'matrix-react-sdk/src/MatrixClientPeg';
import {Views} from 'matrix-react-sdk/src/components/structures/MatrixChat';
import dis from 'matrix-react-sdk/src/dispatcher';
import dis from 'matrix-react-sdk/src/dispatcher/dispatcher';
import * as test_utils from '../test-utils';
import MockHttpBackend from 'matrix-mock-request';
import {parseQs, parseQsFromFragment} from '../../src/vector/url_utils';
......@@ -589,8 +589,10 @@ describe('loading:', function() {
describe('Token login:', function() {
it('logs in successfully', function() {
localStorage.setItem("mx_hs_url", "https://homeserver");
localStorage.setItem("mx_is_url", "https://idserver");
loadApp({
queryString: "?loginToken=secretToken&homeserver=https%3A%2F%2Fhomeserver&identityServer=https%3A%2F%2Fidserver",
queryString: "?loginToken=secretToken",
});
return sleep(1).then(() => {
......
......@@ -14,7 +14,8 @@