Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add app loader #17558

Merged
merged 5 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 65 additions & 1 deletion src/page/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,71 @@
</head>

<body>
<main id="wire-app"></main>
<main id="wire-app">
<style>
body {
margin: 0;
}

#loader-root {
align-items: center;
background-color: #fafafa;
color: #676b71;
display: flex;
flex-direction: column;
height: 100%;
justify-content: center;
position: absolute;
width: 100%;
}

.loading-spinner {
width: 24px;
height: 24px;
border: 3px solid #000;
border-bottom-color: transparent;
border-radius: 50%;
display: inline-block;
box-sizing: border-box;
animation: rotation 1s linear infinite;
}

#loading-message {
display: none;
margin-top: 20px;
padding-inline: 16px;
}

#loading-message p {
color: #676B71;
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji";
font-size: 12px;
line-height: 14px;
margin: 0;
text-align: center;
}

#loading-message.visible {
display: block;
}

@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>

<div id="loader-root">
<div class="loading-spinner"></div>
<div id="loading-message"></div>
</div>
</main>

<script src="./min/loader.js?<%= VERSION %>"></script>
<script src="./config.js?<%= VERSION %>"></script>
<script src="./min/dexie.js?<%= VERSION %>"></script>
<script src="./min/vendor.js?<%= VERSION %>"></script>
Expand Down
41 changes: 41 additions & 0 deletions src/page/loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Wire
* Copyright (C) 2024 Wire Swiss GmbH
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/

const loadingMessage = document.getElementById('loading-message');
const HALF_MINUTE_IN_MS = 30000;

const translations = {
de: `<p>Laden von Wire dauert länger als erwartet.</p><p>Bitte überprüfen Sie Ihre Internetverbindung.</p>`,
en: `<p>Loading Wire takes longer than expected.</p><p>Please check your internet connection.</p>`,
};

const userLang = navigator.language;

setTimeout(() => {
if (loadingMessage) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do the getElementById here, else we are going to have a memory leak and never release the reference

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// TODO: If there will be more translations, we have to change this functionality..
if (userLang.startsWith('de')) {
loadingMessage.innerHTML = translations['de'];
} else {
loadingMessage.innerHTML = translations['en'];
}

loadingMessage.classList.add('visible');
}
}, HALF_MINUTE_IN_MS);
1 change: 1 addition & 0 deletions webpack.config.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ module.exports = {
// copying all static resources (audio, images, fonts...)
{from: 'resource', to: dist},
{from: 'src/page/basicBrowserFeatureCheck.js', to: `${dist}/min/`},
{from: 'src/page/loader.js', to: `${dist}/min/`},
],
}),
new webpack.IgnorePlugin({resourceRegExp: /.*\.wasm/}),
Expand Down
Loading