diff --git a/_locales/en/messages.json b/_locales/en/messages.json index a8df96028e33..de3771b9c4b9 100644 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -39,6 +39,10 @@ "message": "Loading...", "description": "Message shown on the loading screen before we've loaded any messages" }, + "optimizingApplication": { + "message": "Optimizing application...", + "description": "Message shown on the loading screen while we are doing application optimizations" + }, "chooseDirectory": { "message": "Choose folder", "description": "Button to allow the user to find a folder on disk" diff --git a/background.html b/background.html index 091686fda6cc..b3a2517b448c 100644 --- a/background.html +++ b/background.html @@ -951,7 +951,6 @@ -
@@ -962,8 +961,10 @@
-
Loading...
+
+ + diff --git a/js/background.js b/js/background.js index 27018df5c317..d72edc427fbb 100644 --- a/js/background.js +++ b/js/background.js @@ -17,6 +17,7 @@ const { IdleDetector, MessageDataMigrator } = Signal.Workflow; const { Errors, Message } = window.Signal.Types; const { upgradeMessageSchema } = window.Signal.Migrations; + const { Views } = window.Signal; // Implicitly used in `indexeddb-backbonejs-adapter`: // https://github.com/signalapp/Signal-Desktop/blob/4033a9f8137e62ed286170ed5d4941982b1d3a64/components/indexeddb-backbonejs-adapter/backbone-indexeddb.js#L569 @@ -74,6 +75,8 @@ return accountManager; }; + const cancelInitializationMessage = Views.Initialization.setMessage(); + console.log('Start IndexedDB migrations'); storage.fetch(); @@ -163,6 +166,7 @@ connect(true); }); + cancelInitializationMessage(); var appView = window.owsDesktopApp.appView = new Whisper.AppView({el: $('body')}); Whisper.WallClockListener.init(Whisper.events); diff --git a/js/modules/views/initialization.js b/js/modules/views/initialization.js new file mode 100644 index 000000000000..81ea453813f9 --- /dev/null +++ b/js/modules/views/initialization.js @@ -0,0 +1,30 @@ +/* eslint-env browser */ + +/* global i18n: false */ + + +const OPTIMIZATION_MESSAGE_DISPLAY_THRESHOLD = 1000; // milliseconds + +const setMessage = () => { + const message = document.querySelector('.app-loading-screen .message'); + if (!message) { + return () => {}; + } + message.innerText = i18n('loading'); + + const optimizingMessageTimeoutId = setTimeout(() => { + const innerMessage = document.querySelector('.app-loading-screen .message'); + if (!innerMessage) { + return; + } + innerMessage.innerText = i18n('optimizingApplication'); + }, OPTIMIZATION_MESSAGE_DISPLAY_THRESHOLD); + + return () => { + clearTimeout(optimizingMessageTimeoutId); + }; +}; + +module.exports = { + setMessage, +}; diff --git a/preload.js b/preload.js index 3528fc75fce7..c10ed563ae62 100644 --- a/preload.js +++ b/preload.js @@ -124,7 +124,7 @@ const { IdleDetector} = require('./js/modules/idle_detector'); - window.Signal = window.Signal || {}; + window.Signal = {}; window.Signal.Backup = require('./js/modules/backup'); window.Signal.Crypto = require('./js/modules/crypto'); window.Signal.Logs = require('./js/modules/logs'); @@ -134,12 +134,14 @@ window.Signal.Migrations.upgradeMessageSchema = upgradeMessageSchema; window.Signal.Migrations.V17 = require('./js/modules/migrations/17'); window.Signal.OS = require('./js/modules/os'); - window.Signal.Types = window.Signal.Types || {}; + window.Signal.Types = {}; window.Signal.Types.Attachment = Attachment; window.Signal.Types.Errors = require('./js/modules/types/errors'); window.Signal.Types.Message = Message; window.Signal.Types.MIME = require('./js/modules/types/mime'); window.Signal.Types.Settings = require('./js/modules/types/settings'); + window.Signal.Views = {}; + window.Signal.Views.Initialization = require('./js/modules/views/initialization'); window.Signal.Workflow = {}; window.Signal.Workflow.IdleDetector = IdleDetector; window.Signal.Workflow.MessageDataMigrator =