From add19aa73254be6285afff0e43f02b2e1db44d4d Mon Sep 17 00:00:00 2001 From: Daniel Gasienica Date: Thu, 22 Mar 2018 11:52:52 -0400 Subject: [PATCH] Add initialization view --- _locales/en/messages.json | 4 ++++ js/modules/views/initialization.js | 33 ++++++++++++++++++++++++++++++ preload.js | 2 ++ 3 files changed, 39 insertions(+) create mode 100644 js/modules/views/initialization.js 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/js/modules/views/initialization.js b/js/modules/views/initialization.js new file mode 100644 index 000000000000..12bf334b568a --- /dev/null +++ b/js/modules/views/initialization.js @@ -0,0 +1,33 @@ +/* eslint-env browser */ + +/* global i18n: false */ + + +const OPTIMIZATION_MESSAGE_DISPLAY_THRESHOLD = 2000; // milliseconds + +// type Canceler = () => Eff Unit +// +// setMessage :: Unit -> Eff (dom :: DOM) Canceler +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 26aead31d0b0..c10ed563ae62 100644 --- a/preload.js +++ b/preload.js @@ -140,6 +140,8 @@ 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 =