Browse Source

Fix blinking fonts again

Fix manifest for PWA
master
Eduard Kuzmenko 4 years ago
parent
commit
a034f207c8
  1. 5
      src/components/languageChangeButton.ts
  2. 12
      src/helpers/dom/loadFonts.ts
  3. 6
      src/index.ts
  4. 2
      src/lib/appManagers/appDialogsManager.ts
  5. 5
      src/pages/pageIm.ts

5
src/components/languageChangeButton.ts

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

12
src/helpers/dom/loadFonts.ts

@ -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();
}

6
src/index.ts

@ -8,6 +8,7 @@ import App from './config/app';
import blurActiveElement from './helpers/dom/blurActiveElement'; import blurActiveElement from './helpers/dom/blurActiveElement';
import findUpClassName from './helpers/dom/findUpClassName'; import findUpClassName from './helpers/dom/findUpClassName';
import fixSafariStickyInput from './helpers/dom/fixSafariStickyInput'; import fixSafariStickyInput from './helpers/dom/fixSafariStickyInput';
import loadFonts from './helpers/dom/loadFonts';
import { isMobileSafari } from './helpers/userAgent'; import { isMobileSafari } from './helpers/userAgent';
import './materialize.scss'; import './materialize.scss';
import './scss/style.scss'; import './scss/style.scss';
@ -261,11 +262,6 @@ console.timeEnd('get storage1'); */
const langPromise = I18n.default.getCacheLangPack(); 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([ const [state, langPack] = await Promise.all([
appStateManager.default.getState(), appStateManager.default.getState(),
langPromise langPromise

2
src/lib/appManagers/appDialogsManager.ts

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

5
src/pages/pageIm.ts

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

Loading…
Cancel
Save