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

Commit

Permalink
Merge pull request #180 from BoostIO/fix-dropbox-bug
Browse files Browse the repository at this point in the history
remove unnecessary createNoteButton
  • Loading branch information
kazup01 authored Jan 13, 2018
2 parents 612f56f + 832e9dc commit 63af838
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
21 changes: 17 additions & 4 deletions app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ export default class App extends Component {
noteList: [],
fileName: '',
content: '',
filterFavorites: false
filterFavorites: false,
isConnectedToDropbox: false
}

// Init AwsMobileAnalytics
Expand Down Expand Up @@ -325,8 +326,14 @@ export default class App extends Component {
}
}

setIsConnectedToDropbox (value) {
this.setState({
isConnectedToDropbox: value
})
}

render () {
const { noteList, mode, filterFavorites, isNoteOpen, fileName, content } = this.state
const { noteList, mode, filterFavorites, isNoteOpen, fileName, content, isConnectedToDropbox } = this.state
return (
<Drawer
ref={(ref) => {
Expand All @@ -351,11 +358,17 @@ export default class App extends Component {
filterFavorite={filterFavorites}
onStarPress={this.onStarPress}
setNoteModalIsOpen={this.setNoteModalIsOpen} />
: <DropboxNoteList ref='dropboxNoteList' />
: <DropboxNoteList ref='dropboxNoteList'
isConnectedToDropbox={isConnectedToDropbox}
setIsConnectedToDropbox={this.setIsConnectedToDropbox.bind(this)} />
}
</Container>
<View>
<CreateNewNoteButton onPressActionButton={this.onPressActionButton} />
{
mode === 1 && !isConnectedToDropbox
? null
: <CreateNewNoteButton onPressActionButton={this.onPressActionButton} />
}
<NoteModal setIsOpen={this.setNoteModalIsOpen}
isNoteOpen={isNoteOpen}
fileName={fileName}
Expand Down
19 changes: 6 additions & 13 deletions app/views/DropboxNoteList.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ export default class DropboxNoteList extends Component {
note: '',
isNoteOpen: false,
isLoading: false,
isConnectedToDropbox: false,
isNotConnectedToBoostnote: false,
code: ''
}
Expand All @@ -136,20 +135,16 @@ export default class DropboxNoteList extends Component {
AsyncStorage.getItem(DROPBOX_ACCESS_TOKEN)
.then((value) => {
if (value === null) {
this.setState({
isConnectedToDropbox: false
})
this.props.setIsConnectedToDropbox(false)
} else {
this.props.setIsConnectedToDropbox(true)
this.setState({
isConnectedToDropbox: true,
token: value
}, this.getDropboxNoteData(value))
}
})
.catch((e) => {
this.setState({
isConnectedToDropbox: false
})
this.props.setIsConnectedToDropbox(false)
})
}

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

if (responseJson.error_summary && responseJson.error_summary.startsWith('path/not_found/')) {
this.setState({
isNotConnectedToBoostnote: true
})
this.props.setIsConnectedToDropbox(true)
}
if (!responseJson.entries || responseJson.entries.length === 0) {
this.setState({
Expand Down Expand Up @@ -428,7 +421,7 @@ export default class DropboxNoteList extends Component {
// Show Dropbox connect button when...
// 1. Not connected to Dropbox.
// 2. Not loading.
!this.state.isConnectedToDropbox && !this.state.isLoading
!this.props.isConnectedToDropbox && !this.state.isLoading
? <View>
<View style={styles.dropboxLinkButtonWrap}>
<Button style={styles.dropboxLinkButton}
Expand Down Expand Up @@ -469,7 +462,7 @@ export default class DropboxNoteList extends Component {
// 1. Connected to Dropbox.
// 2. Not connected to Boostnote.
// 3. Not loading.
this.state.isConnectedToDropbox && this.state.isNotConnectedToBoostnote && !this.state.isLoading
this.props.isConnectedToDropbox && this.state.isNotConnectedToBoostnote && !this.state.isLoading
? <View style={{ alignItems: 'center', justifyContent: 'center' }}>
<Text style={styles.bottomLinkWord}>Connect with Desktop app and create a note!</Text>
<View style={{
Expand Down

0 comments on commit 63af838

Please sign in to comment.