Skip to content

Commit

Permalink
feat(ui): save theme information on combo data
Browse files Browse the repository at this point in the history
Also bump combo-store version to v2
  • Loading branch information
mateusfg7 committed Oct 3, 2023
1 parent 22db0cf commit 3dcfcc6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 5 additions & 3 deletions src/components/header/combo-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {

export function ComboList() {
const theme = useThemeStore(set => set.theme)
const setTheme = useThemeStore(set => set.setTheme)
const sounds = useSoundsStateStore(state => state.sounds)
const bulkUpdate = useSoundsStateStore(state => state.bulkUpdate)
const combos = useComboStore(state => state.combos)
Expand All @@ -39,12 +40,13 @@ export function ComboList() {
.map(sound => ({ ...sound, active: false }))

console.log(
`enabledSounds: ${comboSounds.map(
sound => `${sound.id}:${sound.volume}`
)}`
`
theme: ${combo[0].theme}
enabledSounds: ${comboSounds.map(sound => `${sound.id}:${sound.volume}`)}`
)

bulkUpdate([...disabledSounds, ...comboSounds])
setTheme(combo[0].theme)
}

useEffect(() => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/save-combo-button/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ export function SaveComboButton() {
saveCombo({
id: faker.string.alphanumeric({ casing: 'lower', length: 6 }),
name: comboName,
sounds: activeSounds
sounds: activeSounds,
theme
})

setComboName('')
Expand Down
4 changes: 3 additions & 1 deletion src/stores/combo-store.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import { create } from 'zustand'
import { SoundState } from './sounds-state-store'
import { persist } from 'zustand/middleware'
import { Theme } from './theme-store'

interface Combo {
id: string
name: string
theme: Theme
sounds: SoundState[]
}

Expand All @@ -27,6 +29,6 @@ export const useComboStore = create<Props>()(
set({ combos })
}
}),
{ name: 'combo-store', version: 1 }
{ name: 'combo-store', version: 2 }
)
)

0 comments on commit 3dcfcc6

Please sign in to comment.