Another attempt to fix RaidCombobox loading (#338)
This commit is contained in:
parent
a820e5ad5f
commit
e2effa0d66
1 changed files with 13 additions and 20 deletions
|
|
@ -112,15 +112,26 @@ const RaidCombobox = (props: Props) => {
|
||||||
|
|
||||||
// Fetch all raids on mount
|
// Fetch all raids on mount
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
sortGroups(appState.raidGroups)
|
const sections: [RaidGroup[], RaidGroup[], RaidGroup[]] = [[], [], []]
|
||||||
|
|
||||||
|
appState.raidGroups.forEach((group) => {
|
||||||
|
if (group.section > 0) sections[group.section - 1].push(group)
|
||||||
|
})
|
||||||
|
|
||||||
|
if (appState.raidGroups[0]) {
|
||||||
|
setFarmingRaid(appState.raidGroups[0].raids[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
setSections(sections)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
// Set current section when the current raid changes
|
// Set current section when the current raid changes
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('Raid has changed')
|
|
||||||
if (props.currentRaid) {
|
if (props.currentRaid) {
|
||||||
|
setCurrentRaid(props.currentRaid)
|
||||||
setCurrentSection(props.currentRaid.group.section)
|
setCurrentSection(props.currentRaid.group.section)
|
||||||
} else {
|
} else {
|
||||||
|
setCurrentRaid(undefined)
|
||||||
setCurrentSection(1)
|
setCurrentSection(1)
|
||||||
}
|
}
|
||||||
}, [props.currentRaid])
|
}, [props.currentRaid])
|
||||||
|
|
@ -201,24 +212,6 @@ const RaidCombobox = (props: Props) => {
|
||||||
else setSort(Sort.ASCENDING)
|
else setSort(Sort.ASCENDING)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sorts the raid groups into sections
|
|
||||||
const sortGroups = useCallback(
|
|
||||||
(groups: RaidGroup[]) => {
|
|
||||||
const sections: [RaidGroup[], RaidGroup[], RaidGroup[]] = [[], [], []]
|
|
||||||
|
|
||||||
groups.forEach((group) => {
|
|
||||||
if (group.section > 0) sections[group.section - 1].push(group)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (groups[0]) {
|
|
||||||
setFarmingRaid(groups[0].raids[0])
|
|
||||||
}
|
|
||||||
|
|
||||||
setSections(sections)
|
|
||||||
},
|
|
||||||
[setSections]
|
|
||||||
)
|
|
||||||
|
|
||||||
const handleSortButtonKeyDown = (
|
const handleSortButtonKeyDown = (
|
||||||
event: React.KeyboardEvent<HTMLButtonElement>
|
event: React.KeyboardEvent<HTMLButtonElement>
|
||||||
) => {
|
) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue