diff --git a/frontend/src/toolbar/stats/currentPageLogic.ts b/frontend/src/toolbar/stats/currentPageLogic.ts index 276345a209222..d116c95186f9c 100644 --- a/frontend/src/toolbar/stats/currentPageLogic.ts +++ b/frontend/src/toolbar/stats/currentPageLogic.ts @@ -1,22 +1,22 @@ -import { kea } from 'kea' +import { actions, events, kea, path, reducers } from 'kea' import type { currentPageLogicType } from './currentPageLogicType' -export const currentPageLogic = kea({ - path: ['toolbar', 'stats', 'currentPageLogic'], - actions: () => ({ +export const currentPageLogic = kea([ + path(['toolbar', 'stats', 'currentPageLogic']), + actions(() => ({ setHref: (href: string) => ({ href }), setWildcardHref: (href: string) => ({ href }), - }), + })), - reducers: () => ({ + reducers(() => ({ href: [window.location.href, { setHref: (_, { href }) => href }], wildcardHref: [ window.location.href, { setHref: (_, { href }) => href, setWildcardHref: (_, { href }) => href }, ], - }), + })), - events: ({ actions, cache, values }) => ({ + events(({ actions, cache, values }) => ({ afterMount: () => { cache.interval = window.setInterval(() => { if (window.location.href !== values.href) { @@ -34,5 +34,5 @@ export const currentPageLogic = kea({ window.clearInterval(cache.interval) window.removeEventListener('popstate', cache.location) }, - }), -}) + })), +])