fix: Passed stylesheets are 'unloaded' after some time

This commit is contained in:
Rene Hampölz 2022-11-12 16:15:21 +00:00
parent 2d6e2deb3d
commit 5f19bb8699

View file

@ -16,14 +16,28 @@ document.onreadystatechange = () => {
};
document.addEventListener('DOMContentLoaded', () => {
passThemes();
});
// Pass nextcloud themes and theme attributes to SnappyMail.
function passThemes() {
const iframe = document.getElementById('rliframe');
if (!iframe) return;
let firstLoad = true;
iframe.addEventListener('load', event => {
// repass theme styles when iframe is reloaded
if (!firstLoad) {
passThemes(event.target);
}
firstLoad = false;
});
passThemes(iframe);
// TODO: add initial stylesheets without primary colors to improve loading experience
});
// Pass nextcloud themes and theme attributes to SnappyMail.
function passThemes(iframe) {
if (!iframe) return;
const target = iframe.contentWindow.document;
const ncStylesheets = [...document.querySelectorAll('link.theme')];