From 3076c6cffdb3a4398f82a556d0673ae56dc08cc0 Mon Sep 17 00:00:00 2001 From: Xmader Date: Tue, 10 Nov 2020 09:46:35 -0500 Subject: [PATCH] fix: buttons disappear after 1s --- src/btn.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/btn.ts b/src/btn.ts index 2475280..d2b64d8 100644 --- a/src/btn.ts +++ b/src/btn.ts @@ -1,5 +1,6 @@ import { loadMscore, WebMscore } from './mscore' +import { webpackGlobalOverride } from './webpack-hook' import i18n from './i18n' type BtnElement = HTMLButtonElement @@ -35,6 +36,24 @@ interface BtnOptions { readonly tooltip?: string; } +const SCORE_BTN_MODULE_ID = 'WYqd' +webpackGlobalOverride(SCORE_BTN_MODULE_ID, (_, r, t) => { // override + const fn = r.a + let firstTime = true + // the root container of btns refreshes every 1s + t.d(r, 'a', () => { + return function () { + if (!firstTime) { + // force state update + this.__H.__[0].__[0] = 0 + } else { + firstTime = false + } + return fn() as void + } + }) +}) + export class BtnList { private readonly list: BtnElement[] = [];