Skip to content

Commit 20f9dbf

Browse files
committed
make flow happy
1 parent 906b595 commit 20f9dbf

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

source/views/menus/menu-bonapp.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,13 @@ export class BonAppHostedMenu extends React.PureComponent<Props, State> {
7878
}
7979

8080
componentDidUpdate() {
81-
if (
82-
(typeof this.state.cachedCafe === 'string' &&
83-
this.state.cachedCafe !== this.props.cafe) ||
84-
(typeof this.state.cachedCafe !== 'string' &&
85-
this.state.cachedCafe.id !== this.props.cafe.id)
86-
) {
81+
let {cachedCafe} = this.state
82+
let {cafe: newCafe} = this.props
83+
84+
cachedCafe = typeof cachedCafe === 'string' ? cachedCafe : cachedCafe.id
85+
newCafe = typeof newCafe === 'string' ? newCafe : newCafe.id
86+
87+
if (cachedCafe !== newCafe) {
8788
this.fetchData(this.props)
8889
}
8990
}
@@ -100,12 +101,13 @@ export class BonAppHostedMenu extends React.PureComponent<Props, State> {
100101

101102
let menuUrl
102103
let cafeUrl
104+
let cafe = typeof props.cafe === 'string' ? props.cafe : props.cafe.id
103105
if (typeof props.cafe === 'string') {
104-
menuUrl = API(`/food/named/menu/${props.cafe}`)
105-
cafeUrl = API(`/food/named/cafe/${props.cafe}`)
106+
menuUrl = API(`/food/named/menu/${cafe}`)
107+
cafeUrl = API(`/food/named/cafe/${cafe}`)
106108
} else if (props.cafe.hasOwnProperty('id')) {
107-
menuUrl = API(`/food/menu/${props.cafe.id}`)
108-
cafeUrl = API(`/food/cafe/${props.cafe.id}`)
109+
menuUrl = API(`/food/menu/${cafe}`)
110+
cafeUrl = API(`/food/cafe/${cafe}`)
109111
} else {
110112
throw new Error('invalid cafe passed to BonappMenu!')
111113
}

0 commit comments

Comments
 (0)