Skip to content

Commit c678bb8

Browse files
authored
feat: Add app loader (#17558)
* feat: Add app loader * app loader improvements * add german translation * cr changes * move loadingMessage into setTimeout
1 parent 1bdd3a8 commit c678bb8

File tree

3 files changed

+110
-1
lines changed

3 files changed

+110
-1
lines changed

src/page/index.ejs

Lines changed: 65 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,71 @@
2424
</head>
2525

2626
<body>
27-
<main id="wire-app"></main>
27+
<main id="wire-app">
28+
<style>
29+
body {
30+
margin: 0;
31+
}
32+
33+
#loader-root {
34+
align-items: center;
35+
background-color: #fafafa;
36+
color: #676b71;
37+
display: flex;
38+
flex-direction: column;
39+
height: 100%;
40+
justify-content: center;
41+
position: absolute;
42+
width: 100%;
43+
}
44+
45+
.loading-spinner {
46+
width: 24px;
47+
height: 24px;
48+
border: 3px solid #000;
49+
border-bottom-color: transparent;
50+
border-radius: 50%;
51+
display: inline-block;
52+
box-sizing: border-box;
53+
animation: rotation 1s linear infinite;
54+
}
55+
56+
#loading-message {
57+
display: none;
58+
margin-top: 20px;
59+
padding-inline: 16px;
60+
}
61+
62+
#loading-message p {
63+
color: #676B71;
64+
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
65+
font-size: 12px;
66+
line-height: 14px;
67+
margin: 0;
68+
text-align: center;
69+
}
70+
71+
#loading-message.visible {
72+
display: block;
73+
}
74+
75+
@keyframes rotation {
76+
0% {
77+
transform: rotate(0deg);
78+
}
79+
100% {
80+
transform: rotate(360deg);
81+
}
82+
}
83+
</style>
84+
85+
<div id="loader-root">
86+
<div class="loading-spinner"></div>
87+
<div id="loading-message"></div>
88+
</div>
89+
</main>
90+
91+
<script src="./min/loader.js?<%= VERSION %>"></script>
2892
<script src="./config.js?<%= VERSION %>"></script>
2993
<script src="./min/dexie.js?<%= VERSION %>"></script>
3094
<script src="./min/vendor.js?<%= VERSION %>"></script>

src/page/loader.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Wire
3+
* Copyright (C) 2024 Wire Swiss GmbH
4+
*
5+
* This program is free software: you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation, either version 3 of the License, or
8+
* (at your option) any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful,
11+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
* GNU General Public License for more details.
14+
*
15+
* You should have received a copy of the GNU General Public License
16+
* along with this program. If not, see http://www.gnu.org/licenses/.
17+
*
18+
*/
19+
20+
const HALF_MINUTE_IN_MS = 30000;
21+
22+
const translations = {
23+
de: `<p>Laden von Wire dauert länger als erwartet.</p><p>Bitte überprüfen Sie Ihre Internetverbindung.</p>`,
24+
en: `<p>Loading Wire takes longer than expected.</p><p>Please check your internet connection.</p>`,
25+
};
26+
27+
const userLang = navigator.language;
28+
29+
setTimeout(() => {
30+
const loadingMessage = document.getElementById('loading-message');
31+
32+
if (!loadingMessage) {
33+
return;
34+
}
35+
36+
// TODO: If there will be more translations, we have to change this functionality..
37+
if (userLang.startsWith('de')) {
38+
loadingMessage.innerHTML = translations['de'];
39+
} else {
40+
loadingMessage.innerHTML = translations['en'];
41+
}
42+
43+
loadingMessage.classList.add('visible');
44+
}, HALF_MINUTE_IN_MS);

webpack.config.common.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ module.exports = {
162162
{from: 'resource', to: dist},
163163
{from: `assets`, to: `${dist}/assets`},
164164
{from: 'src/page/basicBrowserFeatureCheck.js', to: `${dist}/min/`},
165+
{from: 'src/page/loader.js', to: `${dist}/min/`},
165166
],
166167
}),
167168
new webpack.IgnorePlugin({resourceRegExp: /.*\.wasm/}),

0 commit comments

Comments
 (0)