reorder JS execution

pull/7399/head
Thibault Duplessis 2020-10-01 09:49:06 +02:00
parent a74cf1cacd
commit fe92d39b6e
1 changed files with 10 additions and 10 deletions

View File

@ -1,5 +1,6 @@
import * as miniBoard from "./component/mini-board";
import * as miniGame from "./component/mini-game";
import * as timeago from "./component/timeago";
import * as xhr from 'common/xhr';
import announce from './component/announce';
import exportLichessGlobals from "./site.lichess.globals";
@ -11,12 +12,11 @@ import powertip from "./component/powertip";
import pubsub from "./component/pubsub";
import serviceWorker from "./component/serviceWorker";
import StrongSocket from "./component/socket";
import * as timeago from "./component/timeago";
import topBar from "./component/top-bar";
import watchers from "./component/watchers";
import { userComplete } from "./component/assets";
import { reload } from "./component/reload";
import { requestIdleCallback } from "./component/functions";
import { userComplete } from "./component/assets";
exportLichessGlobals();
lichess.info = info;
@ -29,6 +29,14 @@ lichess.load.then(() => {
requestAnimationFrame(() => {
miniBoard.initAll();
miniGame.initAll();
pubsub.on('content-loaded', miniBoard.initAll);
pubsub.on('content-loaded', miniGame.initAll);
timeago.updateRegularly(1000);
pubsub.on('content-loaded', timeago.findAndRender);
const friendsEl = document.getElementById('friend_box');
if (friendsEl) new OnlineFriends(friendsEl);
@ -64,9 +72,6 @@ lichess.load.then(() => {
powertip.watchMouse();
timeago.updateRegularly(1000);
pubsub.on('content-loaded', timeago.findAndRender);
setTimeout(() => {
if (!lichess.socket)
lichess.socket = new StrongSocket("/socket/v5", false);
@ -128,11 +133,6 @@ lichess.load.then(() => {
el.setAttribute('content', el.getAttribute('content') + ',maximum-scale=1.0');
}
miniBoard.initAll();
miniGame.initAll();
pubsub.on('content-loaded', miniBoard.initAll);
pubsub.on('content-loaded', miniGame.initAll);
const chatMembers = document.querySelector('.chat__members') as HTMLElement | null;
if (chatMembers) watchers(chatMembers);