Skip to content

Commit

Permalink
chore(kea): upgrade current page logic to v3
Browse files Browse the repository at this point in the history
  • Loading branch information
thmsobrmlr committed Oct 26, 2023
1 parent b68ba2d commit 57d8fef
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions frontend/src/toolbar/stats/currentPageLogic.ts
Original file line number Diff line number Diff line change
@@ -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<currentPageLogicType>({
path: ['toolbar', 'stats', 'currentPageLogic'],
actions: () => ({
export const currentPageLogic = kea<currentPageLogicType>([
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) {
Expand All @@ -34,5 +34,5 @@ export const currentPageLogic = kea<currentPageLogicType>({
window.clearInterval(cache.interval)
window.removeEventListener('popstate', cache.location)
},
}),
})
})),
])

0 comments on commit 57d8fef

Please sign in to comment.