|
@@ -29,6 +29,7 @@ import {QrCodeService} from './qrcode';
|
|
|
import {ReceiverService} from './receiver';
|
|
|
import {StateService} from './state';
|
|
|
import {TitleService} from './title';
|
|
|
+import {VersionService} from './version';
|
|
|
|
|
|
class WebClientDefault {
|
|
|
private avatar: threema.AvatarRegistry = {
|
|
@@ -132,7 +133,6 @@ export class WebClientService {
|
|
|
private $translate: ng.translate.ITranslateService;
|
|
|
private $filter: any;
|
|
|
private $timeout: ng.ITimeoutService;
|
|
|
- private $http: ng.IHttpService;
|
|
|
|
|
|
// Custom services
|
|
|
private notificationService: NotificationService;
|
|
@@ -144,6 +144,7 @@ export class WebClientService {
|
|
|
private qrCodeService: QrCodeService;
|
|
|
private mimeService: MimeService;
|
|
|
private receiverService: ReceiverService;
|
|
|
+ private versionService: VersionService;
|
|
|
|
|
|
// State handling
|
|
|
private startupPromise: ng.IDeferred<{}> = null; // TODO: deferred type
|
|
@@ -176,7 +177,7 @@ export class WebClientService {
|
|
|
private pcHelper: PeerConnectionHelper = null;
|
|
|
private deviceInfo: string = null;
|
|
|
private trustedKeyStore: TrustedKeyStoreService;
|
|
|
- private version = null;
|
|
|
+ public version = null;
|
|
|
|
|
|
private blobCache = new Map<String, ArrayBuffer>();
|
|
|
private loadingMessages = new Map<String, boolean>();
|
|
@@ -192,11 +193,11 @@ export class WebClientService {
|
|
|
private requestPromises: Map<string, threema.PromiseCallbacks> = new Map();
|
|
|
|
|
|
public static $inject = [
|
|
|
- '$log', '$rootScope', '$q', '$state', '$window', '$translate', '$filter',
|
|
|
- '$timeout', '$http',
|
|
|
+ '$log', '$rootScope', '$q', '$state', '$window', '$translate', '$filter', '$timeout',
|
|
|
'Container', 'TrustedKeyStore',
|
|
|
'StateService', 'NotificationService', 'MessageService', 'PushService', 'BrowserService',
|
|
|
'TitleService', 'FingerPrintService', 'QrCodeService', 'MimeService', 'ReceiverService',
|
|
|
+ 'VersionService',
|
|
|
'CONFIG',
|
|
|
];
|
|
|
constructor($log: ng.ILogService,
|
|
@@ -207,7 +208,6 @@ export class WebClientService {
|
|
|
$translate: ng.translate.ITranslateService,
|
|
|
$filter: ng.IFilterService,
|
|
|
$timeout: ng.ITimeoutService,
|
|
|
- $http: ng.IHttpService,
|
|
|
container: threema.Container.Factory,
|
|
|
trustedKeyStore: TrustedKeyStoreService,
|
|
|
stateService: StateService,
|
|
@@ -220,6 +220,7 @@ export class WebClientService {
|
|
|
qrCodeService: QrCodeService,
|
|
|
mimeService: MimeService,
|
|
|
receiverService: ReceiverService,
|
|
|
+ VersionService: VersionService,
|
|
|
CONFIG: threema.Config) {
|
|
|
|
|
|
// Angular services
|
|
@@ -231,7 +232,6 @@ export class WebClientService {
|
|
|
this.$translate = $translate;
|
|
|
this.$filter = $filter;
|
|
|
this.$timeout = $timeout;
|
|
|
- this.$http = $http;
|
|
|
|
|
|
// Own services
|
|
|
this.notificationService = notificationService;
|
|
@@ -243,6 +243,7 @@ export class WebClientService {
|
|
|
this.qrCodeService = qrCodeService;
|
|
|
this.mimeService = mimeService;
|
|
|
this.receiverService = receiverService;
|
|
|
+ this.versionService = VersionService;
|
|
|
|
|
|
// Configuration object
|
|
|
this.config = CONFIG;
|
|
@@ -450,14 +451,7 @@ export class WebClientService {
|
|
|
this._requestInitialData();
|
|
|
|
|
|
// Fetch current version
|
|
|
- this.fetchVersion()
|
|
|
- .then((version: string) => {
|
|
|
- this.version = version;
|
|
|
- this.$log.info(this.logTag, 'Using Threema Web version', this.version);
|
|
|
- })
|
|
|
- .catch((error: string) => {
|
|
|
- this.$log.error(this.logTag, 'Could not fetch version.txt:', error);
|
|
|
- });
|
|
|
+ this.versionService.initVersion();
|
|
|
|
|
|
// Notify state service about data loading
|
|
|
this.stateService.updateConnectionBuildupState('loading');
|
|
@@ -1309,34 +1303,6 @@ export class WebClientService {
|
|
|
this.requestConversations();
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * Fetch the version.txt file.
|
|
|
- */
|
|
|
- private fetchVersion(): Promise<string> {
|
|
|
- return new Promise((resolve, reject) => {
|
|
|
- const cacheBust = Math.floor(Math.random() * 1000000000);
|
|
|
- this.$http({
|
|
|
- method: 'GET',
|
|
|
- url: 'version.txt?' + cacheBust,
|
|
|
- cache: false,
|
|
|
- responseType: 'text',
|
|
|
- transformResponse: (data: string, headersGetter, statusCode) => {
|
|
|
- if (statusCode !== 200) {
|
|
|
- this.$log.error('Could not fetch version.txt: HTTP', statusCode);
|
|
|
- }
|
|
|
- return data.trim();
|
|
|
- },
|
|
|
- }).then(
|
|
|
- (successResponse: ng.IHttpPromiseCallbackArg<string>) => {
|
|
|
- resolve(successResponse.data);
|
|
|
- },
|
|
|
- (error: Error) => {
|
|
|
- reject(error);
|
|
|
- },
|
|
|
- );
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
private _receiveResponseReceivers(message: threema.WireMessage) {
|
|
|
this.$log.debug('Received receiver response');
|
|
|
|