Fix blinking fonts again

Fix manifest for PWA
This commit is contained in:
Eduard Kuzmenko 2021-06-12 20:43:13 +03:00
parent 0a96e4893e
commit a034f207c8
5 changed files with 44 additions and 28 deletions

View File

@ -6,6 +6,7 @@
import { cancelEvent } from "../helpers/dom/cancelEvent";
import { attachClickEvent } from "../helpers/dom/clickEvent";
import loadFonts from "../helpers/dom/loadFonts";
import { Config, LangPackDifference, LangPackString } from "../layer";
import I18n, { LangPackKey } from "../lib/langPack";
import apiManager from "../lib/mtproto/mtprotoworker";
@ -61,7 +62,11 @@ export default function getLanguageChangeButton(appendTo: HTMLElement) {
});
const btnChangeLanguage = Button('btn-primary btn-secondary btn-primary-transparent primary', {text: 'Login.ContinueOnLanguage'});
loadFonts().then(() => {
window.requestAnimationFrame(() => {
appendTo.append(btnChangeLanguage);
});
});
rootScope.addEventListener('language_change', () => {
btnChangeLanguage.remove();

View File

@ -0,0 +1,12 @@
/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
* https://github.com/morethanwords/tweb/blob/master/LICENSE
*/
let promise: Promise<any>;
export default function loadFonts(): Promise<void> {
if(promise) return promise;
// @ts-ignore
return promise = 'fonts' in document ? Promise.all(['400 1rem Roboto', '500 1rem Roboto', '500 1rem tgico'].map(font => document.fonts.load(font))) : Promise.resolve();
}

View File

@ -8,6 +8,7 @@ import App from './config/app';
import blurActiveElement from './helpers/dom/blurActiveElement';
import findUpClassName from './helpers/dom/findUpClassName';
import fixSafariStickyInput from './helpers/dom/fixSafariStickyInput';
import loadFonts from './helpers/dom/loadFonts';
import { isMobileSafari } from './helpers/userAgent';
import './materialize.scss';
import './scss/style.scss';
@ -261,11 +262,6 @@ console.timeEnd('get storage1'); */
const langPromise = I18n.default.getCacheLangPack();
function loadFonts(): Promise<void> {
// @ts-ignore
return 'fonts' in document ? Promise.all(['400 1rem Roboto', '500 1rem Roboto'].map(font => document.fonts.load(font))) : Promise.resolve();
}
const [state, langPack] = await Promise.all([
appStateManager.default.getState(),
langPromise

View File

@ -395,7 +395,9 @@ export class AppDialogsManager {
new ConnectionStatusComponent(this.chatsContainer);
this.chatsContainer.append(bottomPart);
setTimeout(() => {
lottieLoader.loadLottieWorkers();
}, 200);
}
private getOffset(side: 'top' | 'bottom'): {index: number, pos: number} {

View File

@ -1,5 +1,3 @@
//import {stackBlurImage} from '../lib/StackBlur';
//import appStateManager from "../lib/appManagers/appStateManager";
/*
* https://github.com/morethanwords/tweb
* Copyright (C) 2019-2021 Eduard Kuzmenko
@ -7,6 +5,7 @@
*/
import blurActiveElement from "../helpers/dom/blurActiveElement";
import loadFonts from "../helpers/dom/loadFonts";
import appStateManager from "../lib/appManagers/appStateManager";
import I18n from "../lib/langPack";
import Page from "./page";
@ -30,6 +29,7 @@ let onFirstMount = () => {
}
blurActiveElement();
return loadFonts().then(() => {
return new Promise<void>((resolve) => {
window.requestAnimationFrame(() => {
const promise = import('../lib/appManagers/appDialogsManager');
@ -52,6 +52,7 @@ let onFirstMount = () => {
});
});
});
});
//let promise = /* Promise.resolve() */.then(() => {//import('../lib/services').then(services => {
/* fetch('assets/img/camomile.jpg')