Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Circumvents issue with endless refreshing on #messages tab #512

Merged
merged 5 commits into from
Oct 16, 2018

Conversation

philippbayer
Copy link
Member

Have a look - does it work on your ends too?

Could fix #425

app/assets/javascripts/application.js Outdated Show resolved Hide resolved
@@ -43,7 +43,7 @@
<li><%= link_to("Settings", "/users/"+current_user.id.to_s+"/edit", class: "navbar-menu__options", :id => current_user) %></li>
<li><%= link_to("Edit Your Phenotypes", "/users/"+current_user.id.to_s+"/edit#phenotypes", class: "navbar-menu__options")%></li>
<li class="divider"></li>
<li><%= link_to("Messages ("+current_user.messages.where(:user_has_seen => false).length.to_s+")","/users/" + current_user.id.to_s + "#messages", :method => "get", class: "navbar-menu__options")%></li>
<li><%= link_to "Messages (#{current_user.messages.where(:user_has_seen => false).length})","/users/#{current_user.id}#messages", class: 'navbar-menu__options', :data => { :reload => true }%></li>
Copy link
Collaborator

@tsujigiri tsujigiri Oct 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"/users/#{current_user.id}#messages" can be written as user_path(current_user, anchor: 'messages')*. And I suppose the :data => { :reload => true } might have something to do with the reloading? 😄

* https://api.rubyonrails.org/classes/ActionView/Helpers/UrlHelper.html#method-i-link_to

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah the :method => "get" causes an endless reload on my end (right now on production too), Firefox 62.0.3 - when I force the reload then the entire page reloads, but only once! and it lands on the correct tab

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which :method => "get"? I don't think it has anything to do with the link. It happens if you put https://www.opensnp.org/users/15#messages into your address bar as well. This looks a bit suspicious.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By method => get I mean the current way it's implement on production -
That JS snippet is definitely the main 'suspect', getting stuck in an endless loop - let me fix that. My forced reloading seems to not have triggered that JS, thereby circumventing it (on my system?)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what's missing in the JS is comparing hash with anchor and only redirecting if they don't match.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's weird is, that it only does that on the messages tab in the first place. 🤔

Copy link
Member Author

@philippbayer philippbayer Oct 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and why does this break only now? I put it in a year ago :P

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea. 😅

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how to do the tab thing properly, according to the docs.

$('#myTabs a[href="#profile"]').tab('show')

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've put in a new commit which gets rid of the method: get, and now it seems to work, even with the 'old' JS?

Copy link
Collaborator

@tsujigiri tsujigiri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷‍♂️

@philippbayer
Copy link
Member Author

🤷‍♂️ computers!

thank you for your help :)

@philippbayer philippbayer merged commit 3cbfc12 into master Oct 16, 2018
@philippbayer philippbayer deleted the CheckJS branch October 16, 2018 09:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Issues with message system
2 participants