-
Notifications
You must be signed in to change notification settings - Fork 46
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
Conversation
app/views/layouts/_navbar.html.erb
Outdated
@@ -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> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 🤔
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have no idea. 😅
There was a problem hiding this comment.
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')
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤷♂️
🤷♂️ computers! thank you for your help :) |
Have a look - does it work on your ends too?
Could fix #425