Skip to content

Commit

Permalink
avoid crash for #3069
Browse files Browse the repository at this point in the history
  • Loading branch information
aksonov committed Nov 23, 2018
1 parent a1b7364 commit c9af917
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/store/HomeStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,18 @@ const HomeStore = types
// sets new index for the current mode, deselects previously selected bot and select new one.
setIndex: (index: number): void => {
self.fullScreenMode = false
self.homeBotList[self.index].setSelected(false)
self.index = index
if (self.list.length) {
// select card
self.list[self.index].setSelected(true)
// change map center if bot card is selected
if (getType(self.list[self.index]) === BotCard) {
self.setFocusedLocation((self.list[self.index] as IBotCard).bot.location)
if (self.index < self.homeBotList.length) {
self.homeBotList[self.index].setSelected(false)
}
if (index < self.homeBotList.length) {
self.index = index
if (self.list.length) {
// select card
self.list[self.index].setSelected(true)
// change map center if bot card is selected
if (getType(self.list[self.index]) === BotCard) {
self.setFocusedLocation((self.list[self.index] as IBotCard).bot.location)
}
}
}
},
Expand All @@ -134,8 +138,8 @@ const HomeStore = types
if (index !== -1) {
self.homeBotList.splice(index, 1)
}
if (index >= self.index) {
self.index--
if (index <= self.index) {
self.setIndex(self.index - 1) // TODO set index within visible area
}
},
// toggleListMode: (): void => {
Expand Down

0 comments on commit c9af917

Please sign in to comment.