Skip to content

Commit

Permalink
Fix bug with changing mods that share a key. Added tab title
Browse files Browse the repository at this point in the history
  • Loading branch information
Vindexus committed Nov 10, 2023
1 parent 795ae0e commit 2460139
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/pages/Home/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ const CSS = {
card: 'w-full bg-gray-800 border border-gray-800 shadow-lg rounded-2xl p-4 mb-2',
}


const Home = () => {
const store = useWatchersEyeStore()
const selected = useWatchersEyeStore(state => state.auraSettings.filter(x => x.enabled))
const numSelected = selected.length
const tradeLink = useWatchersEyeStore(selTradeLink)
const [loadedURL, setLoadedURL] = useState(false)
const urlChangeRef = useRef<NodeJS.Timeout>()
const titleRef = useRef(document.title)

useEffect(() => {
if (!loadedURL) {
Expand Down Expand Up @@ -48,6 +50,16 @@ const Home = () => {
}, 300)
}, [loadedURL, tradeLink, numSelected])

const auraNames = selected.map(x => x.aura.name).join('+')
useEffect(() => {
if (selected.length === 0) {
document.title = titleRef.current
return
}

document.title = auraNames + ' ' + titleRef.current
}, [auraNames])

useEffect(() => {
function onChange () {
const params = new URL(document.location.toString()).searchParams
Expand All @@ -73,7 +85,6 @@ const Home = () => {
})
})

console.log('settingsPut', settingsPut)
store.setAuraSettings(settingsPut)
setLoadedURL(true)
}
Expand Down
3 changes: 3 additions & 0 deletions src/store/useWatchersEyeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const useWatchersEyeStore = create<WatchersEyeSearchStore>()(
setModEnabled: (ak: AuraKey, mk: string, enable: boolean) => {
set({
auraSettings: get().auraSettings.map((as) => {
if (ak !== as.key) {
return as
}
as.mods = as.mods.map((m) => {
if (m.mod.key === mk) {
return {
Expand Down

0 comments on commit 2460139

Please sign in to comment.