Skip to content

Instantly share code, notes, and snippets.

@khola khola/roadmapper.js
Last active Jan 18, 2019

Embed
What would you like to do?
componentDidMount() {
Storage.list("roadmaps/")
.then(result =>
this.setState(
{
projects: result
.filter(e => e.size > 0 && e.key.includes("index.md"))
.map(e => e.key.split("/")[1])
.filter(e => e && e.length > 0)
},
() => this.setCurrentProject()
)
)
.catch(err => console.log(err));
}
setCurrentProject(key) {
const { projects } = this.state;
const currentProject = key || projects[0];
this.setState({ loading: true });
Storage.get(`roadmaps/${currentProject}/index.md`, { download: true })
.then(eRoadmap => {
this.setState(
{
content: String.fromCharCode.apply(null, eRoadmap.Body),
currentProject
},
() => {
Storage.get(`roadmaps/${currentProject}/details.md`, {
download: true
})
.then(eDetails => {
this.setState({
details: detailsToHtml(
String.fromCharCode.apply(null, eDetails.Body)
),
loading: false
});
})
.catch(e => this.setState({ details: "", loading: false }));
}
);
})
.catch(e => console.log(e));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.