2016-11-02 17:45:35 +00:00
|
|
|
|
/*
|
2016-11-03 11:51:41 +00:00
|
|
|
|
Copyright 2016 Aviral Dasgupta
|
|
|
|
|
Copyright 2016 OpenMarket Ltd
|
2020-05-20 19:56:54 +01:00
|
|
|
|
Copyright 2018, 2020 New Vector Ltd
|
2019-06-26 21:08:04 +01:00
|
|
|
|
Copyright 2019 Michael Telatynski <7t3chguy@gmail.com>
|
2016-11-02 17:45:35 +00:00
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-12-19 18:47:40 -07:00
|
|
|
|
import BasePlatform from 'matrix-react-sdk/src/BasePlatform';
|
2020-05-29 18:24:45 +01:00
|
|
|
|
import {_t} from 'matrix-react-sdk/src/languageHandler';
|
2019-06-26 21:08:04 +01:00
|
|
|
|
import {getVectorConfig} from "../getconfig";
|
2017-05-31 14:51:08 +01:00
|
|
|
|
|
2020-05-20 19:56:54 +01:00
|
|
|
|
import Favicon from "../../favicon";
|
2016-11-02 17:45:35 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Vector-specific extensions to the BasePlatform template
|
|
|
|
|
*/
|
2020-05-21 18:07:01 +01:00
|
|
|
|
export default abstract class VectorBasePlatform extends BasePlatform {
|
2020-05-20 19:56:54 +01:00
|
|
|
|
protected _favicon: Favicon;
|
2017-05-13 12:37:13 +01:00
|
|
|
|
|
2019-06-26 21:08:04 +01:00
|
|
|
|
async getConfig(): Promise<{}> {
|
|
|
|
|
return getVectorConfig();
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-29 20:03:21 +01:00
|
|
|
|
getHumanReadableName(): string {
|
2017-05-31 14:51:08 +01:00
|
|
|
|
return 'Vector Base Platform'; // no translation required: only used for analytics
|
2017-05-29 19:51:28 +01:00
|
|
|
|
}
|
|
|
|
|
|
2019-05-02 13:29:25 +01:00
|
|
|
|
/**
|
2020-05-20 19:56:54 +01:00
|
|
|
|
* 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.
|
2019-05-02 13:29:25 +01:00
|
|
|
|
* See https://github.com/vector-im/riot-web/issues/9605.
|
|
|
|
|
*/
|
|
|
|
|
get favicon() {
|
|
|
|
|
if (this._favicon) {
|
|
|
|
|
return this._favicon;
|
|
|
|
|
}
|
2020-05-20 19:56:54 +01:00
|
|
|
|
return this._favicon = new Favicon();
|
2019-05-02 13:29:25 +01:00
|
|
|
|
}
|
|
|
|
|
|
2017-05-13 12:37:13 +01:00
|
|
|
|
_updateFavicon() {
|
2020-05-20 19:56:54 +01:00
|
|
|
|
let bgColor = "#d00";
|
|
|
|
|
let notif: string | number = this.notificationCount;
|
|
|
|
|
|
|
|
|
|
if (this.errorDidOccur) {
|
|
|
|
|
notif = notif || "×";
|
|
|
|
|
bgColor = "#f00";
|
2017-05-13 12:37:13 +01:00
|
|
|
|
}
|
2020-05-20 19:56:54 +01:00
|
|
|
|
|
|
|
|
|
this.favicon.badge(notif, { bgColor });
|
2017-05-13 12:37:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setNotificationCount(count: number) {
|
|
|
|
|
if (this.notificationCount === count) return;
|
|
|
|
|
super.setNotificationCount(count);
|
|
|
|
|
this._updateFavicon();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setErrorStatus(errorDidOccur: boolean) {
|
|
|
|
|
if (this.errorDidOccur === errorDidOccur) return;
|
|
|
|
|
super.setErrorStatus(errorDidOccur);
|
|
|
|
|
this._updateFavicon();
|
|
|
|
|
}
|
|
|
|
|
|
2017-06-03 12:50:47 +01:00
|
|
|
|
/**
|
|
|
|
|
* Begin update polling, if applicable
|
|
|
|
|
*/
|
|
|
|
|
startUpdater() {
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-24 16:46:15 +00:00
|
|
|
|
/**
|
|
|
|
|
* Get a sensible default display name for the
|
|
|
|
|
* device Vector is running on
|
|
|
|
|
*/
|
2017-05-02 21:29:19 +01:00
|
|
|
|
getDefaultDeviceDisplayName(): string {
|
2017-05-31 14:51:08 +01:00
|
|
|
|
return _t("Unknown device");
|
2016-11-24 16:46:15 +00:00
|
|
|
|
}
|
2016-11-02 17:45:35 +00:00
|
|
|
|
}
|