Skip to content

Commit

Permalink
Fixing the theme based on the zcl package chosen (project-chip#1295)
Browse files Browse the repository at this point in the history
JIRA: MCUDT-34394
  • Loading branch information
brdandu authored Apr 2, 2024
1 parent c9ca9f7 commit 5cc7614
Showing 1 changed file with 24 additions and 14 deletions.
38 changes: 24 additions & 14 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,24 @@ const observable = require('./util/observable.js')
const dbEnum = require(`../src-shared/db-enum.js`)
const storage = require('./util/storage.js')
window.addEventListener('message', (event) => {
window.addEventListener(
'message',
(event) => {
const eventData = event?.data?.eventData
switch (event?.data?.eventId) {
case 'theme':
window[rendApi.GLOBAL_SYMBOL_EXECUTE](rendApi.id.setDarkTheme, eventData.theme === 'dark')
window[rendApi.GLOBAL_SYMBOL_EXECUTE](
rendApi.id.setDarkTheme,
eventData.theme === 'dark'
)
break
case 'save':
if (eventData.shouldSave) {
window[rendApi.GLOBAL_SYMBOL_EXECUTE](rendApi.id.save)
}
break
}
},
},
false
)
Expand Down Expand Up @@ -131,7 +136,13 @@ export default defineComponent({
},
uiThemeCategory: {
get() {
return this.$store.state.zap.selectedZapConfig?.zclProperties.category
let zclProps = this.$store.state.zap.selectedZapConfig?.zclProperties
// Picking the first category in the case of multi-protocol(zigbee/matter)
if (Array.isArray(zclProps) && zclProps.length > 0) {
return zclProps[0].category
} else {
return this.$store.state.zap.selectedZapConfig?.zclProperties.category
}
},
},
},
Expand Down Expand Up @@ -231,12 +242,9 @@ export default defineComponent({
}
)
this.$onWebSocket(
dbEnum.wsCategory.dirtyFlag,
(resp) => {
this.$store.dispatch('zap/setDirtyState', resp)
}
)
this.$onWebSocket(dbEnum.wsCategory.dirtyFlag, (resp) => {
this.$store.dispatch('zap/setDirtyState', resp)
})
},
addClassToBody() {
if (this.uiThemeCategory === 'zigbee') {
Expand Down Expand Up @@ -264,13 +272,15 @@ export default defineComponent({
},
mounted() {
this.addClassToBody()
window?.parent?.postMessage({
window?.parent?.postMessage(
{
eventId: 'mounted',
eventData: {
hasMounted: true
}
hasMounted: true,
},
},
'*')
'*'
)
},
unmounted() {
if (this.uiThemeCategory === 'zigbee') {
Expand Down

0 comments on commit 5cc7614

Please sign in to comment.