Skip to content

Commit

Permalink
Lazy load mic.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
Carbrex committed Aug 30, 2024
1 parent 65b28ea commit e782cc2
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 249 deletions.
22 changes: 12 additions & 10 deletions ui/coordinateTrainer/src/coordinateTrainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ import CoordinateTrainerCtrl from './ctrl';
const patch = init([classModule, attributesModule, propsModule, eventListenersModule, styleModule]);

export function initModule(config: CoordinateTrainerConfig) {
const ctrl = new CoordinateTrainerCtrl(config, redraw);
const element = document.getElementById('trainer')!;
element.innerHTML = '';
const inner = document.createElement('div');
element.appendChild(inner);
let vnode = patch(inner, view(ctrl));
site.asset.loadEsm('mic').then(() => {
const ctrl = new CoordinateTrainerCtrl(config, redraw);
const element = document.getElementById('trainer')!;
element.innerHTML = '';
const inner = document.createElement('div');
element.appendChild(inner);
let vnode = patch(inner, view(ctrl));

function redraw() {
vnode = patch(vnode, view(ctrl));
}
function redraw() {
vnode = patch(vnode, view(ctrl));
}

menuHover();
menuHover();
});
}
6 changes: 4 additions & 2 deletions ui/round/src/ctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -838,8 +838,10 @@ export default class RoundController implements MoveRootCtrl {
this.keyboardMove.update(up);
}
if (this.data.pref.voiceMove) {
if (this.voiceMove) this.voiceMove.update(up);
else this.voiceMove = makeVoiceMove(this, up);
site.asset.loadEsm('mic').then(() => {
if (this.voiceMove) this.voiceMove.update(up);
else this.voiceMove = makeVoiceMove(this, up);
});
}
if (this.keyboardMove || this.voiceMove) requestAnimationFrame(() => this.redraw());
site.pubsub.on('board.change', (is3d: boolean) => {
Expand Down
3 changes: 2 additions & 1 deletion ui/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"src/site.ts",
"src/site.tvEmbed.ts",
"src/site.puzzleEmbed.ts",
"src/site.lpvEmbed.ts"
"src/site.lpvEmbed.ts",
"src/mic.ts"
],
"sync": {
"node_modules/dialog-polyfill/dist/dialog-polyfill.esm.js": "public/npm"
Expand Down
Loading

0 comments on commit e782cc2

Please sign in to comment.