How does NodeBB redirect the browser after posting?
-
Continuing the discussion from NodeBB Support Group:
After posting a reply the browser scrolls to the bottom of the topic. The browser should stay where it was so the user can keep reading from where he left off (even if it's only a user option to do so).
We have a lot of long topics and losing one's place in there causes a lot of grief.I'm trying to figure out how this happens in the code and I'm at a complete loss. I've been focusing my attention on
src/posts/create.js
, but I can't tell what might be doing it.
-
Might also be handled by
Topics.reply
in/src/topics/create.js
. That callsposts.create
,onNewPost
, and some other stuff. Can't find the scrolling/navigating stuff yet...
-
I assume you guys are looking at serverside code? I'd say find the function that triggers clientside when you hit reply, it's likely that the scrolling code is somewhere in the
.done
(or equivalent if not jQuery) handler of thePOST
request.
-
Ah, I see stuff in
public/src/client/topic/posts.js
. In particular a call to something calledscrollToPostIfSelf
.
-
Awwwww.....shit. I just realized that I need to make changes across 3 different projects:
- NodeBB
- nodebb-theme-vanilla
- nodebb-theme-persona
-
nodebb-theme-persona
http://www.destructoid.com/ul/user/2/207789-289101-Persona3ADjpg-620x.jpg
Filed under: actually kinda want
-
I have no idea what that means. Why would you post japanamation stuff in my thread?
-
It's a thing called Persona.
-
Look, here's how this works. I can either explain the already weak joke, therefore ruining it completely, or just leave you hanging so that maybe someone who gets it gets a mild chuckle.
Also, not to be a helpless cunt in a Coding Help thread:
I just realized that I need to make changes across 3 different projects:
Why? As far as I can tell, the themes are nothing but a bunch of CSS. And that should be overridable via the admin interface.
So's the JS that changes your position, probably, if you can get to it client-side.
-
I can either explain the already weak joke, therefore ruining it completely, or just leave you hanging so that maybe someone who gets it gets a mild chuckle
Please don't. I don't really care. I have no clue what it is, but my New Year's Resolution is to refer to anime as japanimation.
Why? As far as I can tell, the themes are nothing but a bunch of CSS.
There are lots of templates in there. Those were the only places I could find that defined the account settings interface.
-
As far as I can tell, the themes are nothing but a bunch of CSS.
Those are the skins.
-
Please don't.
Too late, @Choonster already took the decision away from me.
Those were the only places I could find that defined the account settings.
...oh, if you want to make it into a setting, you'll probably want to do it right and use the settings plugin framework.
You can refer to said settings in the client-side Javascripts, but I can't find how to override the action instead of hooking to it.
-
Too late, @Choonster already took the decision away from me.
Not really.
You can refer to said settings in the client-side Javascripts, but I can't find how to override the action instead of hooking to it.
Yeah, I don't think this can be a pure plug-in. The behavior is wired into the core system.
-
@boomzilla Hang on, maybe I can help (sorry I didn't get to this earlier, I was actually tweaking the composer itself on an unrelated issue: https://github.com/NodeBB/NodeBB/issues/4371)
Let me just check the code now...
-
I just submitted the pull requests.
(Now off to Cub Scouts...)
-
As long as I can control my party... I still can't believe they thought it was a good idea to make your party AI-controlled for persona 3. Also not as edgy.
-
Will respond more in detail in PR, but
scrollToPostIfSelf
is too late... happens after page load if pagination enabled...hmmm
-
Ah. Yes...didn't test that.
-
OK...resubmitted. Your solution was much better, of course.
-
So...second attempt:
One of the devs said:
https://github.com/NodeBB/NodeBB/pull/4374/files#r56478592 Can you change this to ajaxify.data.scrollToMyPost and add scrollToMyPost here https://github.com/NodeBB/NodeBB/blob/master/src/controllers/topics.js#L261 so it is passed to the client.
...and I was like:
@boomzilla said:
Changing to ajaxify.data is easy, though the way it is now seems to work. I don't understand why this is better (but I'll be honest, I've barely scratched the surface of figuring out how everything fits together).
Also, I've been looking and I have no clue how to make the change in controllers/topics.js or why it's necessary. Also, the change seems to get passed to the client already.
So...we'll see...
-
I think the reason for the request is simply to keep everything consistent; in that section of code, the other settings are fetched through
ajaxify.data
-
I guess that sort of makes sense. Although literally the stuff in there was using
config
, and and the stuff in theonNewPost*()
functions do, too.The second bit about controllers/topics.js is the big stumbling block for me. A lot of this node style coding is still voodoo to me.
-
-
More like:
https://youtu.be/9SSUQxGjZZ4
-
-
Double oh.
(Seems to better illustrate Boomzillas experience with this PR)
-
A lot of this node style coding is still voodoo to me.
it's taken me...... how long have i been working on @SockBot a year and a half?
somehting like that...
wait....
where was i?
OH! right.
it's taken me a year and a half to wrap my head fully around the nodejs programming styles. I used to think i was a bit of a rockstar coder, now i'm not sure if i was wrong or if a lot of the "rockstars" are secretly "complicators"
i wonder what they would do if i walked up to them and said "gloves".....
-
-
i wonder what they would do if i walked up to them and said "gloves".....
They would ask you if there's a Ruby gem for that.
-
AH HA HA HA HA HA... ha ha....haaaa....
bugger me with a purple dildo....
they would too...
.....
now i has a sad.
-
-
@accalia said:
bugger me with a purple dildo....
I was informed that's not my job.
You have been informed correctly.now i has a sad.
*gives you your favourite chew toy*
-
Yes mistress U+1F498, I shall appear as summoned.
-
I used to think i was a bit of a rockstar coder
From what I can tell, in the original sense, that ability you have to take a seed of an idea about programming, learn more about it from examples, and adapt it into things that work for you makes you a "rockstar". The fact that in a year and a half you've picked up, learned from, and discarded half a dozen programming styles in order to separate the wheat from the chaff is one of the key indicators for being in the top whatever percent of coders.
Also almost everyone here qualifies. Maybe not fbmac, though. Deleting code isn't a style
-
Looks like this got released today:
-
@ben_lubar, are we planning to deploy that version? Having that new setting will really reduce pain levels.
-
-
So wait... in under three days, not only has a feature been suggested, but it's been implemented, submitted, accepted and rolled into a new release?
-
-
Test
-
@loopback0 I'm having to refresh to see my post, regardless of what this setting is set to?
-
Hmmm, maybe not. It seems inconsistent?
TO THE TEST MOBILE!!!!
-
@loopback0 said:
@loopback0 I'm having to refresh to see my post, regardless of what this setting is set to?
Ditto, I have to refresh to see ANY new posts in a thread
-
@LB_ Some testing with reloads in between suggests that having "scroll to my post" enabled shows me the post without a refresh, but disabling it means I have to refresh.
FYI @boomzilla
-
@sockbot said:
Yes mistress U+1F498, I shall appear as summoned.
Oh, html-comments are de-fusticated?
(Testing the scroll-to-posts regression)
-
@loopback0 Yep. I've started taking a look at this. Basically, with that setting on, you don't get the new post until the next polling interval ends. This is due to where @julianlam suggested testing for the setting.
I've been playing with it in my dev environment and I've gone back to my original solution plus some additional checking for the pagination case. So basically, stuff gets loaded as required when the post is created.
-
I've opened this:
The new setting in #4363 has the unfortunate effect of preventing new posts from loading in after making a post until a refresh or the next round of polling happens.
Basically, the check happens too soon and prevents some useful things happening in addition to the scrolling.
I think I have a fix for it, so will be submitting a PR.
-
-
@boomzilla Is there a feature request for notification settings in the bug tracker yet?
Because that's a really essential feature, I need to be able to mute those like notifications.
-
@asdf I don't know. You might enquire on https://community.nodebb.org