From 7c4573544d33f66bec2b18f1e9db888fd97b36ba Mon Sep 17 00:00:00 2001 From: aladoui <125268611+aladoui@users.noreply.github.com> Date: Fri, 5 Jul 2024 08:43:07 +0100 Subject: [PATCH 1/3] fix matcher matching only on local tag --- src/matcher.ts | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/matcher.ts b/src/matcher.ts index 15e2cb0..e21581b 100644 --- a/src/matcher.ts +++ b/src/matcher.ts @@ -1,10 +1,7 @@ -import {MatcherResult, SkillEnv} from '@matterway/types'; +import {MatcherResult} from '@matterway/types'; import manifest from './manifest.json'; -export default function matcher( - window: Window, - skillEnv: SkillEnv, -): MatcherResult { +export default function matcher(window: Window): MatcherResult { const forceSkillMatch = window.location.hash === `#mw-force-skill-match-${manifest.identifier}`; @@ -22,8 +19,7 @@ export default function matcher( const triggerUrl = 'https://yetiforce.matterway.io/index.php?module=Home&view=DashBoard'; - const matcherResult = - window.location.href.includes(triggerUrl) && skillEnv.tag === 'local'; + const matcherResult = window.location.href.includes(triggerUrl); console.debug(`${manifest.name} matcher result:`, matcherResult); return matcherResult; From b66e5b1cc57ba05ab186b6e7bccbf17f5095d7a5 Mon Sep 17 00:00:00 2001 From: aladoui <125268611+aladoui@users.noreply.github.com> Date: Fri, 5 Jul 2024 08:43:14 +0100 Subject: [PATCH 2/3] fix themes --- src/background.tsx | 4 +--- src/content.tsx | 51 +++++++++++----------------------------------- 2 files changed, 13 insertions(+), 42 deletions(-) diff --git a/src/background.tsx b/src/background.tsx index 31f77ec..454af89 100644 --- a/src/background.tsx +++ b/src/background.tsx @@ -6,7 +6,7 @@ import {startStep} from 'steps/@start'; export default async function (ctx: Context) { console.clear(); initI18n(ctx.languageCode); - const themeWatcher = await initTheme(ctx); + await initTheme(ctx); try { await startStep(ctx); } catch (err) { @@ -15,7 +15,5 @@ export default async function (ctx: Context) { await failureStep(ctx, err as Error); throw err; - } finally { - await themeWatcher.stop(); } } diff --git a/src/content.tsx b/src/content.tsx index 70559d0..10b8ca0 100644 --- a/src/content.tsx +++ b/src/content.tsx @@ -21,43 +21,16 @@ const reactMountRoot = createSkillMountRoot({ }); const root = createRoot(reactMountRoot); -const renderApp = () => { - root.render( - - - { - initI18n(languageCode); - }} - /> - - , - ); -}; +root.render( + + + { + initI18n(languageCode); + }} + /> + + , +); -const waitForTheme = async () => { - const timeoutPromise = new Promise((_resolve, reject) => { - setTimeout(() => { - reject(new Error('MW_THEME not found')); - }, 2000); - }); - - const themePromise = new Promise((resolve) => { - const interval = setInterval(() => { - if ((window as any).MW_THEME) { - clearInterval(interval); - resolve((window as any).MW_THEME); - } - }, 10); - }); - - try { - await Promise.race([timeoutPromise, themePromise]); - } catch (error) { - console.log(error); - } - renderApp(); -}; - -void waitForTheme(); From 88a428cbed4ce56636514f828bcd0f1d9d53aad7 Mon Sep 17 00:00:00 2001 From: aladoui <125268611+aladoui@users.noreply.github.com> Date: Fri, 5 Jul 2024 08:51:03 +0100 Subject: [PATCH 3/3] lint --- src/content.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/content.tsx b/src/content.tsx index 10b8ca0..e0e6534 100644 --- a/src/content.tsx +++ b/src/content.tsx @@ -33,4 +33,3 @@ root.render( , ); -