Skip to content
This repository was archived by the owner on Feb 21, 2020. It is now read-only.

Commit 63af838

Browse files
authored
Merge pull request #180 from BoostIO/fix-dropbox-bug
remove unnecessary createNoteButton
2 parents 612f56f + 832e9dc commit 63af838

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

app/App.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ export default class App extends Component {
105105
noteList: [],
106106
fileName: '',
107107
content: '',
108-
filterFavorites: false
108+
filterFavorites: false,
109+
isConnectedToDropbox: false
109110
}
110111

111112
// Init AwsMobileAnalytics
@@ -325,8 +326,14 @@ export default class App extends Component {
325326
}
326327
}
327328

329+
setIsConnectedToDropbox (value) {
330+
this.setState({
331+
isConnectedToDropbox: value
332+
})
333+
}
334+
328335
render () {
329-
const { noteList, mode, filterFavorites, isNoteOpen, fileName, content } = this.state
336+
const { noteList, mode, filterFavorites, isNoteOpen, fileName, content, isConnectedToDropbox } = this.state
330337
return (
331338
<Drawer
332339
ref={(ref) => {
@@ -351,11 +358,17 @@ export default class App extends Component {
351358
filterFavorite={filterFavorites}
352359
onStarPress={this.onStarPress}
353360
setNoteModalIsOpen={this.setNoteModalIsOpen} />
354-
: <DropboxNoteList ref='dropboxNoteList' />
361+
: <DropboxNoteList ref='dropboxNoteList'
362+
isConnectedToDropbox={isConnectedToDropbox}
363+
setIsConnectedToDropbox={this.setIsConnectedToDropbox.bind(this)} />
355364
}
356365
</Container>
357366
<View>
358-
<CreateNewNoteButton onPressActionButton={this.onPressActionButton} />
367+
{
368+
mode === 1 && !isConnectedToDropbox
369+
? null
370+
: <CreateNewNoteButton onPressActionButton={this.onPressActionButton} />
371+
}
359372
<NoteModal setIsOpen={this.setNoteModalIsOpen}
360373
isNoteOpen={isNoteOpen}
361374
fileName={fileName}

app/views/DropboxNoteList.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ export default class DropboxNoteList extends Component {
121121
note: '',
122122
isNoteOpen: false,
123123
isLoading: false,
124-
isConnectedToDropbox: false,
125124
isNotConnectedToBoostnote: false,
126125
code: ''
127126
}
@@ -136,20 +135,16 @@ export default class DropboxNoteList extends Component {
136135
AsyncStorage.getItem(DROPBOX_ACCESS_TOKEN)
137136
.then((value) => {
138137
if (value === null) {
139-
this.setState({
140-
isConnectedToDropbox: false
141-
})
138+
this.props.setIsConnectedToDropbox(false)
142139
} else {
140+
this.props.setIsConnectedToDropbox(true)
143141
this.setState({
144-
isConnectedToDropbox: true,
145142
token: value
146143
}, this.getDropboxNoteData(value))
147144
}
148145
})
149146
.catch((e) => {
150-
this.setState({
151-
isConnectedToDropbox: false
152-
})
147+
this.props.setIsConnectedToDropbox(false)
153148
})
154149
}
155150

@@ -199,9 +194,7 @@ export default class DropboxNoteList extends Component {
199194
const noteList = []
200195

201196
if (responseJson.error_summary && responseJson.error_summary.startsWith('path/not_found/')) {
202-
this.setState({
203-
isNotConnectedToBoostnote: true
204-
})
197+
this.props.setIsConnectedToDropbox(true)
205198
}
206199
if (!responseJson.entries || responseJson.entries.length === 0) {
207200
this.setState({
@@ -428,7 +421,7 @@ export default class DropboxNoteList extends Component {
428421
// Show Dropbox connect button when...
429422
// 1. Not connected to Dropbox.
430423
// 2. Not loading.
431-
!this.state.isConnectedToDropbox && !this.state.isLoading
424+
!this.props.isConnectedToDropbox && !this.state.isLoading
432425
? <View>
433426
<View style={styles.dropboxLinkButtonWrap}>
434427
<Button style={styles.dropboxLinkButton}
@@ -469,7 +462,7 @@ export default class DropboxNoteList extends Component {
469462
// 1. Connected to Dropbox.
470463
// 2. Not connected to Boostnote.
471464
// 3. Not loading.
472-
this.state.isConnectedToDropbox && this.state.isNotConnectedToBoostnote && !this.state.isLoading
465+
this.props.isConnectedToDropbox && this.state.isNotConnectedToBoostnote && !this.state.isLoading
473466
? <View style={{ alignItems: 'center', justifyContent: 'center' }}>
474467
<Text style={styles.bottomLinkWord}>Connect with Desktop app and create a note!</Text>
475468
<View style={{

0 commit comments

Comments
 (0)