Adjust modal to not interfere with pull-to-refresh (#888)

* Remove unnecessary code from onboarding

* Adjust pull-to-refresh button to account for open modal scenario
This commit is contained in:
Ben Halpern 2018-10-11 16:45:43 -04:00 committed by GitHub
parent 775dca2142
commit b13c09583f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 52 deletions

View file

@ -31,8 +31,7 @@
onRefresh: function () { return location.reload(); },
resistanceFunction: function (t) { return Math.min(1, t / 2.5); },
shouldPullToRefresh: function () {
return !window.scrollY && document.getElementById('articles-list')
return !window.scrollY && document.getElementById('articles-list') && !document.body.classList.contains('modal-open')
},
};

View file

@ -1,7 +1,4 @@
@import 'variables';
html {
overflow-y:scroll;
}
body {
background: $lightest-gray;
@ -11,6 +8,7 @@ body {
padding:0 !important;
margin:0 !important;
margin-top:-20px !important;
overflow-y:scroll;
:focus {
outline: 0;
}
@ -25,6 +23,7 @@ body {
margin: 0;
overflow: hidden;
overflow-y: hidden;
height: 90vh;
}

View file

@ -40,7 +40,7 @@ class Onboarding extends Component {
componentDidMount() {
this.updateUserData();
this.getUserTags();
document.getElementsByTagName('body')[0].classList.add('modal-open');
document.getElementsByTagName("body")[0].classList.add("modal-open");
}
getUserTags() {
@ -89,27 +89,6 @@ class Onboarding extends Component {
});
}
getSuggestedArticles() {
const followedTags = [];
for (let i = 0; i < this.state.allTags.length; i += 1) {
if (this.state.allTags[i].following) {
followedTags.push(this.state.allTags[i].name);
}
}
fetch(`/api/articles/onboarding?tag_list=${followedTags.join(',')}`, {
headers: {
Accept: 'application/json',
'Content-Type': 'application/json',
},
credentials: 'same-origin',
})
.then(response => response.json())
.then(json => {
this.setState({ articles: json, savedArticles: json });
});
}
handleBulkFollowUsers(users) {
if (this.state.checkedUsers.length > 0 && !this.state.followRequestSent) {
const csrfToken = document.querySelector("meta[name='csrf-token']")
@ -133,29 +112,6 @@ class Onboarding extends Component {
}
}
handleBulkSaveArticles(articles) {
if (this.state.savedArticles.length > 0 && !this.state.saveRequestSent) {
const csrfToken = document.querySelector("meta[name='csrf-token']")
.content;
const formData = new FormData();
formData.append('articles', JSON.stringify(articles));
fetch('/api/reactions/onboarding', {
method: 'POST',
headers: {
'X-CSRF-Token': csrfToken,
},
body: formData,
credentials: 'same-origin',
}).then(response => {
if (response.ok) {
this.setState({ saveRequestSent: true });
}
});
}
}
handleUserProfileSave() {
const csrfToken = document.querySelector("meta[name='csrf-token']")
.content;
@ -278,7 +234,6 @@ class Onboarding extends Component {
handleNextHover() {
if (this.state.pageNumber === 2 && this.state.users.length === 0) {
this.getUsersToFollow();
this.getSuggestedArticles();
}
}
@ -289,7 +244,6 @@ class Onboarding extends Component {
this.state.articles.length === 0
) {
this.getUsersToFollow();
this.getSuggestedArticles();
}
if (this.state.pageNumber < 5) {
this.setState({ pageNumber: this.state.pageNumber + 1 });