Convert app loading message code to TypeScript
This commit is contained in:
parent
d4bba46b2c
commit
53d4a31311
4 changed files with 21 additions and 27 deletions
|
@ -125,9 +125,6 @@ const { UUID } = require('../../ts/types/UUID');
|
|||
const { Address } = require('../../ts/types/Address');
|
||||
const { QualifiedAddress } = require('../../ts/types/QualifiedAddress');
|
||||
|
||||
// Views
|
||||
const Initialization = require('./views/initialization');
|
||||
|
||||
// Processes / Services
|
||||
const {
|
||||
initializeGroupCredentialFetcher,
|
||||
|
@ -404,10 +401,6 @@ exports.setup = (options = {}) => {
|
|||
QualifiedAddress,
|
||||
};
|
||||
|
||||
const Views = {
|
||||
Initialization,
|
||||
};
|
||||
|
||||
return {
|
||||
Backbone,
|
||||
Components,
|
||||
|
@ -426,6 +419,5 @@ exports.setup = (options = {}) => {
|
|||
Stickers,
|
||||
Types,
|
||||
Util,
|
||||
Views,
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
// Copyright 2018-2020 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
/* eslint-env browser */
|
||||
|
||||
/* global i18n: false */
|
||||
|
||||
const DISPLAY_THRESHOLD = 3000; // milliseconds
|
||||
const SELECTOR = '.app-loading-screen .message';
|
||||
|
||||
let timeout;
|
||||
let targetString;
|
||||
let didTimeout = false;
|
||||
|
||||
const clear = () => {
|
||||
if (timeout) {
|
||||
clearTimeout(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
};
|
||||
|
||||
const setMessage = loadingText => {
|
||||
const message = document.querySelector(SELECTOR);
|
||||
if (!message) {
|
||||
return clear;
|
||||
}
|
||||
|
||||
targetString = loadingText || i18n('optimizingApplication');
|
||||
|
||||
message.innerText = didTimeout ? targetString : i18n('loading');
|
||||
|
||||
if (timeout) {
|
||||
return clear;
|
||||
}
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
didTimeout = true;
|
||||
const innerMessage = document.querySelector(SELECTOR);
|
||||
if (!innerMessage) {
|
||||
return;
|
||||
}
|
||||
innerMessage.innerText = targetString;
|
||||
}, DISPLAY_THRESHOLD);
|
||||
|
||||
return clear;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
setMessage,
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue