Skip to content

Commit

Permalink
Improve language switching reactivity further by forcing a rerender o…
Browse files Browse the repository at this point in the history
…f all widgets when the local is changed
  • Loading branch information
Kristo Lippur committed Sep 10, 2021
1 parent e4772ad commit cf3e43c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "victron-venus-metrics",
"version": "2.0.6",
"version": "2.0.7",
"description": "Metric framework for Victron VenusOS",
"license": "ISC",
"author": "",
Expand Down
7 changes: 7 additions & 0 deletions src/app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import React, { useEffect } from "react"
import "../css/index.scss"
import { getLocale } from "react-i18nify"
import Loading from "./MarineApp/components/Loading"
import { useVisibleWidgetsStore } from "./MarineApp/modules"

const KVNRV = React.lazy(() => import("./KVNRV"))
const MarineApp = React.lazy(() => import("./MarineApp"))
Expand All @@ -19,6 +20,7 @@ const App = observer((props: AppProps) => {
const appStore = useAppStore()
const mqtt = useMqtt()
const locale = getLocale()
const visibleWidgetsStore = useVisibleWidgetsStore()
useVebus()

useEffect(() => {
Expand Down Expand Up @@ -48,6 +50,11 @@ const App = observer((props: AppProps) => {
locale,
])

useEffect(() => {
visibleWidgetsStore.clearVisibleElements()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [locale])

if (whitelabel === "KVNRV") {
return (
<React.Suspense fallback={<Loading />}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ export class VisibleWidgets {
get noVisibleElements() {
return !this.visibleElements.size
}

clearVisibleElements() {
this.visibleElements.clear()
}
}

let store: VisibleWidgets
Expand Down

0 comments on commit cf3e43c

Please sign in to comment.